Anybody else is trying t…

less than 1 minute read

Anybody else is trying to do something like this? Stack Overflow: Tree-shaking nested modules with webpack 4


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? 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

I didn’t pursue more that solution