[SEI-5656] tree-shaking not working properly
kev1n-peters opened this issue · comments
Hello, I installed the @sei-js/core@3.0.4
package in my React application. When I built an optimized production version, I noticed the bundle size grow by about 4MB even though I only imported getQueryClient
. So I ran webpack-bundle-analyzer on the bundle and noticed that @sei-js/core
and @sei-js/proto
are both built with "module": "commonjs"
in the tsconfig.json
(implicit in the proto packge). Webpack recommends building with ES module support so tree-shaking can work properly (see: https://webpack.js.org/guides/tree-shaking/#conclusion). Would it be possible to build the packages with both commonjs
and es6
module support? This way tree-shaking in Webpack would work properly and reduce integrators' bundle sizes.
We are looking into this and will get back to you soon. Thank you for bringing this to our attention.
@kev1n-peters we have addressed this issue in @sei-js release 3.1.0 be including both cjs and esm builds of each library, we have also defined the exports for these builds and allowed bundlers to tree shake by declaring the packages side effect free. Please let us know if you have any further issues. Thank you for bringing this up.
Wow, that was fast. Thank you!