* Applies the plugin by registering its hooks on the compiler. * @param {Compiler} compiler the compiler instance * @returns {void}
(compiler)
| 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 | |
| 54 | module.exports = InferAsyncModulesPlugin; |
nothing calls this directly
no test coverage detected