You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
5.2.0-dev.2 imports unused modules in JS output #3839
Since trying out 5.2.0-dev.2, I've noticed quite a few unused imports in the compiled files. In particular, this seems to happen with modules that alias others as submodules. For front-end assets, this has the potential to add bloat to the bundled JS, though bundlers that support tree-shaking will probably eliminate the issue.
This doesn't only happen with third-party modules. In our larger (private, unfortunately) app, I was seeing the same thing with imports for our own internal modules.
I am not sure what's the right solution.
Recently we made a fix that will track effectful module alias, module A = B if B is not pure, it will still be linked in
I think that's fine. I'll keep an eye out for modules with side effects that don't seem like they should need to be side-effectful, and any amount of JS tree-shaking should take care of the rest.
Recently we made a fix that will track effectful module alias, module A = B if B is not pure, it will still be linked in
I looked through the changelog and I didn't see a mention of this. Do you have an issue or pull request I could look at for more detail? Is there any way this behavior could be made opt-in (or opt-out)?
I understand that it may be correct to import unused modules that have effects, but it seems like the use-case for that would be quite rare in an fp language, and this is having a fairly substantial impact on our JS bundle size.
Activity
mlms13 commentedon Sep 21, 2019
I pushed a small demo repository, in case that helps: https://github.com/mlms13/bsb-issue-3839
replace 100% dangerous raw with less danger raw
bobzhang commentedon Sep 22, 2019
I am not sure what's the right solution.
Recently we made a fix that will track effectful module alias,
module A = Bif B is not pure, it will still be linked inreplace 100% dangerous raw with less danger raw
bobzhang commentedon Sep 23, 2019
I am going to close this issue, let me know if you have better ideas.
mlms13 commentedon Sep 23, 2019
I think that's fine. I'll keep an eye out for modules with side effects that don't seem like they should need to be side-effectful, and any amount of JS tree-shaking should take care of the rest.
mlms13 commentedon Sep 26, 2019
I looked through the changelog and I didn't see a mention of this. Do you have an issue or pull request I could look at for more detail? Is there any way this behavior could be made opt-in (or opt-out)?
I understand that it may be correct to import unused modules that have effects, but it seems like the use-case for that would be quite rare in an fp language, and this is having a fairly substantial impact on our JS bundle size.