Output bundle stats in rspack

Rspack provides a built-in method to generate the bundle stats JSON file after the bundle compilation is complete.

Configure

The bundle stats JSON data and structure are controlled by the Rspack config stats options. RelativeCI agent extracts data from assets, chunks, and modules entries, and the corresponding stats options are required:

rspack.config.js
module.exports = {
// ... project rspack config
stats: {
assets: true,
chunks: true,
modules: true
}
};

For advanced transformations of the bundle stats data, you can check webpack-stats-plugin transform option.

Validation errors

RelativeCI agent validates the bundles stats JSON structure before extracting the required data. However, because the rspack stats options are global, the values can be changed before/during the compilation by another plugin or a framework base config, and the result can fail the structure validation.

If you encounter agent validation errors, please consider using the webpack-stats-plugin method to fully control the webpack stats JSON structure.

Output file size

The size of the webpack stats JSON file depends on the size of the project and the stats configuration. @relative-ci/agent filters the file and sends only the required data. For example, the size of the filtered webpack stats for an application with 100 assets and 1500 modules is approximately 250KiB.

To optimize the bundle stats JSON file size, please consider using the webpack-stats-plugin method to fully control the webpack stats JSON structure and output.

Output bundle stats JSON file

npx rspack --mode production --json bundle-stats.json
[rspack-cli] stats are successfully stored as json to bundle-stats.json


To avoid issues with other tools that check if the repository has uncommitted changes or if you are publishing your project as an npm package, consider adding the generated webpack stats file to .gitignore/.npmignore.

.gitignore
webpack-stats.json
.npmignore
webpack-stats.json



Need help?Contact us via email, Twitter, or GitHub!