fix(rspack): fix issue with optimization options in rspack config (#31337)

## Current Behavior
rspack.config.ts options related to optimizations are removed if the
mode is not "production". This makes the compile fail for all
non-production builds.

## Expected Behavior
If mode isn't set to "production" configuration related to optimization
should be passed through.

## Related Issue(s)
Fixes #31268 #30292
This commit is contained in:
Johann Wagner 2025-05-30 19:41:13 +02:00 committed by GitHub
parent 9400f09603
commit efc9c8d12a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -147,10 +147,10 @@ function applyNxIndependentConfig(
...(config.ignoreWarnings ?? []), ...(config.ignoreWarnings ?? []),
]; ];
config.optimization = !isProd config.optimization = {
? undefined
: {
...(config.optimization ?? {}), ...(config.optimization ?? {}),
...(isProd
? {
sideEffects: true, sideEffects: true,
minimize: minimize:
typeof options.optimization === 'object' typeof options.optimization === 'object'
@ -182,6 +182,8 @@ function applyNxIndependentConfig(
runtimeChunk: isDevServer runtimeChunk: isDevServer
? config.optimization?.runtimeChunk ?? undefined ? config.optimization?.runtimeChunk ?? undefined
: false, : false,
}
: {}),
}; };
config.stats = { config.stats = {