stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: Removing polyfills except for es5 builds breaks existing installs

Open gavmck opened this issue 1 year ago • 17 comments

Prerequisites

Stencil Version

4.18.1

Current Behavior

The PR to remove polyfills unless explicitly building es5 means that, although addPolyfills is still defined as being exported in the types, the function does not exist. This meant when we our package lock updated from 4.14.x to 4.18.1, the install broke.

PR https://github.com/ionic-team/stencil/pull/5725

Expected Behavior

Might be cleaner to keep exporting the function, but make it do nothing so the import doesn't explode before removing in the next major.

System Info

No response

Steps to Reproduce

Install stencil 4.14.x and use applyPolyfills. Update to stencil 4.18.1, watch build explode.

Code Reproduction URL

https://sorry.dont/have/this.biz

Additional Information

No response

gavmck avatar May 20 '24 09:05 gavmck

@gavmck thanks for raising the issue.

Unfortunately I was not able to verify that exploding build 😉 I created a new Stencil project, build it with v4.14.0 and then again with v4.18.1 and everything was fine:

❯ npm i
npm WARN deprecated [email protected]: < 22.5.0 is no longer supported

added 349 packages, and audited 350 packages in 6s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[18:02.0]  @stencil/core
[18:02.1]  v4.14.0 🚡
[18:02.8]  build, issue5780, prod mode, started ...
[18:02.8]  transpile started ...
[18:04.0]  transpile finished in 1.20 s
[18:04.0]  copy started ...
[18:04.0]  generate custom elements + source maps started ...
[18:04.0]  generate lazy + source maps started ...
[18:04.1]  copy finished (0 files) in 107 ms
[18:04.2]  generate custom elements + source maps finished in 213 ms
[18:04.3]  generate lazy + source maps finished in 299 ms
[18:04.3]  build finished in 1.55 s

❯ rm -r node_modules/ package-lock.json
❯ npm i
npm WARN deprecated [email protected]: < 22.5.0 is no longer supported

added 349 packages, and audited 350 packages in 2s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[18:22.1]  @stencil/core
[18:22.3]  v4.18.1 🏍
[18:22.8]  build, issue5780, prod mode, started ...
[18:22.9]  transpile started ...
[18:24.0]  transpile finished in 1.19 s
[18:24.0]  copy started ...
[18:24.1]  generate custom elements + source maps started ...
[18:24.1]  generate lazy + source maps started ...
[18:24.1]  copy finished (0 files) in 104 ms
[18:24.2]  generate custom elements + source maps finished in 159 ms
[18:24.4]  generate lazy + source maps finished in 287 ms
[18:24.4]  build finished in 1.53 s

Can you provide a step by step description on how to reproduce the problem please?

christian-bromann avatar May 20 '24 15:05 christian-bromann

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar May 20 '24 15:05 ionitron-bot[bot]

@gavmck thanks for raising the issue.

Unfortunately I was not able to verify that exploding build 😉 I created a new Stencil project, build it with v4.14.0 and then again with v4.18.1 and everything was fine:

❯ npm i
npm WARN deprecated [email protected]: < 22.5.0 is no longer supported

added 349 packages, and audited 350 packages in 6s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[18:02.0]  @stencil/core
[18:02.1]  v4.14.0 🚡
[18:02.8]  build, issue5780, prod mode, started ...
[18:02.8]  transpile started ...
[18:04.0]  transpile finished in 1.20 s
[18:04.0]  copy started ...
[18:04.0]  generate custom elements + source maps started ...
[18:04.0]  generate lazy + source maps started ...
[18:04.1]  copy finished (0 files) in 107 ms
[18:04.2]  generate custom elements + source maps finished in 213 ms
[18:04.3]  generate lazy + source maps finished in 299 ms
[18:04.3]  build finished in 1.55 s

❯ rm -r node_modules/ package-lock.json
❯ npm i
npm WARN deprecated [email protected]: < 22.5.0 is no longer supported

added 349 packages, and audited 350 packages in 2s

38 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
❯ npm run build

> [email protected] build
> stencil build

[18:22.1]  @stencil/core
[18:22.3]  v4.18.1 🏍
[18:22.8]  build, issue5780, prod mode, started ...
[18:22.9]  transpile started ...
[18:24.0]  transpile finished in 1.19 s
[18:24.0]  copy started ...
[18:24.1]  generate custom elements + source maps started ...
[18:24.1]  generate lazy + source maps started ...
[18:24.1]  copy finished (0 files) in 104 ms
[18:24.2]  generate custom elements + source maps finished in 159 ms
[18:24.4]  generate lazy + source maps finished in 287 ms
[18:24.4]  build finished in 1.53 s

Can you provide a step by step description on how to reproduce the problem please?

@christian-bromann Ah sorry, it's not the build that explodes, it's the install. The previous instructions said to do this.

import { applyPolyfills, defineCustomElements } from 'my-component-library';

applyPolyfills().then(() => {
  defineCustomElements();
});

Now the applyPolyfills function does not exist unless you build for es5 so previous working installs break.

gavmck avatar May 21 '24 07:05 gavmck

The type also seems to output that the function exists still https://github.com/ionic-team/stencil/blob/5a82d0152c92f4ad64c0a9dc92dfb5a564a0bdbf/src/compiler/output-targets/output-lazy-loader.ts#L84

gavmck avatar May 21 '24 07:05 gavmck

How do you set applyPolyfills ? Can you please provide a reproducible example? It is unknown to me what my-component-library exports here.

christian-bromann avatar May 22 '24 16:05 christian-bromann

I'll see if I can know one up. applyPolyfills came from the stencil loader

It looks like it was removed from the docs last year and I missed it.

https://github.com/ionic-team/stencil-site/commit/3a910c237e20136e46961cd988759a594d0f9627#diff-f1f96788acd155196970469f3c5031d518d3800fde982f92412858072a726bcfL518

gavmck avatar May 22 '24 16:05 gavmck

That is correct. This has been done due to the fact that Stencil stopped supporting IE, afaik. Do you think we can close this issue then?

christian-bromann avatar May 22 '24 18:05 christian-bromann

Do we still need to update the type?

gavmck avatar May 23 '24 05:05 gavmck

Yes, let me raise a PR for that.

christian-bromann avatar May 23 '24 15:05 christian-bromann

Actually we have this planned to remove for Stencil v5.

christian-bromann avatar May 23 '24 15:05 christian-bromann

We have a polyfill problem in our repos with v4.18.1. We have one repo for Stencil that generates the Web components, and another repo that consumes that repo to generate the React components. Any project that attempts to use the React components gets the following error: export 'applyPolyfills' (imported as 'applyPolyfills') was not found in '@*******/loader' (possible exports: defineCustomElements, setNonce)

Kwooda avatar May 28 '24 19:05 Kwooda

@Kwooda thanks for the feedback, is there a chance you can provide a minimal reproducible example?

christian-bromann avatar May 28 '24 19:05 christian-bromann

I don't know - last time I tried I got slapped by our security team, but I'll see if there's anything I can do.

Kwooda avatar May 28 '24 20:05 Kwooda

Ideally from a new Stencil project, e.g. that you can create via npm init stencil.

christian-bromann avatar May 28 '24 21:05 christian-bromann

If I keep the same structure described in Stencil documentation to generate wrappers of Vue Components and React Components, we have a problem with Stencil 4.18.x to render these components

You can check my real code here

And I have a workaround to work with Vue3 too

In both cases I receive an error because applyPolyfills doesn't exist anymore

image

Can you help us?

felipefialho avatar Jun 05 '24 18:06 felipefialho

If I keep the same structure described in Stencil documentation to generate wrappers of Vue Components and React Components, we have a problem with Stencil 4.18.x to render these components

You can check my real code here

And I have a workaround to work with Vue3 too

In both cases I receive an error because applyPolyfills doesn't exist anymore

image Can you help us?

@felipefialho The answer for us was just to remove all mention of applyPolyfills

gavmck avatar Jun 06 '24 09:06 gavmck

I'm a little bit confused why was this PR (#5725) part of an v4 minor/patch release, for me it looks like a breaking change and should be done in v5.

https://github.com/ionic-team/stencil/blob/47c8efc5c460a1d0931ab3398cc2ac0bb17008c0/src/compiler/output-targets/dist-lazy/generate-esm.ts#L61-L63

danielleroux avatar Jun 28 '24 06:06 danielleroux