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

Method apply

lib/async-modules/InferAsyncModulesPlugin.js:21–51  ·  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

19 * @returns {void}
20 */
21 apply(compiler) {
22 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
23 const { moduleGraph } = compilation;
24 compilation.hooks.finishModules.tap(PLUGIN_NAME, (modules) => {
25 /** @type {Set<Module>} */
26 const queue = new Set();
27 for (const module of modules) {
28 if (module.buildMeta && module.buildMeta.async) {
29 queue.add(module);
30 }
31 }
32 for (const module of queue) {
33 moduleGraph.setAsync(module);
34 for (const [
35 originModule,
36 connections
37 ] of moduleGraph.getIncomingConnectionsByOriginModule(module)) {
38 if (
39 connections.some(
40 (c) =>
41 c.dependency instanceof HarmonyImportDependency &&
42 c.isTargetActive(undefined)
43 )
44 ) {
45 queue.add(/** @type {Module} */ (originModule));
46 }
47 }
48 }
49 });
50 });
51 }
52}
53
54module.exports = InferAsyncModulesPlugin;

Callers

nothing calls this directly

Calls 5

tapMethod · 0.80
setAsyncMethod · 0.80
isTargetActiveMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected