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")) : "");
});
});
}

View File

@@ -0,0 +1,278 @@
"use strict";
// @ts-nocheck
var g = typeof globalThis !== 'undefined' ? globalThis : global;
var crypto = g.crypto || {};
if (typeof crypto.getRandomValues !== 'function') {
var nodeCrypto = require('crypto');
crypto.getRandomValues = function (typedArray) {
var bytes = nodeCrypto.randomBytes(typedArray.byteLength);
new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength).set(bytes);
return typedArray;
};
}
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
'use strict';
// Generate an internal UID to make the regexp pattern harder to guess.
var UID_LENGTH = 16;
var UID = generateUID();
var PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|A|U|I|B|L)-' + UID + '-(\\d+)__@"', 'g');
var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;
var IS_PURE_FUNCTION = /function.*?\(/;
var IS_ARROW_FUNCTION = /.*?=>.*?/;
var UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g;
// Regex to match </script> and variations (case-insensitive) for XSS protection
// Matches </script followed by optional whitespace/attributes and >
var SCRIPT_CLOSE_REGEXP = /<\/script[^>]*>/gi;
var RESERVED_SYMBOLS = ['*', 'async'];
// Mapping of unsafe HTML and invalid JavaScript line terminator chars to their
// Unicode char counterparts which are safe to use in JavaScript strings.
var ESCAPED_CHARS = {
'<': '\\u003C',
'>': '\\u003E',
'/': '\\u002F',
'\u2028': '\\u2028',
'\u2029': '\\u2029'
};
function escapeUnsafeChars(unsafeChar) {
return ESCAPED_CHARS[unsafeChar];
}
// Escape function body for XSS protection while preserving arrow function syntax
function escapeFunctionBody(str) {
// Escape </script> sequences and variations (case-insensitive) - the main XSS risk
// Matches </script followed by optional whitespace/attributes and >
// This must be done first before other replacements
str = str.replace(SCRIPT_CLOSE_REGEXP, function (match) {
// Escape all <, /, and > characters in the closing script tag
return match.replace(/</g, '\\u003C').replace(/\//g, '\\u002F').replace(/>/g, '\\u003E');
});
// Escape line terminators (these are always unsafe)
str = str.replace(/\u2028/g, '\\u2028');
str = str.replace(/\u2029/g, '\\u2029');
return str;
}
function generateUID() {
var bytes = crypto.getRandomValues(new Uint8Array(UID_LENGTH));
var result = '';
for (var i = 0; i < UID_LENGTH; ++i) {
result += bytes[i].toString(16);
}
return result;
}
function deleteFunctions(obj) {
var functionKeys = [];
for (var key in obj) {
if (typeof obj[key] === "function") {
functionKeys.push(key);
}
}
for (var i = 0; i < functionKeys.length; i++) {
delete obj[functionKeys[i]];
}
}
module.exports = function serialize(obj, options) {
options || (options = {});
// Backwards-compatibility for `space` as the second argument.
if (typeof options === 'number' || typeof options === 'string') {
options = {
space: options
};
}
var functions = [];
var regexps = [];
var dates = [];
var maps = [];
var sets = [];
var arrays = [];
var undefs = [];
var infinities = [];
var bigInts = [];
var urls = [];
// Returns placeholders for functions and regexps (identified by index)
// which are later replaced by their string representation.
function replacer(key, value) {
// For nested function
if (options.ignoreFunction) {
deleteFunctions(value);
}
if (!value && value !== undefined && value !== BigInt(0)) {
return value;
}
// If the value is an object w/ a toJSON method, toJSON is called before
// the replacer runs, so we use this[key] to get the non-toJSONed value.
var origValue = this[key];
var type = typeof origValue;
if (type === 'object') {
if (origValue instanceof RegExp) {
return '@__R-' + UID + '-' + (regexps.push(origValue) - 1) + '__@';
}
if (origValue instanceof Date) {
return '@__D-' + UID + '-' + (dates.push(origValue) - 1) + '__@';
}
if (origValue instanceof Map) {
return '@__M-' + UID + '-' + (maps.push(origValue) - 1) + '__@';
}
if (origValue instanceof Set) {
return '@__S-' + UID + '-' + (sets.push(origValue) - 1) + '__@';
}
if (origValue instanceof Array) {
var isSparse = origValue.filter(function () {
return true;
}).length !== origValue.length;
if (isSparse) {
return '@__A-' + UID + '-' + (arrays.push(origValue) - 1) + '__@';
}
}
if (origValue instanceof URL) {
return '@__L-' + UID + '-' + (urls.push(origValue) - 1) + '__@';
}
}
if (type === 'function') {
return '@__F-' + UID + '-' + (functions.push(origValue) - 1) + '__@';
}
if (type === 'undefined') {
return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
}
if (type === 'number' && !isNaN(origValue) && !isFinite(origValue)) {
return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
}
if (type === 'bigint') {
return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
}
return value;
}
function serializeFunc(fn, options) {
var serializedFn = fn.toString();
if (IS_NATIVE_CODE_REGEXP.test(serializedFn)) {
throw new TypeError('Serializing native function: ' + fn.name);
}
// Escape unsafe HTML characters in function body for XSS protection
// This must preserve arrow function syntax (=>) while escaping </script>
if (options && options.unsafe !== true) {
serializedFn = escapeFunctionBody(serializedFn);
}
// pure functions, example: {key: function() {}}
if (IS_PURE_FUNCTION.test(serializedFn)) {
return serializedFn;
}
// arrow functions, example: arg1 => arg1+5
if (IS_ARROW_FUNCTION.test(serializedFn)) {
return serializedFn;
}
var argsStartsAt = serializedFn.indexOf('(');
var def = serializedFn.substr(0, argsStartsAt).trim().split(' ').filter(function (val) {
return val.length > 0;
});
var nonReservedSymbols = def.filter(function (val) {
return RESERVED_SYMBOLS.indexOf(val) === -1;
});
// enhanced literal objects, example: {key() {}}
if (nonReservedSymbols.length > 0) {
return (def.indexOf('async') > -1 ? 'async ' : '') + 'function' + (def.join('').indexOf('*') > -1 ? '*' : '') + serializedFn.substr(argsStartsAt);
}
// arrow functions
return serializedFn;
}
// Check if the parameter is function
if (options.ignoreFunction && typeof obj === "function") {
obj = undefined;
}
// Protects against `JSON.stringify()` returning `undefined`, by serializing
// to the literal string: "undefined".
if (obj === undefined) {
return String(obj);
}
var str;
// Creates a JSON string representation of the value.
// NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args.
if (options.isJSON && !options.space) {
str = JSON.stringify(obj);
} else {
str = JSON.stringify(obj, options.isJSON ? null : replacer, options.space);
}
// Protects against `JSON.stringify()` returning `undefined`, by serializing
// to the literal string: "undefined".
if (typeof str !== 'string') {
return String(str);
}
// Replace unsafe HTML and invalid JavaScript line terminator chars with
// their safe Unicode char counterpart. This _must_ happen before the
// regexps and functions are serialized and added back to the string.
if (options.unsafe !== true) {
str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
}
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && arrays.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0 && urls.length === 0) {
return str;
}
// Replaces all occurrences of function, regexp, date, map and set placeholders in the
// JSON string with their string representations. If the original value can
// not be found, then `undefined` is used.
return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
// The placeholder may not be preceded by a backslash. This is to prevent
// replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
// invalid JS.
if (backSlash) {
return match;
}
if (type === 'D') {
// Validate ISO string format to prevent code injection via spoofed toISOString()
var isoStr = String(dates[valueIndex].toISOString());
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(isoStr)) {
throw new TypeError('Invalid Date ISO string');
}
return "new Date(\"" + isoStr + "\")";
}
if (type === 'R') {
// Sanitize flags to prevent code injection (only allow valid RegExp flag characters)
var flags = String(regexps[valueIndex].flags).replace(/[^gimsuydv]/g, '');
return "new RegExp(" + serialize(regexps[valueIndex].source) + ", \"" + flags + "\")";
}
if (type === 'M') {
return "new Map(" + serialize(Array.from(maps[valueIndex].entries()), options) + ")";
}
if (type === 'S') {
return "new Set(" + serialize(Array.from(sets[valueIndex].values()), options) + ")";
}
if (type === 'A') {
return "Array.prototype.slice.call(" + serialize(Object.assign({
length: arrays[valueIndex].length
}, arrays[valueIndex]), options) + ")";
}
if (type === 'U') {
return 'undefined';
}
if (type === 'I') {
return infinities[valueIndex];
}
if (type === 'B') {
return "BigInt(\"" + bigInts[valueIndex] + "\")";
}
if (type === 'L') {
return "new URL(" + serialize(urls[valueIndex].toString(), options) + ")";
}
var fn = functions[valueIndex];
return serializeFunc(fn, options);
});
};

View File

@@ -14,7 +14,7 @@
*/
/**
* @typedef {Array<string>} ExtractedComments
* @typedef {string[]} ExtractedComments
*/
const notSettled = Symbol("not-settled");
@@ -86,7 +86,7 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
};
/**
* @param {import("terser").MinifyOptions & { sourceMap: import("terser").SourceMapOptions | undefined } & ({ output: import("terser").FormatOptions & { beautify: boolean } } | { format: import("terser").FormatOptions & { beautify: boolean } })} terserOptions terser options
* @param {import("terser").MinifyOptions & { sourceMap: import("terser").SourceMapOptions | undefined } & ({ output: import("terser").FormatOptions & { beautify: boolean } } | { format: import("terser").FormatOptions & { beautify: boolean } })} terserOptions terser options
* @param {ExtractedComments} extractedComments extracted comments
* @returns {ExtractCommentsFunction} function to extract comments
*/
@@ -143,7 +143,7 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
}
regexStr = /** @type {string} */condition[key];
condition[key] = /** @type {ExtractCommentsFunction} */
(astNode, comment) => new RegExp( /** @type {string} */regexStr).test(comment.value);
(astNode, comment) => new RegExp(/** @type {string} */regexStr).test(comment.value);
break;
default:
regex = /** @type {RegExp} */condition[key];
@@ -155,7 +155,7 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
// Redefine the comments function to extract and preserve
// comments according to the two conditions
return (astNode, comment) => {
if ( /** @type {{ extract: ExtractCommentsFunction }} */
if (/** @type {{ extract: ExtractCommentsFunction }} */
condition.extract(astNode, comment)) {
const commentText = comment.type === "comment2" ? `/*${comment.value}*/` : `//${comment.value}`;
@@ -217,7 +217,7 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
} = require("terser"));
} catch (err) {
return {
errors: [( /** @type {Error} */err)]
errors: [(/** @type {Error} */err)]
};
}
@@ -254,8 +254,8 @@ async function terserMinify(input, sourceMap, minimizerOptions, extractComments)
[filename]: code
}, terserOptions);
return {
code: ( /** @type {string} * */result.code),
map: result.map ? ( /** @type {RawSourceMap} * */result.map) : undefined,
code: (/** @type {string} * */result.code),
map: result.map ? (/** @type {RawSourceMap} * */result.map) : undefined,
extractedComments
};
}
@@ -300,7 +300,7 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
};
/**
* @param {import("uglify-js").MinifyOptions & { sourceMap: boolean | import("uglify-js").SourceMapOptions | undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean }}} uglifyJsOptions uglify-js options
* @param {import("uglify-js").MinifyOptions & { sourceMap: boolean | import("uglify-js").SourceMapOptions | undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean } }} uglifyJsOptions uglify-js options
* @param {ExtractedComments} extractedComments extracted comments
* @returns {ExtractCommentsFunction} extract comments function
*/
@@ -350,7 +350,7 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
}
regexStr = /** @type {string} */condition[key];
condition[key] = /** @type {ExtractCommentsFunction} */
(astNode, comment) => new RegExp( /** @type {string} */regexStr).test(comment.value);
(astNode, comment) => new RegExp(/** @type {string} */regexStr).test(comment.value);
break;
default:
regex = /** @type {RegExp} */condition[key];
@@ -362,7 +362,7 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
// Redefine the comments function to extract and preserve
// comments according to the two conditions
return (astNode, comment) => {
if ( /** @type {{ extract: ExtractCommentsFunction }} */
if (/** @type {{ extract: ExtractCommentsFunction }} */
condition.extract(astNode, comment)) {
const commentText = comment.type === "comment2" ? `/*${comment.value}*/` : `//${comment.value}`;
@@ -377,7 +377,7 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
/**
* @param {PredefinedOptions<import("uglify-js").MinifyOptions> & import("uglify-js").MinifyOptions=} uglifyJsOptions uglify-js options
* @returns {import("uglify-js").MinifyOptions & { sourceMap: boolean | import("uglify-js").SourceMapOptions | undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean }}} uglify-js options
* @returns {import("uglify-js").MinifyOptions & { sourceMap: boolean | import("uglify-js").SourceMapOptions | undefined } & { output: import("uglify-js").OutputOptions & { beautify: boolean } }} uglify-js options
*/
const buildUglifyJsOptions = (uglifyJsOptions = {}) => {
if (typeof uglifyJsOptions.ecma !== "undefined") {
@@ -422,7 +422,7 @@ async function uglifyJsMinify(input, sourceMap, minimizerOptions, extractComment
} = require("uglify-js"));
} catch (err) {
return {
errors: [( /** @type {Error} */err)]
errors: [(/** @type {Error} */err)]
};
}
@@ -508,7 +508,7 @@ async function swcMinify(input, sourceMap, minimizerOptions) {
swc = require("@swc/core");
} catch (err) {
return {
errors: [( /** @type {Error} */err)]
errors: [(/** @type {Error} */err)]
};
}
@@ -596,7 +596,7 @@ async function esbuildMinify(input, sourceMap, minimizerOptions) {
esbuild = require("esbuild");
} catch (err) {
return {
errors: [( /** @type {Error} */err)]
errors: [(/** @type {Error} */err)]
};
}

View File

@@ -1,6 +1,6 @@
{
"name": "terser-webpack-plugin",
"version": "5.3.16",
"version": "5.3.17",
"description": "Terser plugin for webpack",
"keywords": [
"uglify",
@@ -37,11 +37,13 @@
"scripts": {
"clean": "del-cli dist types",
"prebuild": "npm run clean",
"build:serialize-javascript": "node ./scripts/copy-serialize-javascript.js",
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
"build": "npm-run-all -p \"build:**\"",
"commitlint": "commitlint --from=main",
"security": "npm audit --production",
"lint:serialize-javascript": "node ./scripts/copy-serialize-javascript.js --check",
"lint:prettier": "prettier --list-different .",
"lint:code": "eslint --cache .",
"lint:spelling": "cspell \"**/*.*\"",
@@ -62,7 +64,6 @@
"@jridgewell/trace-mapping": "^0.3.25",
"jest-worker": "^27.4.5",
"schema-utils": "^4.3.0",
"serialize-javascript": "^6.0.2",
"terser": "^5.31.1"
},
"devDependencies": {
@@ -71,9 +72,6 @@
"@babel/preset-env": "^7.24.7",
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@eslint/js": "^9.29.0",
"@eslint/markdown": "^7.1.0",
"@stylistic/eslint-plugin": "^5.2.2",
"@swc/core": "^1.3.102",
"@types/node": "^24.2.1",
"@types/serialize-javascript": "^5.0.2",
@@ -83,16 +81,9 @@
"cspell": "^6.31.2",
"del": "^6.0.0",
"del-cli": "^3.0.1",
"esbuild": "^0.25.0",
"esbuild": "^0.27.3",
"eslint": "^9.29.0",
"eslint-config-prettier": "^10.1.1",
"eslint-config-webpack": "^4.5.1",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^54.0.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-prettier": "^5.5.0",
"eslint-plugin-unicorn": "^60.0.0",
"file-loader": "^6.2.0",
"husky": "^7.0.2",
"jest": "^27.5.1",
@@ -101,9 +92,9 @@
"npm-run-all": "^4.1.5",
"prettier": "^3.6.0",
"prettier-2": "npm:prettier@^2",
"serialize-javascript": "^7.0.4",
"standard-version": "^9.3.1",
"typescript": "^5.9.2",
"typescript-eslint": "^8.39.1",
"uglify-js": "^3.19.3",
"webpack": "^5.101.0",
"webpack-cli": "^4.10.0",

View File

@@ -77,11 +77,13 @@ declare namespace TerserPlugin {
Configuration,
Asset,
AssetInfo,
TemplatePath,
JestWorker,
RawSourceMap,
TraceMap,
Rule,
Rules,
EXPECTED_ANY,
ExtractCommentsFunction,
ExtractCommentsCondition,
ExtractCommentsFilename,
@@ -116,6 +118,7 @@ type Compilation = import("webpack").Compilation;
type Configuration = import("webpack").Configuration;
type Asset = import("webpack").Asset;
type AssetInfo = import("webpack").AssetInfo;
type TemplatePath = import("webpack").TemplatePath;
type JestWorker = import("jest-worker").Worker;
type RawSourceMap = import("@jridgewell/trace-mapping").EncodedSourceMap & {
sources: string[];
@@ -125,8 +128,9 @@ type RawSourceMap = import("@jridgewell/trace-mapping").EncodedSourceMap & {
type TraceMap = import("@jridgewell/trace-mapping").TraceMap;
type Rule = RegExp | string;
type Rules = Rule[] | Rule;
type EXPECTED_ANY = any;
type ExtractCommentsFunction = (
astNode: any,
astNode: EXPECTED_ANY,
comment: {
value: string;
type: "comment1" | "comment2" | "comment3" | "comment4";
@@ -141,7 +145,7 @@ type ExtractCommentsCondition =
| "some"
| RegExp
| ExtractCommentsFunction;
type ExtractCommentsFilename = string | ((fileData: any) => string);
type ExtractCommentsFilename = TemplatePath;
type ExtractCommentsBanner =
| boolean
| string
@@ -191,21 +195,21 @@ type MinimizedResult = {
/**
* errors
*/
errors?: Array<Error | string> | undefined;
errors?: (Error | string)[] | undefined;
/**
* warnings
*/
warnings?: Array<Error | string> | undefined;
warnings?: (Error | string)[] | undefined;
/**
* extracted comments
*/
extractedComments?: Array<string> | undefined;
extractedComments?: string[] | undefined;
};
type Input = {
[file: string]: string;
};
type CustomOptions = {
[key: string]: any;
[key: string]: EXPECTED_ANY;
};
type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
type PredefinedOptions<T> = {

View File

@@ -0,0 +1,2 @@
declare function _exports(obj: any, options: any): any;
export = _exports;

View File

@@ -11,7 +11,7 @@ export type MinimizedResult = import("./index.js").MinimizedResult;
export type CustomOptions = import("./index.js").CustomOptions;
export type RawSourceMap = import("./index.js").RawSourceMap;
export type PredefinedOptions<T> = import("./index.js").PredefinedOptions<T>;
export type ExtractedComments = Array<string>;
export type ExtractedComments = string[];
/**
* @param {Input} input input
* @param {RawSourceMap=} sourceMap source map