(Partially) Broken tree shaking on v3.0.0-rc14
See original GitHub issueDo you want to request a feature or report a bug?
A bug.
What is the current behaviour?
I’m currently using preact-feather
as my icon library (and it is great) but noticed on an upgrade to v3.0.0-rc14 that the icons were no longer tree shaked. If you import one, you import them all. This increases the bundle size dramatically.
I don’t think this is preact-feather
’s fault, as tree shaking did work before.
If the current behaviour is a bug, please provide the steps to reproduce.
I set up a quick example repository here. It is set to use v3.0.0-rc14 by default. Install, run yarn build:analyze
and you’ll see that all icons are included. Downgrade to v3.0.0-rc10, run yarn build:analyze
, and you’ll see only one, Mail, is included.
What is the expected behaviour?
Unused icons should not be added to the build.
Please mention other relevant information.
Environment Info:
System:
OS: Linux 5.6 Manjaro Linux
CPU: (4) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 14.2.0 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.14.5 - /usr/bin/npm
Browsers:
Firefox: 76.0.1
npmPackages:
preact: ^10.3.1 => 10.4.4
preact-cli: 3.0.0-rc.14 => 3.0.0-rc.14
preact-render-to-string: ^5.1.4 => 5.1.9
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
The issue is located here you are using CJS, due to the addition of custom babelrc files for buliding this is now transpiling your code to CJS making it effectively impossible to tree shake.
To enable tree-shaking this should have
modules: false
More documentation on custom babel configs
Yeah, seems great. Thanks for your help. Appreciate it.