Framework updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2026-03-04 23:20:19 +00:00
parent a89daf3d43
commit 3ed8517b2a
891 changed files with 11126 additions and 9600 deletions

View File

@@ -24,6 +24,7 @@ const {
/** @typedef {import("webpack").Configuration} Configuration */
/** @typedef {import("webpack").Asset} Asset */
/** @typedef {import("webpack").AssetInfo} AssetInfo */
/** @typedef {import("webpack").TemplatePath} TemplatePath */
/** @typedef {import("jest-worker").Worker} JestWorker */
/** @typedef {import("@jridgewell/trace-mapping").EncodedSourceMap & { sources: string[], sourcesContent?: string[], file: string }} RawSourceMap */
/** @typedef {import("@jridgewell/trace-mapping").TraceMap} TraceMap */
@@ -31,21 +32,22 @@ const {
/** @typedef {RegExp | string} Rule */
/** @typedef {Rule[] | Rule} Rules */
// eslint-disable-next-line jsdoc/no-restricted-syntax
// eslint-disable-next-line jsdoc/reject-any-type
/** @typedef {any} EXPECTED_ANY */
/**
* @callback ExtractCommentsFunction
* @param {any} astNode ast Node
* @param {{ value: string, type: 'comment1' | 'comment2' | 'comment3' | 'comment4', pos: number, line: number, col: number }} comment comment node
* @param {EXPECTED_ANY} astNode ast Node
* @param {{ value: string, type: "comment1" | "comment2" | "comment3" | "comment4", pos: number, line: number, col: number }} comment comment node
* @returns {boolean} true when need to extract comment, otherwise false
*/
/**
* @typedef {boolean | 'all' | 'some' | RegExp | ExtractCommentsFunction} ExtractCommentsCondition
* @typedef {boolean | "all" | "some" | RegExp | ExtractCommentsFunction} ExtractCommentsCondition
*/
// eslint-disable-next-line jsdoc/no-restricted-syntax
/**
* @typedef {string | ((fileData: any) => string)} ExtractCommentsFilename
* @typedef {TemplatePath} ExtractCommentsFilename
*/
/**
@@ -75,18 +77,17 @@ const {
* @typedef {object} MinimizedResult
* @property {string=} code code
* @property {RawSourceMap=} map source map
* @property {Array<Error | string>=} errors errors
* @property {Array<Error | string>=} warnings warnings
* @property {Array<string>=} extractedComments extracted comments
* @property {(Error | string)[]=} errors errors
* @property {(Error | string)[]=} warnings warnings
* @property {string[]=} extractedComments extracted comments
*/
/**
* @typedef {{ [file: string]: string }} Input
*/
// eslint-disable-next-line jsdoc/no-restricted-syntax
/**
* @typedef {{ [key: string]: any }} CustomOptions
* @typedef {{ [key: string]: EXPECTED_ANY }} CustomOptions
*/
/**
@@ -166,7 +167,7 @@ const {
*/
const getTraceMapping = memoize(() => require("@jridgewell/trace-mapping"));
const getSerializeJavascript = memoize(() => require("serialize-javascript"));
const getSerializeJavascript = memoize(() => require("./serialize-javascript"));
/**
* @template [T=import("terser").MinifyOptions]
@@ -176,15 +177,15 @@ class TerserPlugin {
* @param {BasePluginOptions & DefinedDefaultMinimizerAndOptions<T>=} options options
*/
constructor(options) {
validate( /** @type {Schema} */schema, options || {}, {
validate(/** @type {Schema} */schema, options || {}, {
name: "Terser Plugin",
baseDataPath: "options"
});
// TODO make `minimizer` option instead `minify` and `terserOptions` in the next major release, also rename `terserMinify` to `terserMinimize`
const {
minify = ( /** @type {MinimizerImplementation<T>} */terserMinify),
terserOptions = ( /** @type {MinimizerOptions<T>} */{}),
minify = (/** @type {MinimizerImplementation<T>} */terserMinify),
terserOptions = (/** @type {MinimizerOptions<T>} */{}),
test = /\.[cm]?js(\?.*)?$/i,
extractComments = true,
parallel = true,
@@ -256,7 +257,7 @@ class TerserPlugin {
builtError.file = file;
return builtError;
}
if ( /** @type {ErrorObject} */error.line) {
if (/** @type {ErrorObject} */error.line) {
const {
line,
column
@@ -395,7 +396,7 @@ class TerserPlugin {
RawSource
} = compiler.webpack.sources;
/** @typedef {{ extractedCommentsSource : import("webpack").sources.RawSource, commentsFilename: string }} ExtractedCommentsInfo */
/** @typedef {{ extractedCommentsSource: import("webpack").sources.RawSource, commentsFilename: string }} ExtractedCommentsInfo */
/** @type {Map<string, ExtractedCommentsInfo>} */
const allExtractedComments = new Map();
const scheduledTasks = [];
@@ -464,8 +465,8 @@ class TerserPlugin {
output = await (getWorker ? getWorker().transform(getSerializeJavascript()(options)) : minify(options));
} catch (error) {
const hasSourceMap = inputSourceMap && TerserPlugin.isSourceMap(inputSourceMap);
compilation.errors.push(TerserPlugin.buildError( /** @type {Error | ErrorObject | string} */
error, name, hasSourceMap ? new (getTraceMapping().TraceMap)( /** @type {RawSourceMap} */
compilation.errors.push(TerserPlugin.buildError(/** @type {Error | ErrorObject | string} */
error, name, hasSourceMap ? new (getTraceMapping().TraceMap)(/** @type {RawSourceMap} */
inputSourceMap) : undefined, hasSourceMap ? compilation.requestShortener : undefined));
return;
}
@@ -487,14 +488,14 @@ class TerserPlugin {
* @param {Error | string} item an error
* @returns {Error} built error with extra info
*/
item => TerserPlugin.buildError(item, name, hasSourceMap ? new (getTraceMapping().TraceMap)( /** @type {RawSourceMap} */
item => TerserPlugin.buildError(item, name, hasSourceMap ? new (getTraceMapping().TraceMap)(/** @type {RawSourceMap} */
inputSourceMap) : undefined, hasSourceMap ? compilation.requestShortener : undefined));
}
// Custom functions can return `undefined` or `null`
if (typeof output.code !== "undefined" && output.code !== null) {
let shebang;
if ( /** @type {ExtractCommentsObject} */
if (/** @type {ExtractCommentsObject} */
this.options.extractComments.banner !== false && output.extractedComments && output.extractedComments.length > 0 && output.code.startsWith("#!")) {
const firstNewlinePosition = output.code.indexOf("\n");
shebang = output.code.slice(0, Math.max(0, firstNewlinePosition));
@@ -527,7 +528,7 @@ class TerserPlugin {
let banner;
// Add a banner to the original file
if ( /** @type {ExtractCommentsObject} */
if (/** @type {ExtractCommentsObject} */
this.options.extractComments.banner !== false) {
banner = /** @type {ExtractCommentsObject} */
this.options.extractComments.banner || `For license information please see ${path.relative(path.dirname(name), output.commentsFilename).replace(/\\/g, "/")}`;
@@ -589,7 +590,7 @@ class TerserPlugin {
compilation.updateAsset(name, source, newInfo);
});
}
const limit = getWorker && numberOfAssets > 0 ? ( /** @type {number} */numberOfWorkers) : scheduledTasks.length;
const limit = getWorker && numberOfAssets > 0 ? (/** @type {number} */numberOfWorkers) : scheduledTasks.length;
await throttleAll(limit, scheduledTasks);
if (initializedWorker) {
await initializedWorker.end();
@@ -694,7 +695,7 @@ class TerserPlugin {
stats.hooks.print.for("asset.info.minimized").tap("terser-webpack-plugin", (minimized, {
green,
formatFlag
}) => minimized ? /** @type {(text: string) => string} */green( /** @type {(flag: string) => string} */formatFlag("minimized")) : "");
}) => minimized ? /** @type {(text: string) => string} */green(/** @type {(flag: string) => string} */formatFlag("minimized")) : "");
});
});
}