MCPcopy
hub / github.com/webpack/webpack / runIteration

Method runIteration

lib/Compilation.js:3989–4073  ·  lib/Compilation.js::Compilation.runIteration
()

Source from the content-addressed store, hash-verified

3987 /** @type {NotCodeGeneratedModules | undefined} */
3988 let notCodeGeneratedModules;
3989 const runIteration = () => {
3990 /** @type {CodeGenerationJobs} */
3991 let delayedJobs = [];
3992 /** @type {Set<Module>} */
3993 let delayedModules = new Set();
3994 asyncLib.eachLimit(
3995 jobs,
3996 this.options.parallelism,
3997 (job, callback) => {
3998 const { module } = job;
3999 const { codeGenerationDependencies } = module;
4000 if (
4001 codeGenerationDependencies !== undefined &&
4002 (notCodeGeneratedModules === undefined ||
4003 codeGenerationDependencies.some((dep) => {
4004 const referencedModule = /** @type {Module} */ (
4005 moduleGraph.getModule(dep)
4006 );
4007 return /** @type {NotCodeGeneratedModules} */ (
4008 notCodeGeneratedModules
4009 ).has(referencedModule);
4010 }))
4011 ) {
4012 delayedJobs.push(job);
4013 delayedModules.add(module);
4014 return callback();
4015 }
4016 const { hash, runtime, runtimes } = job;
4017 this._codeGenerationModule(
4018 module,
4019 runtime,
4020 runtimes,
4021 hash,
4022 dependencyTemplates,
4023 chunkGraph,
4024 moduleGraph,
4025 runtimeTemplate,
4026 errors,
4027 results,
4028 (err, codeGenerated) => {
4029 if (codeGenerated) statModulesGenerated++;
4030 else statModulesFromCache++;
4031 callback(err);
4032 }
4033 );
4034 },
4035 (err) => {
4036 if (err) return callback(/** @type {WebpackError} */ (err));
4037 if (delayedJobs.length > 0) {
4038 if (delayedJobs.length === jobs.length) {
4039 return callback(
4040 /** @type {WebpackError} */ (
4041 new Error(
4042 `Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
4043 delayedModules,
4044 (m) => m.identifier()
4045 ).join(class="st">", ")}`
4046 )

Callers

nothing calls this directly

Calls 10

_codeGenerationModuleMethod · 0.95
compareSelectFunction · 0.85
sortMethod · 0.80
logMethod · 0.80
callbackFunction · 0.50
getModuleMethod · 0.45
hasMethod · 0.45
pushMethod · 0.45
addMethod · 0.45
identifierMethod · 0.45

Tested by

no test coverage detected