MCPcopy
hub / github.com/webpack/webpack / assignAscendingModuleIds

Function assignAscendingModuleIds

lib/ids/IdHelpers.js:440–471  ·  view source on GitHub ↗
(usedIds, modules, compilation)

Source from the content-addressed store, hash-verified

438 * @returns {void}
439 */
440const assignAscendingModuleIds = (usedIds, modules, compilation) => {
441 const chunkGraph = compilation.chunkGraph;
442
443 let nextId = 0;
444 /** @type {(mod: Module) => void} */
445 let assignId;
446 if (usedIds.size > 0) {
447 /**
448 * Processes the provided module.
449 * @param {Module} module the module
450 */
451 assignId = (module) => {
452 if (chunkGraph.getModuleId(module) === null) {
453 while (usedIds.has(String(nextId))) nextId++;
454 chunkGraph.setModuleId(module, nextId++);
455 }
456 };
457 } else {
458 /**
459 * Processes the provided module.
460 * @param {Module} module the module
461 */
462 assignId = (module) => {
463 if (chunkGraph.getModuleId(module) === null) {
464 chunkGraph.setModuleId(module, nextId++);
465 }
466 };
467 }
468 for (const module of modules) {
469 assignId(module);
470 }
471};
472
473/**
474 * Assign ascending chunk ids.

Callers 3

applyMethod · 0.85
applyMethod · 0.85
applyMethod · 0.85

Calls 3

getModuleIdMethod · 0.80
setModuleIdMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected