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:
parent
9400f09603
commit
efc9c8d12a
@ -147,42 +147,44 @@ function applyNxIndependentConfig(
|
|||||||
...(config.ignoreWarnings ?? []),
|
...(config.ignoreWarnings ?? []),
|
||||||
];
|
];
|
||||||
|
|
||||||
config.optimization = !isProd
|
config.optimization = {
|
||||||
? undefined
|
...(config.optimization ?? {}),
|
||||||
: {
|
...(isProd
|
||||||
...(config.optimization ?? {}),
|
? {
|
||||||
sideEffects: true,
|
sideEffects: true,
|
||||||
minimize:
|
minimize:
|
||||||
typeof options.optimization === 'object'
|
typeof options.optimization === 'object'
|
||||||
? !!options.optimization.scripts
|
? !!options.optimization.scripts
|
||||||
: !!options.optimization,
|
: !!options.optimization,
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new SwcJsMinimizerRspackPlugin({
|
new SwcJsMinimizerRspackPlugin({
|
||||||
extractComments: false,
|
extractComments: false,
|
||||||
minimizerOptions: {
|
minimizerOptions: {
|
||||||
// this needs to be false to allow toplevel variables to be used in the global scope
|
// this needs to be false to allow toplevel variables to be used in the global scope
|
||||||
// important especially for module-federation which operates as such
|
// important especially for module-federation which operates as such
|
||||||
module: false,
|
module: false,
|
||||||
mangle: {
|
mangle: {
|
||||||
keep_classnames: true,
|
keep_classnames: true,
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
ecma: getTerserEcmaVersion(
|
||||||
|
path.join(options.root, options.projectRoot)
|
||||||
|
),
|
||||||
|
ascii_only: true,
|
||||||
|
comments: false,
|
||||||
|
webkit: true,
|
||||||
|
safari10: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
format: {
|
}),
|
||||||
ecma: getTerserEcmaVersion(
|
],
|
||||||
path.join(options.root, options.projectRoot)
|
concatenateModules: true,
|
||||||
),
|
runtimeChunk: isDevServer
|
||||||
ascii_only: true,
|
? config.optimization?.runtimeChunk ?? undefined
|
||||||
comments: false,
|
: false,
|
||||||
webkit: true,
|
}
|
||||||
safari10: true,
|
: {}),
|
||||||
},
|
};
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
concatenateModules: true,
|
|
||||||
runtimeChunk: isDevServer
|
|
||||||
? config.optimization?.runtimeChunk ?? undefined
|
|
||||||
: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
config.stats = {
|
config.stats = {
|
||||||
hash: true,
|
hash: true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user