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:
532
node_modules/webpack/lib/Compilation.js
generated
vendored
532
node_modules/webpack/lib/Compilation.js
generated
vendored
@@ -286,7 +286,7 @@ const { isSourceEqual } = require("./util/source");
|
||||
|
||||
/**
|
||||
* @typedef {object} LogEntry
|
||||
* @property {string} type
|
||||
* @property {keyof LogType} type
|
||||
* @property {EXPECTED_ANY[]=} args
|
||||
* @property {number} time
|
||||
* @property {string[]=} trace
|
||||
@@ -403,11 +403,11 @@ const { isSourceEqual } = require("./util/source");
|
||||
|
||||
/** @typedef {KnownCreateStatsOptionsContext & Record<string, EXPECTED_ANY>} CreateStatsOptionsContext */
|
||||
|
||||
/** @typedef {{ module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[]}} CodeGenerationJob */
|
||||
/** @typedef {{ module: Module, hash: string, runtime: RuntimeSpec, runtimes: RuntimeSpec[] }} CodeGenerationJob */
|
||||
|
||||
/** @typedef {CodeGenerationJob[]} CodeGenerationJobs */
|
||||
|
||||
/** @typedef {{javascript: ModuleTemplate}} ModuleTemplates */
|
||||
/** @typedef {{ javascript: ModuleTemplate }} ModuleTemplates */
|
||||
|
||||
/** @typedef {Set<Module>} NotCodeGeneratedModules */
|
||||
|
||||
@@ -491,6 +491,8 @@ const compareErrors = concatComparators(byModule, byLocation, byMessage);
|
||||
* @typedef {Module & { restoreFromUnsafeCache?: (unsafeCacheData: UnsafeCacheData, moduleFactory: ModuleFactory, compilationParams: CompilationParams) => void }} ModuleWithRestoreFromUnsafeCache
|
||||
*/
|
||||
|
||||
/** @typedef {(module: Module) => boolean} UnsafeCachePredicate */
|
||||
|
||||
/** @type {WeakMap<Dependency, ModuleWithRestoreFromUnsafeCache | null>} */
|
||||
const unsafeCacheDependencies = new WeakMap();
|
||||
|
||||
@@ -514,22 +516,25 @@ class Compilation {
|
||||
/** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
|
||||
const processAssetsHook = new AsyncSeriesHook(["assets"]);
|
||||
|
||||
/** @type {Set<string>} */
|
||||
let savedAssets = new Set();
|
||||
/**
|
||||
* @param {CompilationAssets} assets assets
|
||||
* @returns {CompilationAssets} new assets
|
||||
*/
|
||||
const popNewAssets = (assets) => {
|
||||
/** @type {undefined | CompilationAssets} */
|
||||
let newAssets;
|
||||
for (const file of Object.keys(assets)) {
|
||||
if (savedAssets.has(file)) continue;
|
||||
if (newAssets === undefined) {
|
||||
newAssets = Object.create(null);
|
||||
}
|
||||
newAssets[file] = assets[file];
|
||||
/** @type {CompilationAssets} */
|
||||
(newAssets)[file] = assets[file];
|
||||
savedAssets.add(file);
|
||||
}
|
||||
return newAssets;
|
||||
return /** @type {CompilationAssets} */ (newAssets);
|
||||
};
|
||||
processAssetsHook.intercept({
|
||||
name: "Compilation",
|
||||
@@ -1257,7 +1262,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
this._codeGenerationCache = this.getCache("Compilation/codeGeneration");
|
||||
|
||||
const unsafeCache = options.module.unsafeCache;
|
||||
/** @type {boolean} */
|
||||
this._unsafeCache = Boolean(unsafeCache);
|
||||
/** @type {UnsafeCachePredicate} */
|
||||
this._unsafeCachePredicate =
|
||||
typeof unsafeCache === "function" ? unsafeCache : () => true;
|
||||
}
|
||||
@@ -1347,6 +1354,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
);
|
||||
}
|
||||
}
|
||||
/** @type {LogEntry["trace"]} */
|
||||
let trace;
|
||||
switch (type) {
|
||||
case LogType.warn:
|
||||
@@ -1519,7 +1527,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
/**
|
||||
* Attempts to search for a module by its identifier
|
||||
* @param {string} identifier identifier (usually path) for module
|
||||
* @returns {Module|undefined} attempt to search for module and return it, else undefined
|
||||
* @returns {Module | undefined} attempt to search for module and return it, else undefined
|
||||
*/
|
||||
findModule(identifier) {
|
||||
return this._modules.get(identifier);
|
||||
@@ -2292,6 +2300,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
(originModule)
|
||||
);
|
||||
if (creatingModuleDuringBuildSet === undefined) {
|
||||
/** @type {Set<Module>} */
|
||||
creatingModuleDuringBuildSet = new Set();
|
||||
this.creatingModuleDuringBuild.set(
|
||||
/** @type {Module} */
|
||||
@@ -2598,7 +2607,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
this.moduleGraph.setModuleMemCaches(this.moduleMemCaches);
|
||||
}
|
||||
const { moduleGraph, moduleMemCaches } = this;
|
||||
/** @type {Set<Module>} */
|
||||
const affectedModules = new Set();
|
||||
/** @type {Set<Module>} */
|
||||
const infectedModules = new Set();
|
||||
let statNew = 0;
|
||||
let statChanged = 0;
|
||||
@@ -2714,6 +2725,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
}
|
||||
return affected;
|
||||
};
|
||||
/** @type {Set<Module>} */
|
||||
const directOnlyInfectedModules = new Set();
|
||||
for (const module of infectedModules) {
|
||||
for (const [
|
||||
@@ -2732,6 +2744,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
}
|
||||
}
|
||||
for (const module of directOnlyInfectedModules) infectedModules.add(module);
|
||||
/** @type {Set<Module>} */
|
||||
const directOnlyAffectModules = new Set();
|
||||
for (const module of affectedModules) {
|
||||
for (const [
|
||||
@@ -2994,6 +3007,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
* @param {(profile: ModuleProfile) => number} getParallelism get parallelism callback
|
||||
*/
|
||||
const logByLoadersSummary = (category, getDuration, getParallelism) => {
|
||||
/** @type {Map<string, { module: Module, profile: ModuleProfile }[]>} */
|
||||
const map = new Map();
|
||||
for (const [module, profile] of modulesWithProfiles) {
|
||||
const list = getOrInsert(
|
||||
@@ -3205,6 +3219,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
this.chunkGroups.push(entrypoint);
|
||||
connectChunkGroupAndChunk(entrypoint, chunk);
|
||||
|
||||
/** @type {Set<Module>} */
|
||||
const entryModules = new Set();
|
||||
for (const dep of [...this.globalEntry.dependencies, ...dependencies]) {
|
||||
entrypoint.addOrigin(
|
||||
@@ -3252,6 +3267,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||
modulesList.push(module);
|
||||
}
|
||||
}
|
||||
/** @type {Set<Chunk>} */
|
||||
const runtimeChunks = new Set();
|
||||
outer: for (const [
|
||||
name,
|
||||
@@ -3625,6 +3641,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
const runIteration = () => {
|
||||
/** @type {CodeGenerationJobs} */
|
||||
let delayedJobs = [];
|
||||
/** @type {Set<Module>} */
|
||||
let delayedModules = new Set();
|
||||
asyncLib.eachLimit(
|
||||
jobs,
|
||||
@@ -3668,7 +3685,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
);
|
||||
},
|
||||
(err) => {
|
||||
if (err) return callback(err);
|
||||
if (err) return callback(/** @type {WebpackError} */ (err));
|
||||
if (delayedJobs.length > 0) {
|
||||
if (delayedJobs.length === jobs.length) {
|
||||
return callback(
|
||||
@@ -3746,6 +3763,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
);
|
||||
cache.get((err, cachedResult) => {
|
||||
if (err) return callback(/** @type {WebpackError} */ (err));
|
||||
/** @type {CodeGenerationResult} */
|
||||
let result;
|
||||
if (!cachedResult) {
|
||||
try {
|
||||
@@ -3845,6 +3863,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/** @type {RuntimeRequirements} */
|
||||
let set;
|
||||
const runtimeRequirements =
|
||||
codeGenerationResults.getRuntimeRequirements(module, runtime);
|
||||
@@ -4407,6 +4426,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
hashDigestLength,
|
||||
errors
|
||||
) {
|
||||
/** @type {string} */
|
||||
let moduleHashDigest;
|
||||
try {
|
||||
const moduleHash = createHash(hashFunction);
|
||||
@@ -4529,6 +4549,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
// If there are any references between chunks
|
||||
// make sure to follow these chains
|
||||
if (remaining > 0) {
|
||||
/** @type {Chunk[]} */
|
||||
const readyChunks = [];
|
||||
for (const chunk of runtimeChunks) {
|
||||
const hasFullHashModules =
|
||||
@@ -4555,6 +4576,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||
}
|
||||
// If there are still remaining references we have cycles and want to create a warning
|
||||
if (remaining > 0) {
|
||||
/** @type {RuntimeChunkInfo[]} */
|
||||
const circularRuntimeChunkInfo = [];
|
||||
for (const info of runtimeChunksMap.values()) {
|
||||
if (info.remaining !== 0) {
|
||||
@@ -4574,6 +4596,7 @@ This prevents using hashes of each other and should be avoided.`);
|
||||
}
|
||||
this.logger.timeEnd("hashing: sort chunks");
|
||||
|
||||
/** @type {Set<Chunk>} */
|
||||
const fullHashChunks = new Set();
|
||||
/** @type {CodeGenerationJobs} */
|
||||
const codeGenerationJobs = [];
|
||||
@@ -4702,7 +4725,7 @@ This prevents using hashes of each other and should be avoided.`);
|
||||
).hash = moduleHashDigest;
|
||||
}
|
||||
const chunkHash = createHash(hashFunction);
|
||||
chunkHash.update(chunk.hash);
|
||||
chunkHash.update(/** @type {string} */ (chunk.hash));
|
||||
chunkHash.update(this.hash);
|
||||
const chunkHashDigest = chunkHash.digest(hashDigest);
|
||||
chunk.hash = chunkHashDigest;
|
||||
@@ -4873,6 +4896,7 @@ This prevents using hashes of each other and should be avoided.`);
|
||||
const related = info.related;
|
||||
if (!related) continue;
|
||||
const entry = related[key];
|
||||
/** @type {string | string[]} */
|
||||
let newEntry;
|
||||
if (Array.isArray(entry)) {
|
||||
newEntry = entry.map((x) => (x === file ? newFile : x));
|
||||
@@ -5026,8 +5050,9 @@ This prevents using hashes of each other and should be avoided.`);
|
||||
*/
|
||||
createChunkAssets(callback) {
|
||||
const outputOptions = this.outputOptions;
|
||||
/** @type {WeakMap<Source, CachedSource>} */
|
||||
const cachedSourceMap = new WeakMap();
|
||||
/** @type {Map<string, {hash: string, source: Source, chunk: Chunk}>} */
|
||||
/** @type {Map<string, { hash: string, source: Source, chunk: Chunk }>} */
|
||||
const alreadyWrittenFiles = new Map();
|
||||
|
||||
asyncLib.forEachLimit(
|
||||
@@ -5392,254 +5417,277 @@ This prevents using hashes of each other and should be avoided.`);
|
||||
};
|
||||
|
||||
// Generate code for all aggregated modules
|
||||
asyncLib.eachLimit(modules, 10, codeGen, (err) => {
|
||||
if (err) return callback(err);
|
||||
reportErrors();
|
||||
|
||||
// for backward-compat temporary set the chunk graph
|
||||
// TODO webpack 6
|
||||
const old = this.chunkGraph;
|
||||
this.chunkGraph = chunkGraph;
|
||||
this.processRuntimeRequirements({
|
||||
chunkGraph,
|
||||
modules,
|
||||
chunks,
|
||||
codeGenerationResults,
|
||||
chunkGraphEntries: chunks
|
||||
});
|
||||
this.chunkGraph = old;
|
||||
|
||||
const runtimeModules =
|
||||
chunkGraph.getChunkRuntimeModulesIterable(chunk);
|
||||
|
||||
// Hash runtime modules
|
||||
for (const module of runtimeModules) {
|
||||
modules.add(module);
|
||||
this._createModuleHash(
|
||||
module,
|
||||
chunkGraph,
|
||||
runtime,
|
||||
hashFunction,
|
||||
runtimeTemplate,
|
||||
hashDigest,
|
||||
hashDigestLength,
|
||||
errors
|
||||
);
|
||||
}
|
||||
|
||||
// Generate code for all runtime modules
|
||||
asyncLib.eachLimit(runtimeModules, 10, codeGen, (err) => {
|
||||
asyncLib.eachLimit(
|
||||
/** @type {import("neo-async").IterableCollection<Module>} */ (
|
||||
/** @type {unknown} */ (modules)
|
||||
),
|
||||
10,
|
||||
codeGen,
|
||||
(err) => {
|
||||
if (err) return callback(err);
|
||||
reportErrors();
|
||||
|
||||
/** @type {Map<Module, ExecuteModuleArgument>} */
|
||||
const moduleArgumentsMap = new Map();
|
||||
/** @type {Map<string, ExecuteModuleArgument>} */
|
||||
const moduleArgumentsById = new Map();
|
||||
|
||||
/** @type {ExecuteModuleResult["fileDependencies"]} */
|
||||
const fileDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["contextDependencies"]} */
|
||||
const contextDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["missingDependencies"]} */
|
||||
const missingDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["buildDependencies"]} */
|
||||
const buildDependencies = new LazySet();
|
||||
|
||||
/** @type {ExecuteModuleResult["assets"]} */
|
||||
const assets = new Map();
|
||||
|
||||
let cacheable = true;
|
||||
|
||||
/** @type {ExecuteModuleContext} */
|
||||
const context = {
|
||||
assets,
|
||||
__webpack_require__: undefined,
|
||||
chunk,
|
||||
chunkGraph
|
||||
};
|
||||
|
||||
// Prepare execution
|
||||
asyncLib.eachLimit(
|
||||
// for backward-compat temporary set the chunk graph
|
||||
// TODO webpack 6
|
||||
const old = this.chunkGraph;
|
||||
this.chunkGraph = chunkGraph;
|
||||
this.processRuntimeRequirements({
|
||||
chunkGraph,
|
||||
modules,
|
||||
chunks,
|
||||
codeGenerationResults,
|
||||
chunkGraphEntries: chunks
|
||||
});
|
||||
this.chunkGraph = old;
|
||||
|
||||
const runtimeModules =
|
||||
chunkGraph.getChunkRuntimeModulesIterable(chunk);
|
||||
|
||||
// Hash runtime modules
|
||||
for (const module of runtimeModules) {
|
||||
modules.add(module);
|
||||
this._createModuleHash(
|
||||
module,
|
||||
chunkGraph,
|
||||
runtime,
|
||||
hashFunction,
|
||||
runtimeTemplate,
|
||||
hashDigest,
|
||||
hashDigestLength,
|
||||
errors
|
||||
);
|
||||
}
|
||||
|
||||
// Generate code for all runtime modules
|
||||
asyncLib.eachLimit(
|
||||
/** @type {import("neo-async").IterableCollection<RuntimeModule>} */ (
|
||||
runtimeModules
|
||||
),
|
||||
10,
|
||||
(module, callback) => {
|
||||
const codeGenerationResult = codeGenerationResults.get(
|
||||
module,
|
||||
runtime
|
||||
);
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
const moduleArgument = {
|
||||
module,
|
||||
codeGenerationResult,
|
||||
moduleObject: undefined
|
||||
};
|
||||
moduleArgumentsMap.set(module, moduleArgument);
|
||||
moduleArgumentsById.set(module.identifier(), moduleArgument);
|
||||
module.addCacheDependencies(
|
||||
fileDependencies,
|
||||
contextDependencies,
|
||||
missingDependencies,
|
||||
buildDependencies
|
||||
);
|
||||
if (
|
||||
/** @type {BuildInfo} */ (module.buildInfo).cacheable ===
|
||||
false
|
||||
) {
|
||||
cacheable = false;
|
||||
}
|
||||
if (module.buildInfo && module.buildInfo.assets) {
|
||||
const { assets: moduleAssets, assetsInfo } = module.buildInfo;
|
||||
for (const assetName of Object.keys(moduleAssets)) {
|
||||
assets.set(assetName, {
|
||||
source: moduleAssets[assetName],
|
||||
info: assetsInfo ? assetsInfo.get(assetName) : undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
this.hooks.prepareModuleExecution.callAsync(
|
||||
moduleArgument,
|
||||
context,
|
||||
callback
|
||||
);
|
||||
},
|
||||
codeGen,
|
||||
(err) => {
|
||||
if (err) return callback(err);
|
||||
reportErrors();
|
||||
|
||||
/** @type {ExecuteModuleExports | undefined} */
|
||||
let exports;
|
||||
try {
|
||||
const {
|
||||
strictModuleErrorHandling,
|
||||
strictModuleExceptionHandling
|
||||
} = this.outputOptions;
|
||||
/** @type {Map<Module, ExecuteModuleArgument>} */
|
||||
const moduleArgumentsMap = new Map();
|
||||
/** @type {Map<string, ExecuteModuleArgument>} */
|
||||
const moduleArgumentsById = new Map();
|
||||
|
||||
/** @type {WebpackRequire} */
|
||||
const __webpack_require__ = (id) => {
|
||||
const cached = moduleCache[id];
|
||||
if (cached !== undefined) {
|
||||
if (cached.error) throw cached.error;
|
||||
return cached.exports;
|
||||
}
|
||||
const moduleArgument = moduleArgumentsById.get(id);
|
||||
return __webpack_require_module__(
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
(moduleArgument),
|
||||
id
|
||||
);
|
||||
};
|
||||
const interceptModuleExecution = (__webpack_require__[
|
||||
/** @type {"i"} */
|
||||
(
|
||||
RuntimeGlobals.interceptModuleExecution.replace(
|
||||
`${RuntimeGlobals.require}.`,
|
||||
""
|
||||
)
|
||||
)
|
||||
] = /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
|
||||
const moduleCache = (__webpack_require__[
|
||||
/** @type {"c"} */ (
|
||||
RuntimeGlobals.moduleCache.replace(
|
||||
`${RuntimeGlobals.require}.`,
|
||||
""
|
||||
)
|
||||
)
|
||||
] = /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
|
||||
/** @type {ExecuteModuleResult["fileDependencies"]} */
|
||||
const fileDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["contextDependencies"]} */
|
||||
const contextDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["missingDependencies"]} */
|
||||
const missingDependencies = new LazySet();
|
||||
/** @type {ExecuteModuleResult["buildDependencies"]} */
|
||||
const buildDependencies = new LazySet();
|
||||
|
||||
context.__webpack_require__ = __webpack_require__;
|
||||
/** @type {ExecuteModuleResult["assets"]} */
|
||||
const assets = new Map();
|
||||
|
||||
/**
|
||||
* @param {ExecuteModuleArgument} moduleArgument the module argument
|
||||
* @param {string=} id id
|
||||
* @returns {ExecuteModuleExports} exports
|
||||
*/
|
||||
const __webpack_require_module__ = (moduleArgument, id) => {
|
||||
/** @type {ExecuteOptions} */
|
||||
const execOptions = {
|
||||
id,
|
||||
module: {
|
||||
id,
|
||||
exports: {},
|
||||
loaded: false,
|
||||
error: undefined
|
||||
},
|
||||
require: __webpack_require__
|
||||
};
|
||||
for (const handler of interceptModuleExecution) {
|
||||
handler(execOptions);
|
||||
}
|
||||
const module = moduleArgument.module;
|
||||
this.buildTimeExecutedModules.add(module);
|
||||
const moduleObject = execOptions.module;
|
||||
moduleArgument.moduleObject = moduleObject;
|
||||
try {
|
||||
if (id) moduleCache[id] = moduleObject;
|
||||
let cacheable = true;
|
||||
|
||||
tryRunOrWebpackError(
|
||||
() =>
|
||||
this.hooks.executeModule.call(
|
||||
moduleArgument,
|
||||
context
|
||||
),
|
||||
"Compilation.hooks.executeModule"
|
||||
);
|
||||
moduleObject.loaded = true;
|
||||
return moduleObject.exports;
|
||||
} catch (execErr) {
|
||||
if (strictModuleExceptionHandling) {
|
||||
if (id) delete moduleCache[id];
|
||||
} else if (strictModuleErrorHandling) {
|
||||
moduleObject.error =
|
||||
/** @type {WebpackError} */
|
||||
(execErr);
|
||||
}
|
||||
if (!(/** @type {WebpackError} */ (execErr).module)) {
|
||||
/** @type {WebpackError} */
|
||||
(execErr).module = module;
|
||||
}
|
||||
throw execErr;
|
||||
}
|
||||
};
|
||||
|
||||
for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
|
||||
chunk
|
||||
)) {
|
||||
__webpack_require_module__(
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
(moduleArgumentsMap.get(runtimeModule))
|
||||
);
|
||||
}
|
||||
|
||||
exports = __webpack_require__(module.identifier());
|
||||
} catch (execErr) {
|
||||
const { message, stack, module } =
|
||||
/** @type {WebpackError} */
|
||||
(execErr);
|
||||
const err = new WebpackError(
|
||||
`Execution of module code from module graph (${
|
||||
/** @type {Module} */
|
||||
(module).readableIdentifier(this.requestShortener)
|
||||
}) failed: ${message}`,
|
||||
{ cause: execErr }
|
||||
);
|
||||
err.stack = stack;
|
||||
err.module = module;
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
exports,
|
||||
/** @type {ExecuteModuleContext} */
|
||||
const context = {
|
||||
assets,
|
||||
cacheable,
|
||||
fileDependencies,
|
||||
contextDependencies,
|
||||
missingDependencies,
|
||||
buildDependencies
|
||||
});
|
||||
__webpack_require__: undefined,
|
||||
chunk,
|
||||
chunkGraph
|
||||
};
|
||||
|
||||
// Prepare execution
|
||||
asyncLib.eachLimit(
|
||||
modules,
|
||||
10,
|
||||
(module, callback) => {
|
||||
const codeGenerationResult = codeGenerationResults.get(
|
||||
module,
|
||||
runtime
|
||||
);
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
const moduleArgument = {
|
||||
module,
|
||||
codeGenerationResult,
|
||||
moduleObject: undefined
|
||||
};
|
||||
moduleArgumentsMap.set(module, moduleArgument);
|
||||
moduleArgumentsById.set(
|
||||
module.identifier(),
|
||||
moduleArgument
|
||||
);
|
||||
module.addCacheDependencies(
|
||||
fileDependencies,
|
||||
contextDependencies,
|
||||
missingDependencies,
|
||||
buildDependencies
|
||||
);
|
||||
if (
|
||||
/** @type {BuildInfo} */ (module.buildInfo).cacheable ===
|
||||
false
|
||||
) {
|
||||
cacheable = false;
|
||||
}
|
||||
if (module.buildInfo && module.buildInfo.assets) {
|
||||
const { assets: moduleAssets, assetsInfo } =
|
||||
module.buildInfo;
|
||||
for (const assetName of Object.keys(moduleAssets)) {
|
||||
assets.set(assetName, {
|
||||
source: moduleAssets[assetName],
|
||||
info: assetsInfo
|
||||
? assetsInfo.get(assetName)
|
||||
: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
this.hooks.prepareModuleExecution.callAsync(
|
||||
moduleArgument,
|
||||
context,
|
||||
callback
|
||||
);
|
||||
},
|
||||
(err) => {
|
||||
if (err) return callback(/** @type {WebpackError} */ (err));
|
||||
|
||||
/** @type {ExecuteModuleExports | undefined} */
|
||||
let exports;
|
||||
try {
|
||||
const {
|
||||
strictModuleErrorHandling,
|
||||
strictModuleExceptionHandling
|
||||
} = this.outputOptions;
|
||||
|
||||
/** @type {WebpackRequire} */
|
||||
const __webpack_require__ = (id) => {
|
||||
const cached = moduleCache[id];
|
||||
if (cached !== undefined) {
|
||||
if (cached.error) throw cached.error;
|
||||
return cached.exports;
|
||||
}
|
||||
const moduleArgument = moduleArgumentsById.get(id);
|
||||
return __webpack_require_module__(
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
(moduleArgument),
|
||||
id
|
||||
);
|
||||
};
|
||||
const interceptModuleExecution = (__webpack_require__[
|
||||
/** @type {"i"} */
|
||||
(
|
||||
RuntimeGlobals.interceptModuleExecution.replace(
|
||||
`${RuntimeGlobals.require}.`,
|
||||
""
|
||||
)
|
||||
)
|
||||
] = /** @type {NonNullable<WebpackRequire["i"]>} */ ([]));
|
||||
const moduleCache = (__webpack_require__[
|
||||
/** @type {"c"} */ (
|
||||
RuntimeGlobals.moduleCache.replace(
|
||||
`${RuntimeGlobals.require}.`,
|
||||
""
|
||||
)
|
||||
)
|
||||
] = /** @type {NonNullable<WebpackRequire["c"]>} */ ({}));
|
||||
|
||||
context.__webpack_require__ = __webpack_require__;
|
||||
|
||||
/**
|
||||
* @param {ExecuteModuleArgument} moduleArgument the module argument
|
||||
* @param {string=} id id
|
||||
* @returns {ExecuteModuleExports} exports
|
||||
*/
|
||||
const __webpack_require_module__ = (
|
||||
moduleArgument,
|
||||
id
|
||||
) => {
|
||||
/** @type {ExecuteOptions} */
|
||||
const execOptions = {
|
||||
id,
|
||||
module: {
|
||||
id,
|
||||
exports: {},
|
||||
loaded: false,
|
||||
error: undefined
|
||||
},
|
||||
require: __webpack_require__
|
||||
};
|
||||
for (const handler of interceptModuleExecution) {
|
||||
handler(execOptions);
|
||||
}
|
||||
const module = moduleArgument.module;
|
||||
this.buildTimeExecutedModules.add(module);
|
||||
const moduleObject = execOptions.module;
|
||||
moduleArgument.moduleObject = moduleObject;
|
||||
try {
|
||||
if (id) moduleCache[id] = moduleObject;
|
||||
|
||||
tryRunOrWebpackError(
|
||||
() =>
|
||||
this.hooks.executeModule.call(
|
||||
moduleArgument,
|
||||
context
|
||||
),
|
||||
"Compilation.hooks.executeModule"
|
||||
);
|
||||
moduleObject.loaded = true;
|
||||
return moduleObject.exports;
|
||||
} catch (execErr) {
|
||||
if (strictModuleExceptionHandling) {
|
||||
if (id) delete moduleCache[id];
|
||||
} else if (strictModuleErrorHandling) {
|
||||
moduleObject.error =
|
||||
/** @type {WebpackError} */
|
||||
(execErr);
|
||||
}
|
||||
if (!(/** @type {WebpackError} */ (execErr).module)) {
|
||||
/** @type {WebpackError} */
|
||||
(execErr).module = module;
|
||||
}
|
||||
throw execErr;
|
||||
}
|
||||
};
|
||||
|
||||
for (const runtimeModule of chunkGraph.getChunkRuntimeModulesInOrder(
|
||||
chunk
|
||||
)) {
|
||||
__webpack_require_module__(
|
||||
/** @type {ExecuteModuleArgument} */
|
||||
(moduleArgumentsMap.get(runtimeModule))
|
||||
);
|
||||
}
|
||||
|
||||
exports = __webpack_require__(module.identifier());
|
||||
} catch (execErr) {
|
||||
const { message, stack, module } =
|
||||
/** @type {WebpackError} */
|
||||
(execErr);
|
||||
const err = new WebpackError(
|
||||
`Execution of module code from module graph (${
|
||||
/** @type {Module} */
|
||||
(module).readableIdentifier(this.requestShortener)
|
||||
}) failed: ${message}`,
|
||||
{ cause: execErr }
|
||||
);
|
||||
err.stack = stack;
|
||||
err.module = module;
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
exports,
|
||||
assets,
|
||||
cacheable,
|
||||
fileDependencies,
|
||||
contextDependencies,
|
||||
missingDependencies,
|
||||
buildDependencies
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user