Bug report
What is the current behavior?
Given that one uses package that has multiple ESM exports, and marked as side effect free, all sub-trees seems to be analyzed or even compiled, which causes great performance loss. Inclusion (or not inclusion) into final bundle works correctly.
If the current behavior is a bug, please provide the steps to reproduce.
I've created this setup to demonstrate https://github.com/archfz/webpack-treeshake-issue
What is the expected behavior?
I am not sure if this is a bug or this is intended to work like this. I would expect the subtree that is not imported to not be analyzed and/or compiled at all. Given the example repository I would expect the same webpack compile duration using either some-module or some-module-less. Instead there is a big performance difference.
Given this performance I do not see the use of tree-shaking versus used-exports optimization. Indeed with sideeffectless ESM it is quite easier and faster to determine when to not include unused exports, than with used-exports optimization, but the big gains is the latter where the whole sub-tree is completely skipped.
Other relevant information:
webpack version: 5.72.0
Node.js version: 16.x
Operating System: Ubuntu 22
Additional tools: N/A
Bug report
What is the current behavior?
Given that one uses package that has multiple ESM exports, and marked as side effect free, all sub-trees seems to be analyzed or even compiled, which causes great performance loss. Inclusion (or not inclusion) into final bundle works correctly.
If the current behavior is a bug, please provide the steps to reproduce.
I've created this setup to demonstrate https://github.com/archfz/webpack-treeshake-issue
What is the expected behavior?
I am not sure if this is a bug or this is intended to work like this. I would expect the subtree that is not imported to not be analyzed and/or compiled at all. Given the example repository I would expect the same webpack compile duration using either
some-moduleorsome-module-less. Instead there is a big performance difference.Given this performance I do not see the use of
tree-shakingversusused-exportsoptimization. Indeed with sideeffectless ESM it is quite easier and faster to determine when to not include unused exports, than withused-exportsoptimization, but the big gains is the latter where the whole sub-tree is completely skipped.Other relevant information:
webpack version: 5.72.0
Node.js version: 16.x
Operating System: Ubuntu 22
Additional tools: N/A