Tree shaking is not working properly with react classes (stateful vs functional) components.
This repo https://github.com/mshaaban0/tree-shaker demonstrates the issue clearly for a better understanding.
Tree shaking should eliminate unused/not imported code from the built bundle.
Unused/not imported react classes gets included in the built bundle.
Playground repo is available here
Could you please try this with Parcel 2?
Hey @mischnic Just did, same results unfortunately.
As suspected, this is related to Babel transpiling the classes.
Parcel 1: modern vs transpiled
@mshaaban0 With Parcel 2, it does work with minification enabled?
@mischnic Nope, just tried it with minification. Same issue.
Could you please update your repo to include only Parcel 2?
I can't find the text StatefulModuleOne in the output.
@mischnic Done.
PR: https://github.com/parcel-bundler/parcel/issues/4046
Terser wasn't configured correctly for the commonjs output format.
@mischnic Thanks for looking into this ๐