Anybody else is trying t…
Anybody else is trying to do something like this? https://stackoverflow.com/questions/52150668/tree-shaking-nested-modules-with-webpack-4 Stack Overflow: Tree-shaking nested modules with webpack 4
Responses:
Haven’t tried with rollup, but got it working with Webpack. Created a module rule with sideEffects: false
in webpack config. Tree shaking confirmed with next.js, and a bespoke ssr React app. If we end up building one of our libraries we will want it working with rollup. It would be great if the default config was optimised for it - it seems it might not be?
It is not indeed by default, I couldn’t make it work :confused:
It might be worth extracting the babel, rollup and tsconfig into a separate experiment, see how it differs from a known working treeshaking config.
is this it? https://github.com/nrwl/nx/blob/master/packages/react/plugins/bundle-rollup.ts or is there more somewhere
Even something simple like a rogue commonjs module format setting has thrown it for me in the past (but with tsconfig, babel, webpack)
It is, but I think the problem here is more on webpack side, in my case my rollup bundles are marked (comments that are used by Terser) correctly, but for some reason webpack can’t handle it
I found this
https://stackoverflow.com/questions/52150668/tree-shaking-nested-modules-with-webpack-4
I didn’t pursue more that solution