MCPcopy
hub / github.com/webpack/webpack / addRuntimeModule

Method addRuntimeModule

lib/Compilation.js:4322–4367  ·  view source on GitHub ↗

* Adds runtime module. * @param {Chunk} chunk target chunk * @param {RuntimeModule} module runtime module * @param {ChunkGraph} chunkGraph the chunk graph * @returns {void}

(chunk, module, chunkGraph = this.chunkGraph)

Source from the content-addressed store, hash-verified

4320 * @returns {void}
4321 */
4322 addRuntimeModule(chunk, module, chunkGraph = this.chunkGraph) {
4323 // Deprecated ModuleGraph association
4324 if (this._backCompat) {
4325 ModuleGraph.setModuleGraphForModule(module, this.moduleGraph);
4326 }
4327
4328 // add it to the list
4329 this.modules.add(module);
4330 this._modules.set(module.identifier(), module);
4331
4332 // connect to the chunk graph
4333 chunkGraph.connectChunkAndModule(chunk, module);
4334 chunkGraph.connectChunkAndRuntimeModule(chunk, module);
4335 if (module.fullHash) {
4336 chunkGraph.addFullHashModuleToChunk(chunk, module);
4337 } else if (module.dependentHash) {
4338 chunkGraph.addDependentHashModuleToChunk(chunk, module);
4339 }
4340
4341 // attach runtime module
4342 module.attach(this, chunk, chunkGraph);
4343
4344 // Setup internals
4345 const exportsInfo = this.moduleGraph.getExportsInfo(module);
4346 exportsInfo.setHasProvideInfo();
4347 if (typeof chunk.runtime === "string") {
4348 exportsInfo.setUsedForSideEffectsOnly(chunk.runtime);
4349 } else if (chunk.runtime === undefined) {
4350 exportsInfo.setUsedForSideEffectsOnly(undefined);
4351 } else {
4352 for (const runtime of chunk.runtime) {
4353 exportsInfo.setUsedForSideEffectsOnly(runtime);
4354 }
4355 }
4356 chunkGraph.addModuleRuntimeRequirements(
4357 module,
4358 chunk.runtime,
4359 new Set([RuntimeGlobals.requireScope])
4360 );
4361
4362 // runtime modules don't need ids
4363 chunkGraph.setModuleId(module, "");
4364
4365 // Call hook
4366 this.hooks.runtimeModule.call(module, chunk);
4367 }
4368
4369 /**
4370 * If `module` is passed, `loc` and `request` must also be passed.

Callers 15

applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
handlerMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
handlerMethod · 0.80
handlerMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80
applyMethod · 0.80

Calls 15

connectChunkAndModuleMethod · 0.80
attachMethod · 0.80
getExportsInfoMethod · 0.80
setModuleIdMethod · 0.80
addMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected