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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tree Shaking Seems to be not Working #517
Comments
Hey @dazlious 馃憢, |
Hello @dazlious, I think it is not related to Loadable Components but I think it is related to webpack and the way dynamic imports work. |
Hello @gregberge and thank you for your quick response. You're indeed right, thank you. |
Because the "module" is a singleton. If it is used in two places - it would be bundled in the "maximum" required form. |
馃悰 Bug Report
When using loadable components route-based code-splitting seems to be working fine, but Webpack's tree shaking functionality seems to be broken. A named export should not force a bundle to have all the exported code in it.
In this case we have an component (
./lib/index.jsx
) that has two sub components called module1 (./lib/module1/module1.jsx
) and module2 (./lib/module1/module2.jsx
). Module1 exports a constant calledFOO_BAR
that is then imported by Module2 as a named import.When looking at the build output, you'll find Module2 containing Module1 completely and not only the string that is needed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The Output of Module2 should not include the complete Module1-file, but instead the Variable named
FOO_BAR
.Link to repl or repo (highly encouraged)
https://github.com/dazlious/treeshaking-dynamic-imports
The text was updated successfully, but these errors were encountered: