MCPcopy
hub / github.com/webpack/webpack / apply

Method apply

lib/FlagAllModulesAsUsedPlugin.js:30–49  ·  view source on GitHub ↗

* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

28 * @returns {void}
29 */
30 apply(compiler) {
31 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
32 const moduleGraph = compilation.moduleGraph;
33 compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, (modules) => {
34 /** @type {RuntimeSpec} */
35 let runtime;
36 for (const [name, { options }] of compilation.entries) {
37 runtime = mergeRuntimeOwned(
38 runtime,
39 getEntryRuntime(compilation, name, options)
40 );
41 }
42 for (const module of modules) {
43 const exportsInfo = moduleGraph.getExportsInfo(module);
44 exportsInfo.setUsedInUnknownWay(runtime);
45 moduleGraph.addExtraReason(module, this.explanation);
46 }
47 });
48 });
49 }
50}
51
52module.exports = FlagAllModulesAsUsedPlugin;

Callers

nothing calls this directly

Calls 6

mergeRuntimeOwnedFunction · 0.85
getEntryRuntimeFunction · 0.85
tapMethod · 0.80
getExportsInfoMethod · 0.80
addExtraReasonMethod · 0.80
setUsedInUnknownWayMethod · 0.45

Tested by

no test coverage detected