stencil
stencil copied to clipboard
bug: rollup build cannot tree-shake properly when using dist-custom-elements + defineCustomElement + setAssetPath
Prerequisites
- [X] I have read the Contributing Guidelines.
- [X] I agree to follow the Code of Conduct.
- [X] I have searched for existing issues that already report this problem, without success.
Stencil Version
2.17.1
Current Behavior
A rollup build of an app that uses setAssetPath and imports a subset of components (built w/ Stencil 2.17.1 + defineCustomElement: true), will not tree-shake properly and include code for all components.
Expected Behavior
The main bundle should only have code relevant to the imported component.
Steps to Reproduce
See README from repro case repo.
Code Reproduction URL
https://github.com/jcfranco/stencil-use-case-where-build-is-not-tree-shaken
Additional Information
This started after the single file export of all components got introduced by Stencil v2.17.0.
A couple of suggestions to address this:
- Add an option to
dist-custom-elementsto enable/disable exporting all components fromindex.js - Provide another way of importing
setAssetPath
Hi @jcfranco, thanks for filing this issue! I'm going to mark this for further discussion and refinement so we can figure out what to do exactly.