stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: rollup build cannot tree-shake properly when using dist-custom-elements + defineCustomElement + setAssetPath

Open jcfranco opened this issue 3 years ago • 1 comments

Prerequisites

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:

  1. Add an option to dist-custom-elements to enable/disable exporting all components from index.js
  2. Provide another way of importing setAssetPath

jcfranco avatar Jul 13 '22 20:07 jcfranco

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.

alicewriteswrongs avatar Jul 15 '22 14:07 alicewriteswrongs