-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: All stencil components are imported in Angular even if only one is called #5952
Comments
There is something which disturb me a lot. But, in the angular documentation it says : So, in one side it says, "keep customElementsExportBehavior on default to have one component per file" and on the other side it says "change customElementsExportBehavior to 'single-export-module' if you need standalone components" But single-export-module' regroups all the components into one index.js file. I'm lost |
Hello, I encounter exactly the same problem. However in our case, we use more than 50 components and the JS coming from the stencil components is more than 10MB in our angular app. We are in a situation where putting an app into production is no longer possible for our organization due to the size of the stencil javascript. I hope the stencil team can help us to use/call real standalone components. |
We are facing the same issue. When importing a component from stencil.js library to an angular app, all exported components get loaded and registered although only one was imported. Is there a workaround or a different configuration that will fix this. Our stencil.config has:
|
Same issue here, at the beginning we thought it was an issue with Angular 18 but we did some tests on Angular 17 and 16.2 and this is the same. Are there any solutions ? |
Hey you all 👋 we currently have a lot of competing priorities and can't give every issue the attention it deserves. We recommend at this point to help the project by contributing a patch that may help to resolve the issue. We are happy to answer any questions that may arrise. |
@Loic57 - Could it be the issue that is described here for React-output target? It says; "When you look at the components generated by stencils in typescript, they are all prepended by the comment “/@PURE/”. As we saw in the previous article, this comment serves as an indicator to the bundler, signaling that these components are pure functions and can be safely removed if they are not directly invoked by the application." The solution was to add the following to the typescript config:
We are having the same issue that you describe, but we export our component-library as an Angular Module. So teams that consumes it import the entire module. When we went from Angular 16 to 17 and from Stencil 3 to 4 (which unfortunately was the same PR) we got this problem with thee-shaking. If a team only use a button, they don't get just the button, they get everything. We are investigating this now, but takes a while to see what's what. :) |
Hello @andberg The article that you sent is comforting, we are not the only ones to struggle with this. I tried to use the scam method but it doesn't work either, I have an error message from my generated components.ts file in I have no idea how to fix this issue or the one with standalone but I'm relived to see I'm not the only one with this issue. |
Can we expect a fix for that in the future? |
Prerequisites
Stencil Version
4.20
Current Behavior
I followed this documentationt to build a monorepo with stencil and angular : https://stenciljs.com/docs/angular
Nothing less, nothing more.
When running my angular app I can see in the network tab in my console that my two stencil components are loaded whereas I only need one.
In my app.component.ts (angular 18.2 in standalone mode) I call only "my-component" but my two components are called in the console.
Expected Behavior
I would like to load only the right component, not everything at once.
System Info
Steps to Reproduce
git clone https://github.com/Loic57/stencil-angular-18
npm i (be sure to have lerna installed)
go to packages/stencil-library and run : npm run build
go to packages/angular-workspace and run : npx -p @angular/cli ng build component-library
go to packages/angular-workspace/projects/my-app and run : npm run start
The browser should open on localhost:4200 and you should see "Hell, i'm a test" which is shipped by default with stencil.
But if you inspect the network tab in the console you should see another component name created by myself but which is not called in app.component.ts
Code Reproduction URL
https://github.com/Loic57/stencil-angular-18
Additional Information
No response
The text was updated successfully, but these errors were encountered: