Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
3
node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js
generated
vendored
3
node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js
generated
vendored
@@ -30,6 +30,7 @@ class AggressiveMergingPlugin {
|
||||
"Argument should be an options object. To use defaults, pass in nothing.\nFor more info on options, see https://webpack.js.org/plugins/"
|
||||
);
|
||||
}
|
||||
/** @type {AggressiveMergingPluginOptions} */
|
||||
this.options = options || {};
|
||||
}
|
||||
|
||||
@@ -50,7 +51,7 @@ class AggressiveMergingPlugin {
|
||||
},
|
||||
(chunks) => {
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
/** @type {{a: Chunk, b: Chunk, improvement: number}[]} */
|
||||
/** @type {{ a: Chunk, b: Chunk, improvement: number }[]} */
|
||||
const combinations = [];
|
||||
for (const a of chunks) {
|
||||
if (a.canBeInitial()) continue;
|
||||
|
||||
21
node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
generated
vendored
21
node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
generated
vendored
@@ -50,7 +50,7 @@ const moveModuleBetween = (chunkGraph, oldChunk, newChunk) => (module) => {
|
||||
const isNotAEntryModule = (chunkGraph, chunk) => (module) =>
|
||||
!chunkGraph.isEntryModuleInChunk(module, chunk);
|
||||
|
||||
/** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: Module[], size: number }} SplitData */
|
||||
/** @typedef {{ id?: NonNullable<Chunk["id"]>, hash?: NonNullable<Chunk["hash"]>, modules: string[], size: number }} SplitData */
|
||||
|
||||
/** @type {WeakSet<Chunk>} */
|
||||
const recordedChunks = new WeakSet();
|
||||
@@ -64,16 +64,21 @@ class AggressiveSplittingPlugin {
|
||||
constructor(options = {}) {
|
||||
validate(options);
|
||||
|
||||
/** @type {AggressiveSplittingPluginOptions} */
|
||||
this.options = options;
|
||||
|
||||
if (typeof this.options.minSize !== "number") {
|
||||
this.options.minSize = 30 * 1024;
|
||||
}
|
||||
|
||||
if (typeof this.options.maxSize !== "number") {
|
||||
this.options.maxSize = 50 * 1024;
|
||||
}
|
||||
|
||||
if (typeof this.options.chunkOverhead !== "number") {
|
||||
this.options.chunkOverhead = 0;
|
||||
}
|
||||
|
||||
if (typeof this.options.entryChunkMultiplicator !== "number") {
|
||||
this.options.entryChunkMultiplicator = 1;
|
||||
}
|
||||
@@ -114,7 +119,9 @@ class AggressiveSplittingPlugin {
|
||||
(chunks) => {
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
// Precompute stuff
|
||||
/** @type {Map<string, Module>} */
|
||||
const nameToModuleMap = new Map();
|
||||
/** @type {Map<Module, string>} */
|
||||
const moduleToNameMap = new Map();
|
||||
const makePathsRelative =
|
||||
identifierUtils.makePathsRelative.bindContextCache(
|
||||
@@ -128,10 +135,10 @@ class AggressiveSplittingPlugin {
|
||||
}
|
||||
|
||||
// Check used chunk ids
|
||||
/** @typedef {Set<ChunkId>} */
|
||||
/** @type {Set<ChunkId>} */
|
||||
const usedIds = new Set();
|
||||
for (const chunk of chunks) {
|
||||
usedIds.add(chunk.id);
|
||||
usedIds.add(/** @type {ChunkId} */ (chunk.id));
|
||||
}
|
||||
|
||||
const recordedSplits =
|
||||
@@ -154,8 +161,8 @@ class AggressiveSplittingPlugin {
|
||||
}
|
||||
|
||||
// Get module objects from names
|
||||
const selectedModules = splitData.modules.map((name) =>
|
||||
nameToModuleMap.get(name)
|
||||
const selectedModules = splitData.modules.map(
|
||||
(name) => /** @type {Module} */ (nameToModuleMap.get(name))
|
||||
);
|
||||
|
||||
// Does the modules exist at all?
|
||||
@@ -240,6 +247,7 @@ class AggressiveSplittingPlugin {
|
||||
const modules = chunkGraph
|
||||
.getOrderedChunkModules(chunk, compareModulesByIdentifier)
|
||||
.filter(isNotAEntryModule(chunkGraph, chunk));
|
||||
/** @type {Module[]} */
|
||||
const selectedModules = [];
|
||||
let selectedModulesSize = 0;
|
||||
for (let k = 0; k < modules.length; k++) {
|
||||
@@ -255,7 +263,7 @@ class AggressiveSplittingPlugin {
|
||||
/** @type {SplitData} */
|
||||
const splitData = {
|
||||
modules: selectedModules
|
||||
.map((m) => moduleToNameMap.get(m))
|
||||
.map((m) => /** @type {string} */ (moduleToNameMap.get(m)))
|
||||
.sort(),
|
||||
size: selectedModulesSize
|
||||
};
|
||||
@@ -271,6 +279,7 @@ class AggressiveSplittingPlugin {
|
||||
);
|
||||
compilation.hooks.recordHash.tap(PLUGIN_NAME, (records) => {
|
||||
// 4. save made splittings to records
|
||||
/** @type {Set<SplitData>} */
|
||||
const allSplits = new Set();
|
||||
/** @type {Set<SplitData>} */
|
||||
const invalidSplits = new Set();
|
||||
|
||||
52
node_modules/webpack/lib/optimize/ConcatenatedModule.js
generated
vendored
52
node_modules/webpack/lib/optimize/ConcatenatedModule.js
generated
vendored
@@ -72,6 +72,7 @@ const {
|
||||
/** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
||||
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
||||
/** @typedef {import("../Module").LibIdent} LibIdent */
|
||||
@@ -90,7 +91,8 @@ const {
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
||||
/** @typedef {import("../util/Hash").HashFunction} HashFunction */
|
||||
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
||||
/** @typedef {import("../util/concatenate").ScopeInfo} ScopeInfo */
|
||||
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
||||
@@ -227,6 +229,7 @@ const compareNumbers = (a, b) => {
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const bySourceOrder = createComparator("sourceOrder", compareNumbers);
|
||||
const byRangeStart = createComparator("rangeStart", compareNumbers);
|
||||
|
||||
@@ -653,7 +656,9 @@ const getFinalName = (
|
||||
);
|
||||
{
|
||||
const { ids, comment } = binding;
|
||||
/** @type {string} */
|
||||
let reference;
|
||||
/** @type {boolean} */
|
||||
let isPropertyAccess;
|
||||
if ("rawName" in binding) {
|
||||
reference = `${binding.rawName}${comment || ""}${propertyAccess(ids)}`;
|
||||
@@ -705,7 +710,7 @@ class ConcatenatedModule extends Module {
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
|
||||
* @param {string | HashConstructor=} hashFunction hash function to use
|
||||
* @param {HashFunction=} hashFunction hash function to use
|
||||
* @returns {ConcatenatedModule} the module
|
||||
*/
|
||||
static create(
|
||||
@@ -854,6 +859,7 @@ class ConcatenatedModule extends Module {
|
||||
const { moduleArgument, exportsArgument } =
|
||||
/** @type {BuildInfo} */
|
||||
(rootModule.buildInfo);
|
||||
/** @type {BuildInfo} */
|
||||
this.buildInfo = {
|
||||
strict: true,
|
||||
cacheable: true,
|
||||
@@ -872,8 +878,7 @@ class ConcatenatedModule extends Module {
|
||||
for (const m of this._modules) {
|
||||
// populate cacheable
|
||||
if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
|
||||
/** @type {BuildInfo} */
|
||||
(this.buildInfo).cacheable = false;
|
||||
this.buildInfo.cacheable = false;
|
||||
}
|
||||
|
||||
// populate dependencies
|
||||
@@ -911,7 +916,7 @@ class ConcatenatedModule extends Module {
|
||||
const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
|
||||
/** @type {BuildInfo} */ (m.buildInfo);
|
||||
|
||||
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
||||
const buildInfo = this.buildInfo;
|
||||
|
||||
// populate topLevelDeclarations
|
||||
if (topLevelDeclarations) {
|
||||
@@ -1209,7 +1214,7 @@ class ConcatenatedModule extends Module {
|
||||
* @param {Module} rootModule the root module of the concatenation
|
||||
* @param {Set<Module>} modules all modules in the concatenation (including the root module)
|
||||
* @param {AssociatedObjectForCache=} associatedObjectForCache object for caching
|
||||
* @param {string | HashConstructor=} hashFunction hash function to use
|
||||
* @param {HashFunction=} hashFunction hash function to use
|
||||
* @returns {string} the identifier
|
||||
*/
|
||||
static _createIdentifier(
|
||||
@@ -1222,6 +1227,7 @@ class ConcatenatedModule extends Module {
|
||||
/** @type {string} */ (rootModule.context),
|
||||
associatedObjectForCache
|
||||
);
|
||||
/** @type {string[]} */
|
||||
const identifiers = [];
|
||||
for (const module of modules) {
|
||||
identifiers.push(cachedMakePathsRelative(module.identifier()));
|
||||
@@ -1316,6 +1322,7 @@ class ConcatenatedModule extends Module {
|
||||
const usedNamesInScopeInfo = new Map();
|
||||
|
||||
// Set of already checked scopes
|
||||
/** @type {Set<Scope>} */
|
||||
const ignoredScopes = new Set();
|
||||
|
||||
// get all global names
|
||||
@@ -1329,14 +1336,17 @@ class ConcatenatedModule extends Module {
|
||||
// The super class expression in class scopes behaves weird
|
||||
// We get ranges of all super class expressions to make
|
||||
// renaming to work correctly
|
||||
/** @typedef {{ range: Range, variables: Variable[] }} ClassInfo */
|
||||
/** @type {WeakMap<Scope, ClassInfo[]>} */
|
||||
const superClassCache = new WeakMap();
|
||||
/**
|
||||
* @param {Scope} scope scope
|
||||
* @returns {{ range: Range, variables: Variable[] }[]} result
|
||||
* @returns {ClassInfo[]} result
|
||||
*/
|
||||
const getSuperClassExpressions = (scope) => {
|
||||
const cacheEntry = superClassCache.get(scope);
|
||||
if (cacheEntry !== undefined) return cacheEntry;
|
||||
/** @type {ClassInfo[]} */
|
||||
const superClassExpressions = [];
|
||||
for (const childScope of scope.childScopes) {
|
||||
if (childScope.type !== "class") continue;
|
||||
@@ -1462,6 +1472,7 @@ class ConcatenatedModule extends Module {
|
||||
info.module.identifier(),
|
||||
name
|
||||
);
|
||||
/** @type {UsedNames} */
|
||||
const referencesUsedNames = new Set();
|
||||
for (const ref of references) {
|
||||
addScopeSymbols(
|
||||
@@ -1533,11 +1544,12 @@ class ConcatenatedModule extends Module {
|
||||
topLevelDeclarations.add(name);
|
||||
}
|
||||
}
|
||||
/** @type {string} */
|
||||
let namespaceObjectName;
|
||||
if (info.namespaceExportSymbol) {
|
||||
namespaceObjectName = info.internalNames.get(
|
||||
info.namespaceExportSymbol
|
||||
);
|
||||
namespaceObjectName =
|
||||
/** @type {string} */
|
||||
(info.internalNames.get(info.namespaceExportSymbol));
|
||||
} else {
|
||||
namespaceObjectName = findNewName(
|
||||
"namespaceObject",
|
||||
@@ -1547,13 +1559,8 @@ class ConcatenatedModule extends Module {
|
||||
);
|
||||
allUsedNames.add(namespaceObjectName);
|
||||
}
|
||||
info.namespaceObjectName =
|
||||
/** @type {string} */
|
||||
(namespaceObjectName);
|
||||
topLevelDeclarations.add(
|
||||
/** @type {string} */
|
||||
(namespaceObjectName)
|
||||
);
|
||||
info.namespaceObjectName = namespaceObjectName;
|
||||
topLevelDeclarations.add(namespaceObjectName);
|
||||
break;
|
||||
}
|
||||
case "external": {
|
||||
@@ -1636,13 +1643,15 @@ class ConcatenatedModule extends Module {
|
||||
if (info.type === "concatenated") {
|
||||
const globalScope = /** @type {Scope} */ (info.globalScope);
|
||||
// group references by name
|
||||
/** @type {Map<string, Reference[]>} */
|
||||
const referencesByName = new Map();
|
||||
for (const reference of globalScope.through) {
|
||||
const name = reference.identifier.name;
|
||||
if (!referencesByName.has(name)) {
|
||||
referencesByName.set(name, []);
|
||||
}
|
||||
referencesByName.get(name).push(reference);
|
||||
/** @type {Reference[]} */
|
||||
(referencesByName.get(name)).push(reference);
|
||||
}
|
||||
for (const [name, references] of referencesByName) {
|
||||
const match = ConcatenationScope.matchModuleReference(name);
|
||||
@@ -1775,6 +1784,7 @@ class ConcatenatedModule extends Module {
|
||||
|
||||
// define exports
|
||||
if (exportsMap.size > 0) {
|
||||
/** @type {string[]} */
|
||||
const definitions = [];
|
||||
for (const [key, value] of exportsMap) {
|
||||
definitions.push(
|
||||
@@ -1826,9 +1836,11 @@ class ConcatenatedModule extends Module {
|
||||
}
|
||||
|
||||
// generate namespace objects
|
||||
/** @type {Map<ConcatenatedModuleInfo, string>} */
|
||||
const namespaceObjectSources = new Map();
|
||||
for (const info of neededNamespaceObjects) {
|
||||
if (info.namespaceExportSymbol) continue;
|
||||
/** @type {string[]} */
|
||||
const nsObj = [];
|
||||
const exportsInfo = moduleGraph.getExportsInfo(info.module);
|
||||
for (const exportInfo of exportsInfo.orderedExports) {
|
||||
@@ -1924,6 +1936,7 @@ ${defineGetters}`
|
||||
|
||||
// evaluate modules in order
|
||||
for (const rawInfo of modulesWithInfo) {
|
||||
/** @type {undefined | string} */
|
||||
let name;
|
||||
let isConditional = false;
|
||||
const info = rawInfo.type === "reference" ? rawInfo.target : rawInfo;
|
||||
@@ -2012,6 +2025,7 @@ ${defineGetters}`
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {CodeGenerationResultData} */
|
||||
const data = new Map();
|
||||
if (chunkInitFragments.length > 0) {
|
||||
data.set("chunkInitFragments", chunkInitFragments);
|
||||
@@ -2038,7 +2052,7 @@ ${defineGetters}`
|
||||
* @param {RuntimeSpec} runtime runtime
|
||||
* @param {RuntimeSpec[]} runtimes runtimes
|
||||
* @param {CodeGenerationResults} codeGenerationResults codeGenerationResults
|
||||
* @param {Set<string>} usedNames used names
|
||||
* @param {UsedNames} usedNames used names
|
||||
*/
|
||||
_analyseModule(
|
||||
modulesMap,
|
||||
|
||||
12
node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js
generated
vendored
12
node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js
generated
vendored
@@ -42,7 +42,16 @@ class FlagIncludedChunksPlugin {
|
||||
|
||||
// precalculate the modulo values for each bit
|
||||
const modulo = 1 / (1 / modulesCount) ** (1 / 31);
|
||||
const modulos = Array.from({ length: 31 }, (x, i) => (modulo ** i) | 0);
|
||||
/** @type {number[]} */
|
||||
const modulos = Array.from(
|
||||
{ length: 31 },
|
||||
/**
|
||||
* @param {number} x x
|
||||
* @param {number} i i
|
||||
* @returns {number} result
|
||||
*/
|
||||
(x, i) => (modulo ** i) | 0
|
||||
);
|
||||
|
||||
// iterate all modules to generate bit values
|
||||
let i = 0;
|
||||
@@ -72,6 +81,7 @@ class FlagIncludedChunksPlugin {
|
||||
(chunkModulesHash.get(chunkA));
|
||||
const chunkAModulesCount = chunkGraph.getNumberOfChunkModules(chunkA);
|
||||
if (chunkAModulesCount === 0) continue;
|
||||
/** @type {undefined | Module} */
|
||||
let bestModule;
|
||||
for (const module of chunkGraph.getChunkModulesIterable(chunkA)) {
|
||||
if (
|
||||
|
||||
8
node_modules/webpack/lib/optimize/InnerGraph.js
generated
vendored
8
node_modules/webpack/lib/optimize/InnerGraph.js
generated
vendored
@@ -35,6 +35,7 @@ class TopLevelSymbol {
|
||||
* @param {string} name name of the variable
|
||||
*/
|
||||
constructor(name) {
|
||||
/** @type {string} */
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -310,6 +311,7 @@ module.exports.onUsage = (state, onUsageCallback) => {
|
||||
let callbacks = usageCallbackMap.get(currentTopLevelSymbol);
|
||||
|
||||
if (callbacks === undefined) {
|
||||
/** @type {Set<UsageCallback>} */
|
||||
callbacks = new Set();
|
||||
usageCallbackMap.set(currentTopLevelSymbol, callbacks);
|
||||
}
|
||||
@@ -353,14 +355,14 @@ module.exports.tagTopLevelSymbol = (parser, name) => {
|
||||
return existingTag;
|
||||
}
|
||||
|
||||
const fn = new TopLevelSymbol(name);
|
||||
const symbol = new TopLevelSymbol(name);
|
||||
parser.tagVariable(
|
||||
name,
|
||||
topLevelSymbolTag,
|
||||
fn,
|
||||
symbol,
|
||||
JavascriptParser.VariableInfoFlags.Normal
|
||||
);
|
||||
return fn;
|
||||
return symbol;
|
||||
};
|
||||
|
||||
module.exports.topLevelSymbolTag = topLevelSymbolTag;
|
||||
|
||||
50
node_modules/webpack/lib/optimize/InnerGraphPlugin.js
generated
vendored
50
node_modules/webpack/lib/optimize/InnerGraphPlugin.js
generated
vendored
@@ -120,10 +120,10 @@ class InnerGraphPlugin {
|
||||
statement.type === "FunctionDeclaration"
|
||||
) {
|
||||
const name = statement.id ? statement.id.name : "*default*";
|
||||
const fn =
|
||||
const symbol =
|
||||
/** @type {TopLevelSymbol} */
|
||||
(InnerGraph.tagTopLevelSymbol(parser, name));
|
||||
statementWithTopLevelSymbol.set(statement, fn);
|
||||
statementWithTopLevelSymbol.set(statement, symbol);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -140,15 +140,15 @@ class InnerGraphPlugin {
|
||||
)
|
||||
) {
|
||||
const name = statement.id ? statement.id.name : "*default*";
|
||||
const fn = /** @type {TopLevelSymbol} */ (
|
||||
const symbol = /** @type {TopLevelSymbol} */ (
|
||||
InnerGraph.tagTopLevelSymbol(parser, name)
|
||||
);
|
||||
classWithTopLevelSymbol.set(statement, fn);
|
||||
classWithTopLevelSymbol.set(statement, symbol);
|
||||
return true;
|
||||
}
|
||||
if (statement.type === "ExportDefaultDeclaration") {
|
||||
const name = "*default*";
|
||||
const fn =
|
||||
const symbol =
|
||||
/** @type {TopLevelSymbol} */
|
||||
(InnerGraph.tagTopLevelSymbol(parser, name));
|
||||
const decl = statement.declaration;
|
||||
@@ -165,7 +165,7 @@ class InnerGraphPlugin {
|
||||
classWithTopLevelSymbol.set(
|
||||
/** @type {ClassExpression | ClassDeclaration} */
|
||||
(decl),
|
||||
fn
|
||||
symbol
|
||||
);
|
||||
} else if (
|
||||
parser.isPure(
|
||||
@@ -175,7 +175,7 @@ class InnerGraphPlugin {
|
||||
(statement.range)[0]
|
||||
)
|
||||
) {
|
||||
statementWithTopLevelSymbol.set(statement, fn);
|
||||
statementWithTopLevelSymbol.set(statement, symbol);
|
||||
if (
|
||||
!decl.type.endsWith("FunctionExpression") &&
|
||||
!decl.type.endsWith("Declaration") &&
|
||||
@@ -207,20 +207,20 @@ class InnerGraphPlugin {
|
||||
/** @type {Range} */ (decl.id.range)[1]
|
||||
)
|
||||
) {
|
||||
const fn =
|
||||
const symbol =
|
||||
/** @type {TopLevelSymbol} */
|
||||
(InnerGraph.tagTopLevelSymbol(parser, name));
|
||||
classWithTopLevelSymbol.set(decl.init, fn);
|
||||
classWithTopLevelSymbol.set(decl.init, symbol);
|
||||
} else if (
|
||||
parser.isPure(
|
||||
decl.init,
|
||||
/** @type {Range} */ (decl.id.range)[1]
|
||||
)
|
||||
) {
|
||||
const fn =
|
||||
const symbol =
|
||||
/** @type {TopLevelSymbol} */
|
||||
(InnerGraph.tagTopLevelSymbol(parser, name));
|
||||
declWithTopLevelSymbol.set(decl, fn);
|
||||
declWithTopLevelSymbol.set(decl, symbol);
|
||||
if (
|
||||
!decl.init.type.endsWith("FunctionExpression") &&
|
||||
decl.init.type !== "Literal"
|
||||
@@ -252,9 +252,9 @@ class InnerGraphPlugin {
|
||||
if (parser.scope.topLevelScope === true) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, undefined);
|
||||
|
||||
const fn = statementWithTopLevelSymbol.get(statement);
|
||||
if (fn) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
||||
const symbol = statementWithTopLevelSymbol.get(statement);
|
||||
if (symbol) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, symbol);
|
||||
const purePart = statementPurePart.get(statement);
|
||||
if (purePart) {
|
||||
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
||||
@@ -285,9 +285,9 @@ class InnerGraphPlugin {
|
||||
(expr, statement) => {
|
||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||
if (parser.scope.topLevelScope === true) {
|
||||
const fn = classWithTopLevelSymbol.get(statement);
|
||||
const symbol = classWithTopLevelSymbol.get(statement);
|
||||
if (
|
||||
fn &&
|
||||
symbol &&
|
||||
parser.isPure(
|
||||
expr,
|
||||
statement.id
|
||||
@@ -295,7 +295,7 @@ class InnerGraphPlugin {
|
||||
: /** @type {Range} */ (statement.range)[0]
|
||||
)
|
||||
) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
||||
InnerGraph.setTopLevelSymbol(parser.state, symbol);
|
||||
onUsageSuper(expr);
|
||||
}
|
||||
}
|
||||
@@ -307,8 +307,8 @@ class InnerGraphPlugin {
|
||||
(element, classDefinition) => {
|
||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||
if (parser.scope.topLevelScope === true) {
|
||||
const fn = classWithTopLevelSymbol.get(classDefinition);
|
||||
if (fn) {
|
||||
const symbol = classWithTopLevelSymbol.get(classDefinition);
|
||||
if (symbol) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, undefined);
|
||||
}
|
||||
}
|
||||
@@ -320,8 +320,8 @@ class InnerGraphPlugin {
|
||||
(expression, element, classDefinition) => {
|
||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||
if (parser.scope.topLevelScope === true) {
|
||||
const fn = classWithTopLevelSymbol.get(classDefinition);
|
||||
if (fn) {
|
||||
const symbol = classWithTopLevelSymbol.get(classDefinition);
|
||||
if (symbol) {
|
||||
if (
|
||||
!element.static ||
|
||||
parser.isPure(
|
||||
@@ -331,7 +331,7 @@ class InnerGraphPlugin {
|
||||
: /** @type {Range} */ (element.range)[0]
|
||||
)
|
||||
) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
||||
InnerGraph.setTopLevelSymbol(parser.state, symbol);
|
||||
if (element.type !== "MethodDefinition" && element.static) {
|
||||
InnerGraph.onUsage(parser.state, (usedByExports) => {
|
||||
switch (usedByExports) {
|
||||
@@ -362,10 +362,10 @@ class InnerGraphPlugin {
|
||||
|
||||
parser.hooks.declarator.tap(PLUGIN_NAME, (decl, _statement) => {
|
||||
if (!InnerGraph.isEnabled(parser.state)) return;
|
||||
const fn = declWithTopLevelSymbol.get(decl);
|
||||
const symbol = declWithTopLevelSymbol.get(decl);
|
||||
|
||||
if (fn) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, fn);
|
||||
if (symbol) {
|
||||
InnerGraph.setTopLevelSymbol(parser.state, symbol);
|
||||
if (pureDeclarators.has(decl)) {
|
||||
if (
|
||||
/** @type {ClassExpression} */
|
||||
|
||||
5
node_modules/webpack/lib/optimize/LimitChunkCountPlugin.js
generated
vendored
5
node_modules/webpack/lib/optimize/LimitChunkCountPlugin.js
generated
vendored
@@ -57,9 +57,10 @@ class LimitChunkCountPlugin {
|
||||
/**
|
||||
* @param {LimitChunkCountPluginOptions=} options options object
|
||||
*/
|
||||
constructor(options) {
|
||||
constructor(options = { maxChunks: 1 }) {
|
||||
validate(options);
|
||||
this.options = /** @type {LimitChunkCountPluginOptions} */ (options);
|
||||
/** @type {LimitChunkCountPluginOptions} */
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
16
node_modules/webpack/lib/optimize/MangleExportsPlugin.js
generated
vendored
16
node_modules/webpack/lib/optimize/MangleExportsPlugin.js
generated
vendored
@@ -17,6 +17,12 @@ const { compareSelect, compareStringsNumeric } = require("../util/comparators");
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
||||
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
||||
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../util/comparators").Comparator<T>} Comparator
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {ExportsInfo} exportsInfo exports info
|
||||
@@ -36,6 +42,7 @@ const canMangle = (exportsInfo) => {
|
||||
};
|
||||
|
||||
// Sort by name
|
||||
/** @type {Comparator<ExportInfo>} */
|
||||
const comparator = compareSelect((e) => e.name, compareStringsNumeric);
|
||||
/**
|
||||
* @param {boolean} deterministic use deterministic names
|
||||
@@ -45,6 +52,7 @@ const comparator = compareSelect((e) => e.name, compareStringsNumeric);
|
||||
*/
|
||||
const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
||||
if (!canMangle(exportsInfo)) return;
|
||||
/** @type {UsedNames} */
|
||||
const usedNames = new Set();
|
||||
/** @type {ExportInfo[]} */
|
||||
const mangleableExports = [];
|
||||
@@ -69,11 +77,11 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
||||
// Can the export be mangled?
|
||||
exportInfo.canMangle !== true ||
|
||||
// Never rename 1 char exports
|
||||
(name.length === 1 && /^[a-zA-Z0-9_$]/.test(name)) ||
|
||||
(name.length === 1 && /^[a-z0-9_$]/i.test(name)) ||
|
||||
// Don't rename 2 char exports in deterministic mode
|
||||
(deterministic &&
|
||||
name.length === 2 &&
|
||||
/^[a-zA-Z_$][a-zA-Z0-9_$]|^[1-9][0-9]/.test(name)) ||
|
||||
/^[a-z_$][a-z0-9_$]|^[1-9][0-9]/i.test(name)) ||
|
||||
// Don't rename exports that are not provided
|
||||
(avoidMangleNonProvided && exportInfo.provided !== true)
|
||||
) {
|
||||
@@ -119,7 +127,9 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
||||
usedNames.size
|
||||
);
|
||||
} else {
|
||||
/** @type {ExportInfo[]} */
|
||||
const usedExports = [];
|
||||
/** @type {ExportInfo[]} */
|
||||
const unusedExports = [];
|
||||
for (const exportInfo of mangleableExports) {
|
||||
if (exportInfo.getUsed(undefined) === UsageState.Unused) {
|
||||
@@ -133,6 +143,7 @@ const mangleExportsInfo = (deterministic, exportsInfo, isNamespace) => {
|
||||
let i = 0;
|
||||
for (const list of [usedExports, unusedExports]) {
|
||||
for (const exportInfo of list) {
|
||||
/** @type {string} */
|
||||
let name;
|
||||
do {
|
||||
name = numberToIdentifier(i++);
|
||||
@@ -150,6 +161,7 @@ class MangleExportsPlugin {
|
||||
* @param {boolean} deterministic use deterministic names
|
||||
*/
|
||||
constructor(deterministic) {
|
||||
/** @type {boolean} */
|
||||
this._deterministic = deterministic;
|
||||
}
|
||||
|
||||
|
||||
6
node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js
generated
vendored
6
node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js
generated
vendored
@@ -11,6 +11,7 @@ const { runtimeEqual } = require("../util/runtime");
|
||||
|
||||
/** @typedef {import("../../declarations/plugins/optimize/MergeDuplicateChunksPlugin").MergeDuplicateChunksPluginOptions} MergeDuplicateChunksPluginOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../../schemas/plugins/optimize/MergeDuplicateChunksPlugin.check"),
|
||||
@@ -26,10 +27,11 @@ const PLUGIN_NAME = "MergeDuplicateChunksPlugin";
|
||||
|
||||
class MergeDuplicateChunksPlugin {
|
||||
/**
|
||||
* @param {MergeDuplicateChunksPluginOptions} options options object
|
||||
* @param {MergeDuplicateChunksPluginOptions=} options options object
|
||||
*/
|
||||
constructor(options = { stage: STAGE_BASIC }) {
|
||||
validate(options);
|
||||
/** @type {MergeDuplicateChunksPluginOptions} */
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -48,11 +50,13 @@ class MergeDuplicateChunksPlugin {
|
||||
const { chunkGraph, moduleGraph } = compilation;
|
||||
|
||||
// remember already tested chunks for performance
|
||||
/** @type {Set<Chunk>} */
|
||||
const notDuplicates = new Set();
|
||||
|
||||
// for each chunk
|
||||
for (const chunk of chunks) {
|
||||
// track a Set of all chunk that could be duplicates
|
||||
/** @type {Set<Chunk> | undefined} */
|
||||
let possibleDuplicates;
|
||||
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
|
||||
if (possibleDuplicates === undefined) {
|
||||
|
||||
7
node_modules/webpack/lib/optimize/MinChunkSizePlugin.js
generated
vendored
7
node_modules/webpack/lib/optimize/MinChunkSizePlugin.js
generated
vendored
@@ -29,6 +29,7 @@ class MinChunkSizePlugin {
|
||||
*/
|
||||
constructor(options) {
|
||||
validate(options);
|
||||
/** @type {MinChunkSizePluginOptions} */
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -53,11 +54,13 @@ class MinChunkSizePlugin {
|
||||
entryChunkMultiplicator: 1
|
||||
};
|
||||
|
||||
/** @type {Map<Chunk, number>} */
|
||||
const chunkSizesMap = new Map();
|
||||
/** @type {[Chunk, Chunk][]} */
|
||||
const combinations = [];
|
||||
/** @type {Chunk[]} */
|
||||
const smallChunks = [];
|
||||
/** @type {Chunk[]} */
|
||||
const visitedChunks = [];
|
||||
for (const a of chunks) {
|
||||
// check if one of the chunks sizes is smaller than the minChunkSize
|
||||
@@ -83,8 +86,8 @@ class MinChunkSizePlugin {
|
||||
const sortedSizeFilteredExtendedPairCombinations = combinations
|
||||
.map((pair) => {
|
||||
// extend combination pairs with size and integrated size
|
||||
const a = chunkSizesMap.get(pair[0]);
|
||||
const b = chunkSizesMap.get(pair[1]);
|
||||
const a = /** @type {number} */ (chunkSizesMap.get(pair[0]));
|
||||
const b = /** @type {number} */ (chunkSizesMap.get(pair[1]));
|
||||
const ab = chunkGraph.getIntegratedChunksSize(
|
||||
pair[0],
|
||||
pair[1],
|
||||
|
||||
23
node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
generated
vendored
23
node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
generated
vendored
@@ -28,6 +28,8 @@ const ConcatenatedModule = require("./ConcatenatedModule");
|
||||
/** @typedef {import("../RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
|
||||
|
||||
/**
|
||||
* @typedef {object} Statistics
|
||||
* @property {number} cached
|
||||
@@ -104,7 +106,7 @@ class ModuleConcatenationPlugin {
|
||||
|
||||
/**
|
||||
* @param {Module} module the module
|
||||
* @param {Module | ((requestShortener: RequestShortener) => string)} problem the problem
|
||||
* @param {Problem} problem the problem
|
||||
* @returns {(requestShortener: RequestShortener) => string} the reason
|
||||
*/
|
||||
const formatBailoutWarning = (module, problem) => (requestShortener) => {
|
||||
@@ -143,7 +145,9 @@ class ModuleConcatenationPlugin {
|
||||
"webpack.ModuleConcatenationPlugin"
|
||||
);
|
||||
const { chunkGraph, moduleGraph } = compilation;
|
||||
/** @type {Module[]} */
|
||||
const relevantModules = [];
|
||||
/** @type {Set<Module>} */
|
||||
const possibleInners = new Set();
|
||||
const context = {
|
||||
chunkGraph,
|
||||
@@ -265,7 +269,9 @@ class ModuleConcatenationPlugin {
|
||||
let statsEmptyConfigurations = 0;
|
||||
|
||||
logger.time("find modules to concatenate");
|
||||
/** @type {ConcatConfiguration[]} */
|
||||
const concatConfigurations = [];
|
||||
/** @type {Set<Module>} */
|
||||
const usedAsInner = new Set();
|
||||
for (const currentRoot of relevantModules) {
|
||||
// when used by another configuration as inner:
|
||||
@@ -273,6 +279,7 @@ class ModuleConcatenationPlugin {
|
||||
// TODO reconsider that when it's only used in a different runtime
|
||||
if (usedAsInner.has(currentRoot)) continue;
|
||||
|
||||
/** @type {RuntimeSpec} */
|
||||
let chunkRuntime;
|
||||
for (const r of chunkGraph.getModuleRuntimes(currentRoot)) {
|
||||
chunkRuntime = mergeRuntimeOwned(chunkRuntime, r);
|
||||
@@ -295,6 +302,7 @@ class ModuleConcatenationPlugin {
|
||||
);
|
||||
|
||||
// cache failures to add modules
|
||||
/** @type {Map<Module, Problem>} */
|
||||
const failureCache = new Map();
|
||||
|
||||
// potential optional import candidates
|
||||
@@ -311,6 +319,7 @@ class ModuleConcatenationPlugin {
|
||||
}
|
||||
|
||||
for (const imp of candidates) {
|
||||
/** @type {Set<Module>} */
|
||||
const impCandidates = new Set();
|
||||
const problem = this._tryToAdd(
|
||||
compilation,
|
||||
@@ -373,6 +382,7 @@ class ModuleConcatenationPlugin {
|
||||
logger.time("sort concat configurations");
|
||||
concatConfigurations.sort((a, b) => b.modules.size - a.modules.size);
|
||||
logger.timeEnd("sort concat configurations");
|
||||
/** @type {Set<Module>} */
|
||||
const usedModules = new Set();
|
||||
|
||||
logger.time("create concatenated modules");
|
||||
@@ -515,6 +525,7 @@ class ModuleConcatenationPlugin {
|
||||
*/
|
||||
_getImports(compilation, module, runtime) {
|
||||
const moduleGraph = compilation.moduleGraph;
|
||||
/** @type {Set<Module>} */
|
||||
const set = new Set();
|
||||
for (const dep of module.dependencies) {
|
||||
// Get reference info only for harmony Dependencies
|
||||
@@ -555,11 +566,11 @@ class ModuleConcatenationPlugin {
|
||||
* @param {RuntimeSpec} activeRuntime the runtime scope of the root module
|
||||
* @param {Set<Module>} possibleModules modules that are candidates
|
||||
* @param {Set<Module>} candidates list of potential candidates (will be added to)
|
||||
* @param {Map<Module, Module | ((requestShortener: RequestShortener) => string)>} failureCache cache for problematic modules to be more performant
|
||||
* @param {Map<Module, Problem>} failureCache cache for problematic modules to be more performant
|
||||
* @param {ChunkGraph} chunkGraph the chunk graph
|
||||
* @param {boolean} avoidMutateOnFailure avoid mutating the config when adding fails
|
||||
* @param {Statistics} statistics gathering metrics
|
||||
* @returns {null | Module | ((requestShortener: RequestShortener) => string)} the problematic module
|
||||
* @returns {null | Problem} the problematic module
|
||||
*/
|
||||
_tryToAdd(
|
||||
compilation,
|
||||
@@ -646,6 +657,7 @@ class ModuleConcatenationPlugin {
|
||||
* @returns {string} problem description
|
||||
*/
|
||||
const problem = (requestShortener) => {
|
||||
/** @type {Set<string>} */
|
||||
const importingExplanations = new Set(
|
||||
activeNonModulesConnections
|
||||
.map((c) => c.explanation)
|
||||
@@ -674,6 +686,7 @@ class ModuleConcatenationPlugin {
|
||||
if (chunkGraph.getNumberOfModuleChunks(originModule) === 0) continue;
|
||||
|
||||
// We don't care for connections from other runtimes
|
||||
/** @type {RuntimeSpec} */
|
||||
let originRuntime;
|
||||
for (const r of chunkGraph.getModuleRuntimes(originModule)) {
|
||||
originRuntime = mergeRuntimeOwned(originRuntime, r);
|
||||
@@ -822,6 +835,7 @@ class ModuleConcatenationPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {undefined | number} */
|
||||
let backup;
|
||||
if (avoidMutateOnFailure) {
|
||||
backup = config.snapshot();
|
||||
@@ -864,7 +878,6 @@ class ModuleConcatenationPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
|
||||
/** @typedef {Map<Module, Problem>} Warnings */
|
||||
|
||||
class ConcatConfiguration {
|
||||
@@ -873,7 +886,9 @@ class ConcatConfiguration {
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
*/
|
||||
constructor(rootModule, runtime) {
|
||||
/** @type {Module} */
|
||||
this.rootModule = rootModule;
|
||||
/** @type {RuntimeSpec} */
|
||||
this.runtime = runtime;
|
||||
/** @type {Set<Module>} */
|
||||
this.modules = new Set();
|
||||
|
||||
64
node_modules/webpack/lib/optimize/RealContentHashPlugin.js
generated
vendored
64
node_modules/webpack/lib/optimize/RealContentHashPlugin.js
generated
vendored
@@ -20,6 +20,12 @@ const createHash = require("../util/createHash");
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {typeof import("../util/Hash")} Hash */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../util/comparators").Comparator<T>} Comparator
|
||||
*/
|
||||
|
||||
/** @type {Hashes} */
|
||||
const EMPTY_SET = new Set();
|
||||
|
||||
/**
|
||||
@@ -47,6 +53,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
|
||||
// Buffer.equals compares size first so this should be efficient enough
|
||||
// If it becomes a performance problem we can use a map and group by size
|
||||
// instead of looping over all assets.
|
||||
/** @type {Buffer[]} */
|
||||
const result = [];
|
||||
outer: for (const value of input) {
|
||||
const buf = fn(value);
|
||||
@@ -65,6 +72,7 @@ const mapAndDeduplicateBuffers = (input, fn) => {
|
||||
*/
|
||||
const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
||||
|
||||
/** @type {WeakMap<Source, CachedSource>} */
|
||||
const cachedSourceMap = new WeakMap();
|
||||
|
||||
/**
|
||||
@@ -82,8 +90,6 @@ const toCachedSource = (source) => {
|
||||
return newSource;
|
||||
};
|
||||
|
||||
/** @typedef {Set<string>} OwnHashes */
|
||||
/** @typedef {Set<string>} ReferencedHashes */
|
||||
/** @typedef {Set<string>} Hashes */
|
||||
|
||||
/**
|
||||
@@ -94,10 +100,10 @@ const toCachedSource = (source) => {
|
||||
* @property {RawSource | undefined} newSource
|
||||
* @property {RawSource | undefined} newSourceWithoutOwn
|
||||
* @property {string} content
|
||||
* @property {OwnHashes | undefined} ownHashes
|
||||
* @property {Hashes | undefined} ownHashes
|
||||
* @property {Promise<void> | undefined} contentComputePromise
|
||||
* @property {Promise<void> | undefined} contentComputeWithoutOwnPromise
|
||||
* @property {ReferencedHashes | undefined} referencedHashes
|
||||
* @property {Hashes | undefined} referencedHashes
|
||||
* @property {Hashes} hashes
|
||||
*/
|
||||
|
||||
@@ -142,7 +148,9 @@ class RealContentHashPlugin {
|
||||
* @param {RealContentHashPluginOptions} options options
|
||||
*/
|
||||
constructor({ hashFunction, hashDigest }) {
|
||||
/** @type {HashFunction} */
|
||||
this._hashFunction = hashFunction;
|
||||
/** @type {HashDigest} */
|
||||
this._hashDigest = hashDigest;
|
||||
}
|
||||
|
||||
@@ -220,7 +228,9 @@ class RealContentHashPlugin {
|
||||
);
|
||||
[asset.referencedHashes, asset.ownHashes] =
|
||||
await cacheAnalyse.providePromise(name, etag, () => {
|
||||
/** @type {Hashes} */
|
||||
const referencedHashes = new Set();
|
||||
/** @type {Hashes} */
|
||||
const ownHashes = new Set();
|
||||
const inContent = content.match(hashRegExp);
|
||||
if (inContent) {
|
||||
@@ -238,15 +248,13 @@ class RealContentHashPlugin {
|
||||
);
|
||||
/**
|
||||
* @param {string} hash the hash
|
||||
* @returns {undefined | ReferencedHashes} the referenced hashes
|
||||
* @returns {undefined | Hashes} the referenced hashes
|
||||
*/
|
||||
const getDependencies = (hash) => {
|
||||
const assets = hashToAssets.get(hash);
|
||||
if (!assets) {
|
||||
const referencingAssets = assetsWithInfo.filter((asset) =>
|
||||
/** @type {ReferencedHashes} */ (asset.referencedHashes).has(
|
||||
hash
|
||||
)
|
||||
/** @type {Hashes} */ (asset.referencedHashes).has(hash)
|
||||
);
|
||||
const err = new WebpackError(`RealContentHashPlugin
|
||||
Some kind of unexpected caching problem occurred.
|
||||
@@ -264,16 +272,15 @@ ${referencingAssets
|
||||
compilation.errors.push(err);
|
||||
return;
|
||||
}
|
||||
/** @type {Hashes} */
|
||||
const hashes = new Set();
|
||||
for (const { referencedHashes, ownHashes } of assets) {
|
||||
if (!(/** @type {OwnHashes} */ (ownHashes).has(hash))) {
|
||||
for (const hash of /** @type {OwnHashes} */ (ownHashes)) {
|
||||
if (!(/** @type {Hashes} */ (ownHashes).has(hash))) {
|
||||
for (const hash of /** @type {Hashes} */ (ownHashes)) {
|
||||
hashes.add(hash);
|
||||
}
|
||||
}
|
||||
for (const hash of /** @type {ReferencedHashes} */ (
|
||||
referencedHashes
|
||||
)) {
|
||||
for (const hash of /** @type {Hashes} */ (referencedHashes)) {
|
||||
hashes.add(hash);
|
||||
}
|
||||
}
|
||||
@@ -290,7 +297,7 @@ ${referencingAssets
|
||||
(a) => a.name
|
||||
)})`;
|
||||
};
|
||||
/** @type {Set<string>} */
|
||||
/** @type {Hashes} */
|
||||
const hashesInOrder = new Set();
|
||||
for (const hash of hashToAssets.keys()) {
|
||||
/**
|
||||
@@ -329,7 +336,7 @@ ${referencingAssets
|
||||
cacheGenerate.mergeEtags(
|
||||
cacheGenerate.getLazyHashedEtag(asset.source),
|
||||
Array.from(
|
||||
/** @type {ReferencedHashes} */ (asset.referencedHashes),
|
||||
/** @type {Hashes} */ (asset.referencedHashes),
|
||||
(hash) => hashToNewHash.get(hash)
|
||||
).join("|")
|
||||
);
|
||||
@@ -341,10 +348,10 @@ ${referencingAssets
|
||||
if (asset.contentComputePromise) return asset.contentComputePromise;
|
||||
return (asset.contentComputePromise = (async () => {
|
||||
if (
|
||||
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
||||
[
|
||||
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
||||
].some((hash) => hashToNewHash.get(hash) !== hash)
|
||||
/** @type {Hashes} */ (asset.ownHashes).size > 0 ||
|
||||
[.../** @type {Hashes} */ (asset.referencedHashes)].some(
|
||||
(hash) => hashToNewHash.get(hash) !== hash
|
||||
)
|
||||
) {
|
||||
const identifier = asset.name;
|
||||
const etag = getEtag(asset);
|
||||
@@ -372,10 +379,10 @@ ${referencingAssets
|
||||
}
|
||||
return (asset.contentComputeWithoutOwnPromise = (async () => {
|
||||
if (
|
||||
/** @type {OwnHashes} */ (asset.ownHashes).size > 0 ||
|
||||
[
|
||||
.../** @type {ReferencedHashes} */ (asset.referencedHashes)
|
||||
].some((hash) => hashToNewHash.get(hash) !== hash)
|
||||
/** @type {Hashes} */ (asset.ownHashes).size > 0 ||
|
||||
[.../** @type {Hashes} */ (asset.referencedHashes)].some(
|
||||
(hash) => hashToNewHash.get(hash) !== hash
|
||||
)
|
||||
) {
|
||||
const identifier = `${asset.name}|without-own`;
|
||||
const etag = getEtag(asset);
|
||||
@@ -387,7 +394,7 @@ ${referencingAssets
|
||||
hashRegExp,
|
||||
(hash) => {
|
||||
if (
|
||||
/** @type {OwnHashes} */
|
||||
/** @type {Hashes} */
|
||||
(asset.ownHashes).has(hash)
|
||||
) {
|
||||
return "";
|
||||
@@ -401,6 +408,7 @@ ${referencingAssets
|
||||
}
|
||||
})());
|
||||
};
|
||||
/** @type {Comparator<AssetInfoForRealContentHash>} */
|
||||
const comparator = compareSelect((a) => a.name, compareStrings);
|
||||
for (const oldHash of hashesInOrder) {
|
||||
const assets =
|
||||
@@ -409,13 +417,13 @@ ${referencingAssets
|
||||
assets.sort(comparator);
|
||||
await Promise.all(
|
||||
assets.map((asset) =>
|
||||
/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)
|
||||
/** @type {Hashes} */ (asset.ownHashes).has(oldHash)
|
||||
? computeNewContentWithoutOwn(asset)
|
||||
: computeNewContent(asset)
|
||||
)
|
||||
);
|
||||
const assetsContent = mapAndDeduplicateBuffers(assets, (asset) => {
|
||||
if (/** @type {OwnHashes} */ (asset.ownHashes).has(oldHash)) {
|
||||
if (/** @type {Hashes} */ (asset.ownHashes).has(oldHash)) {
|
||||
return asset.newSourceWithoutOwn
|
||||
? asset.newSourceWithoutOwn.buffer()
|
||||
: asset.source.buffer();
|
||||
@@ -447,7 +455,9 @@ ${referencingAssets
|
||||
);
|
||||
|
||||
const infoUpdate = {};
|
||||
const hash = /** @type {string} */ (asset.info.contenthash);
|
||||
const hash =
|
||||
/** @type {Exclude<AssetInfo["contenthash"], undefined>} */
|
||||
(asset.info.contenthash);
|
||||
infoUpdate.contenthash = Array.isArray(hash)
|
||||
? hash.map(
|
||||
(hash) => /** @type {string} */ (hashToNewHash.get(hash))
|
||||
|
||||
15
node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js
generated
vendored
15
node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js
generated
vendored
@@ -33,7 +33,7 @@ const THIRTY_TWO_BIGINT = BigInt(32);
|
||||
* Parses the module mask and returns the modules represented by it
|
||||
* @param {bigint} mask the module mask
|
||||
* @param {Module[]} ordinalModules the modules in the order they were added to the mask (LSB is index 0)
|
||||
* @returns {Generator<Module>} the modules represented by the mask
|
||||
* @returns {Generator<Module, undefined, undefined>} the modules represented by the mask
|
||||
*/
|
||||
function* getModulesFromMask(mask, ordinalModules) {
|
||||
let offset = 31;
|
||||
@@ -74,10 +74,13 @@ class RemoveParentModulesPlugin {
|
||||
*/
|
||||
const handler = (chunks, chunkGroups) => {
|
||||
const chunkGraph = compilation.chunkGraph;
|
||||
/** @type {Set<ChunkGroup>} */
|
||||
const queue = new Set();
|
||||
/** @type {WeakMap<ChunkGroup, bigint | undefined>} */
|
||||
const availableModulesMap = new WeakMap();
|
||||
|
||||
let nextModuleMask = ONE_BIGINT;
|
||||
/** @type {WeakMap<Module, bigint>} */
|
||||
const maskByModule = new WeakMap();
|
||||
/** @type {Module[]} */
|
||||
const ordinalModules = [];
|
||||
@@ -99,6 +102,7 @@ class RemoveParentModulesPlugin {
|
||||
};
|
||||
|
||||
// Initialize masks by chunk and by chunk group for quicker comparisons
|
||||
/** @type {WeakMap<Chunk, bigint>} */
|
||||
const chunkMasks = new WeakMap();
|
||||
for (const chunk of chunks) {
|
||||
let mask = ZERO_BIGINT;
|
||||
@@ -109,6 +113,7 @@ class RemoveParentModulesPlugin {
|
||||
chunkMasks.set(chunk, mask);
|
||||
}
|
||||
|
||||
/** @type {WeakMap<ChunkGroup, bigint>} */
|
||||
const chunkGroupMasks = new WeakMap();
|
||||
for (const chunkGroup of chunkGroups) {
|
||||
let mask = ZERO_BIGINT;
|
||||
@@ -143,7 +148,8 @@ class RemoveParentModulesPlugin {
|
||||
const availableModulesInParent = availableModulesMap.get(parent);
|
||||
if (availableModulesInParent !== undefined) {
|
||||
const parentMask =
|
||||
availableModulesInParent | chunkGroupMasks.get(parent);
|
||||
availableModulesInParent |
|
||||
/** @type {bigint} */ (chunkGroupMasks.get(parent));
|
||||
// If we know the available modules in parent: process these
|
||||
if (availableModulesMask === undefined) {
|
||||
// if we have not own info yet: create new entry
|
||||
@@ -181,7 +187,10 @@ class RemoveParentModulesPlugin {
|
||||
);
|
||||
if (availableModulesSets.includes(undefined)) continue; // No info about this chunk group
|
||||
|
||||
const availableModulesMask = intersectMasks(availableModulesSets);
|
||||
const availableModulesMask = intersectMasks(
|
||||
/** @type {bigint[]} */
|
||||
(availableModulesSets)
|
||||
);
|
||||
const toRemoveMask = chunkMask & availableModulesMask;
|
||||
if (toRemoveMask !== ZERO_BIGINT) {
|
||||
for (const module of getModulesFromMask(
|
||||
|
||||
8
node_modules/webpack/lib/optimize/RuntimeChunkPlugin.js
generated
vendored
8
node_modules/webpack/lib/optimize/RuntimeChunkPlugin.js
generated
vendored
@@ -16,9 +16,9 @@ class RuntimeChunkPlugin {
|
||||
/**
|
||||
* @param {{ name?: RuntimeChunkFunction }=} options options
|
||||
*/
|
||||
constructor(options) {
|
||||
constructor(options = {}) {
|
||||
/** @type {{ name: string | RuntimeChunkFunction }} */
|
||||
this.options = {
|
||||
/** @type {RuntimeChunkFunction} */
|
||||
name: (entrypoint) => `runtime~${entrypoint.name}`,
|
||||
...options
|
||||
};
|
||||
@@ -38,9 +38,7 @@ class RuntimeChunkPlugin {
|
||||
(compilation.entries.get(entryName));
|
||||
if (data.options.runtime === undefined && !data.options.dependOn) {
|
||||
// Determine runtime chunk name
|
||||
let name =
|
||||
/** @type {string | RuntimeChunkFunction} */
|
||||
(this.options.name);
|
||||
let name = this.options.name;
|
||||
if (typeof name === "function") {
|
||||
name = name({ name: entryName });
|
||||
}
|
||||
|
||||
3
node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js
generated
vendored
3
node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js
generated
vendored
@@ -68,6 +68,7 @@ class SideEffectsFlagPlugin {
|
||||
* @param {boolean} analyseSource analyse source code for side effects
|
||||
*/
|
||||
constructor(analyseSource = true) {
|
||||
/** @type {boolean} */
|
||||
this._analyseSource = analyseSource;
|
||||
}
|
||||
|
||||
@@ -277,6 +278,7 @@ class SideEffectsFlagPlugin {
|
||||
|
||||
logger.time("update dependencies");
|
||||
|
||||
/** @type {Set<Module>} */
|
||||
const optimizedModules = new Set();
|
||||
|
||||
/**
|
||||
@@ -291,6 +293,7 @@ class SideEffectsFlagPlugin {
|
||||
module
|
||||
)) {
|
||||
const dep = connection.dependency;
|
||||
/** @type {boolean} */
|
||||
let isReexport;
|
||||
if (
|
||||
(isReexport =
|
||||
|
||||
28
node_modules/webpack/lib/optimize/SplitChunksPlugin.js
generated
vendored
28
node_modules/webpack/lib/optimize/SplitChunksPlugin.js
generated
vendored
@@ -22,7 +22,6 @@ const memoize = require("../util/memoize");
|
||||
const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
|
||||
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
||||
@@ -36,6 +35,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
|
||||
/** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
|
||||
/** @typedef {import("../util/deterministicGrouping").Sizes} Sizes */
|
||||
|
||||
/**
|
||||
* @callback ChunkFilterFn
|
||||
@@ -123,6 +123,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
* @property {ChunkGraph} chunkGraph
|
||||
*/
|
||||
|
||||
/** @typedef {(module: Module) => OptimizationSplitChunksCacheGroup | OptimizationSplitChunksCacheGroup[] | void} RawGetCacheGroups */
|
||||
|
||||
/**
|
||||
* @callback GetCacheGroups
|
||||
* @param {Module} module
|
||||
@@ -220,9 +222,10 @@ const getRequests = (chunk) => {
|
||||
* @returns {T} result
|
||||
*/
|
||||
const mapObject = (obj, fn) => {
|
||||
/** @type {T} */
|
||||
const newObj = Object.create(null);
|
||||
for (const key of Object.keys(obj)) {
|
||||
newObj[key] = fn(
|
||||
newObj[/** @type {keyof T} */ (key)] = fn(
|
||||
obj[/** @type {keyof T} */ (key)],
|
||||
/** @type {keyof T} */
|
||||
(key)
|
||||
@@ -454,7 +457,7 @@ const normalizeChunksFilter = (chunks) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {undefined | GetCacheGroups | Record<string, false | string | RegExp | OptimizationSplitChunksGetCacheGroups | OptimizationSplitChunksCacheGroup>} cacheGroups the cache group options
|
||||
* @param {undefined | GetCacheGroups | Record<string, false | string | RegExp | RawGetCacheGroups | OptimizationSplitChunksCacheGroup>} cacheGroups the cache group options
|
||||
* @param {DefaultSizeTypes} defaultSizeTypes the default size types
|
||||
* @returns {GetCacheGroups} a function to get the cache groups
|
||||
*/
|
||||
@@ -478,6 +481,7 @@ const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
|
||||
}
|
||||
});
|
||||
} else if (typeof option === "function") {
|
||||
/** @type {WeakMap<OptimizationSplitChunksCacheGroup, CacheGroupSource>} */
|
||||
const cache = new WeakMap();
|
||||
handlers.push((module, context, results) => {
|
||||
const result = option(module);
|
||||
@@ -530,6 +534,8 @@ const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
|
||||
return () => null;
|
||||
};
|
||||
|
||||
/** @typedef {(module: Module, context: CacheGroupsContext) => boolean} CheckTestFn */
|
||||
|
||||
/**
|
||||
* @param {OptimizationSplitChunksCacheGroup["test"]} test test option
|
||||
* @param {Module} module the module
|
||||
@@ -553,6 +559,8 @@ const checkTest = (test, module, context) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @typedef {(type: string) => boolean} CheckModuleTypeFn */
|
||||
|
||||
/**
|
||||
* @param {OptimizationSplitChunksCacheGroup["type"]} test type option
|
||||
* @param {Module} module the module
|
||||
@@ -574,6 +582,8 @@ const checkModuleType = (test, module) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
/** @typedef {(layer: string | null) => boolean} CheckModuleLayerFn */
|
||||
|
||||
/**
|
||||
* @param {OptimizationSplitChunksCacheGroup["layer"]} test type option
|
||||
* @param {Module} module the module
|
||||
@@ -868,7 +878,7 @@ module.exports = class SplitChunksPlugin {
|
||||
index <<= ONE;
|
||||
}
|
||||
/**
|
||||
* @param {Iterable<Chunk>} chunks list of chunks
|
||||
* @param {Iterable<Chunk, undefined, undefined>} chunks list of chunks
|
||||
* @returns {bigint | Chunk} key of the chunks
|
||||
*/
|
||||
const getKey = (chunks) => {
|
||||
@@ -921,6 +931,7 @@ module.exports = class SplitChunksPlugin {
|
||||
*/
|
||||
const groupChunksByExports = (module) => {
|
||||
const exportsInfo = moduleGraph.getExportsInfo(module);
|
||||
/** @type {Map<string, Chunk[]>} */
|
||||
const groupedByUsedExports = new Map();
|
||||
for (const chunk of chunkGraph.getModuleChunksIterable(module)) {
|
||||
const key = exportsInfo.getUsageKey(chunk.runtime);
|
||||
@@ -1082,7 +1093,8 @@ module.exports = class SplitChunksPlugin {
|
||||
* @property {bigint | Chunk} key a key of the list
|
||||
*/
|
||||
|
||||
/** @type {WeakMap<ChunkSet | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
|
||||
/** @typedef {WeakMap<ChunkFilterFn, SelectedChunksResult>} ChunkMap */
|
||||
/** @type {WeakMap<ChunkSet | Chunk, ChunkMap>} */
|
||||
const selectedChunksCacheByChunksSet = new WeakMap();
|
||||
|
||||
/**
|
||||
@@ -1095,6 +1107,7 @@ module.exports = class SplitChunksPlugin {
|
||||
const getSelectedChunks = (chunks, chunkFilter) => {
|
||||
let entry = selectedChunksCacheByChunksSet.get(chunks);
|
||||
if (entry === undefined) {
|
||||
/** @type {ChunkMap} */
|
||||
entry = new WeakMap();
|
||||
selectedChunksCacheByChunksSet.set(chunks, entry);
|
||||
}
|
||||
@@ -1392,7 +1405,9 @@ module.exports = class SplitChunksPlugin {
|
||||
|
||||
while (chunksInfoMap.size > 0) {
|
||||
// Find best matching entry
|
||||
/** @type {undefined | string} */
|
||||
let bestEntryKey;
|
||||
/** @type {undefined | ChunksInfoItem} */
|
||||
let bestEntry;
|
||||
for (const pair of chunksInfoMap) {
|
||||
const key = pair[0];
|
||||
@@ -1471,6 +1486,7 @@ module.exports = class SplitChunksPlugin {
|
||||
item.cacheGroup._conditionalEnforce &&
|
||||
checkMinSize(item.sizes, item.cacheGroup.enforceSizeThreshold);
|
||||
|
||||
/** @type {Set<Chunk>} */
|
||||
const usedChunks = new Set(item.chunks);
|
||||
|
||||
// Check if maxRequests condition can be fulfilled
|
||||
@@ -1533,6 +1549,7 @@ module.exports = class SplitChunksPlugin {
|
||||
usedChunks.size === 1
|
||||
) {
|
||||
const [chunk] = usedChunks;
|
||||
/** @type {SplitChunksSizes} */
|
||||
const chunkSizes = Object.create(null);
|
||||
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
|
||||
if (!item.modules.has(module)) {
|
||||
@@ -1763,6 +1780,7 @@ module.exports = class SplitChunksPlugin {
|
||||
return key;
|
||||
},
|
||||
getSize(module) {
|
||||
/** @type {Sizes} */
|
||||
const size = Object.create(null);
|
||||
for (const key of module.getSourceTypes()) {
|
||||
size[key] = module.size(key);
|
||||
|
||||
Reference in New Issue
Block a user