diff --git a/.gitignore b/.gitignore index 8b13ff22d140..82e5977f182b 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ yalc.lock ngrok.yml package-lock.json yarn.lock +stats.rspack.json .claude/settings.local.json .claude/launch.json .claude/plans diff --git a/package.json b/package.json index 03d614c43d81..80d2a1aed45b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "build": "NODE_OPTIONS='--max-old-space-size=4096' rspack --config ./rspack.config.ts", "build-js-loader": "node scripts/build-js-loader.ts", "build-js-po": "node build-utils/ts-extract-gettext.ts", - "build-profile": "rspack --profile --json > stats.json", + "build-profile": "RSPACK_STATS=1 NODE_ENV=production rspack --mode production --config ./rspack.config.ts --json=stats.rspack.json", "extract-form-fields": "node scripts/extractFormFields.ts", "gen:embed-widgets": "esbuild scripts/genEmbedWidgets.ts --bundle --platform=node --format=esm --packages=external --outfile=.artifacts/genEmbedWidgets.mjs && node .artifacts/genEmbedWidgets.mjs", "gen:platform-info": "node scripts/genPlatformProductInfo.ts", diff --git a/rspack.config.ts b/rspack.config.ts index 8a38a2937d4e..1c9fe7fd930c 100644 --- a/rspack.config.ts +++ b/rspack.config.ts @@ -990,4 +990,28 @@ if (env.WEBPACK_CACHE_PATH) { } const configs = [appConfig, workerConfig]; + +// Configure JSON stats explicitly; the CLI defaults to errors and warnings. +// Keep module detail for bundle analysis without embedding source text. +if (env.RSPACK_STATS) { + for (const config of configs) { + config.stats = { + all: false, + modules: true, + nestedModules: true, + source: false, + assets: true, + chunks: true, + chunkRelations: true, + chunkGroups: true, + entrypoints: true, + hash: true, + timings: true, + version: true, + errors: true, + warnings: true, + }; + } +} + export default configs;