feat(core): faster JS minimizer - siteConfig.future.experimental_faster.swcJsMinimizer (#10441)

This commit is contained in:
Sébastien Lorber 2024-08-23 18:44:42 +02:00 committed by GitHub
parent aa65f39d8c
commit bb90e35153
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 202 additions and 36 deletions

View file

@ -6,6 +6,7 @@
*/
import type {RuleSetRule} from 'webpack';
import type {JsMinifyOptions} from '@swc/core';
export function getSwcJsLoaderFactory({
isServer,
@ -33,3 +34,24 @@ export function getSwcJsLoaderFactory({
},
};
}
// Note: these options are similar to what we use in core
// They should rather be kept in sync for now to avoid any unexpected behavior
// The goal of faster minifier is not to fine-tune options but only to be faster
// See core minification.ts
export function getSwcJsMinifierOptions(): JsMinifyOptions {
return {
ecma: 2020,
compress: {
ecma: 5,
},
module: true,
mangle: true,
safari10: true,
format: {
ecma: 5,
comments: false,
ascii_only: true,
},
};
}