Open pastelsky opened 1 month ago
webpack/rspack generates runtime code for every small module. Maybe concatenateModules
could help.
This build runs in production mode β so I assumed module concatenation would be on.
π€ I manually set concatenateModules
to true on top of your config and it did work.
File Size Gzipped
rsbuild-dist/index.html 0.32 kB 0.22 kB
rsbuild-dist/static/js/index.3a9fa5b5.js 1.4 kB 0.74 kB
rsbuild-dist/static/js/712.32ef6620.js 26.4 kB 8.0 kB
Total size: 28.1 kB
Gzipped size: 8.9 kB
Interesting, I don't see such an option documented here β https://www.rspack.dev/config/optimization Where is this documented?
Also, would you know why this isn't enabled by default?
It's true that rspack document is not always up-to-date, which is a problem(I don't know how the team will improve this workflow in the future).
For now, we know rspack aims for alignment with webpack, so you may find some available configuration in webpack document such as https://webpack.js.org/configuration/optimization/#optimizationconcatenatemodules.
As for why it's not enabled by default in production mode, I guess this option was forgotten to be adjusted at the end of the experimental phase.
I'll make a simple pull request.
@CPunisher concatenateModules is not enabled in production because we're still testing it, we will enable it by default in production when we think it's production ready
@hardfist π That's what I'm going to ask. After I changed the default configuration, there are some test cases with strange errors.
System Info
Details
Consider a blank project that only has one dependency β
underscore
.Bundling the project using rspack or a fresh rsbuild project produces an output β
This is 42 KB minified.
However, an actual ESM minified build of rsbuild is only 25KB minified β https://unpkg.com/browse/underscore@1.13.6/underscore-esm-min.js
RSpack might be in-effecient at packing multiple small functions into a smaller space.
Reproduce link
https://github.com/pastelsky/rspack-repro-underscore
Reproduce Steps
yarn install
yarn build