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

Method apply

lib/FlagEntryExportAsUsedPlugin.js:32–56  ·  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

30 * @returns {void}
31 */
32 apply(compiler) {
33 compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
34 const moduleGraph = compilation.moduleGraph;
35 compilation.hooks.seal.tap(PLUGIN_NAME, () => {
36 for (const [
37 entryName,
38 { dependencies: deps, options }
39 ] of compilation.entries) {
40 const runtime = getEntryRuntime(compilation, entryName, options);
41 for (const dep of deps) {
42 const module = moduleGraph.getModule(dep);
43 if (module) {
44 const exportsInfo = moduleGraph.getExportsInfo(module);
45 if (this.nsObjectUsed) {
46 exportsInfo.setUsedInUnknownWay(runtime);
47 } else {
48 exportsInfo.setAllKnownExportsUsed(runtime);
49 }
50 moduleGraph.addExtraReason(module, this.explanation);
51 }
52 }
53 }
54 });
55 });
56 }
57}
58
59module.exports = FlagEntryExportAsUsedPlugin;

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected