Last change
on this file since 6a80231 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
---|
9 |
|
---|
10 | /** @typedef {import("../Compiler")} Compiler */
|
---|
11 | /** @typedef {import("../Module")} Module */
|
---|
12 |
|
---|
13 | class InferAsyncModulesPlugin {
|
---|
14 | /**
|
---|
15 | * Apply the plugin
|
---|
16 | * @param {Compiler} compiler the compiler instance
|
---|
17 | * @returns {void}
|
---|
18 | */
|
---|
19 | apply(compiler) {
|
---|
20 | compiler.hooks.compilation.tap("InferAsyncModulesPlugin", compilation => {
|
---|
21 | const { moduleGraph } = compilation;
|
---|
22 | compilation.hooks.finishModules.tap(
|
---|
23 | "InferAsyncModulesPlugin",
|
---|
24 | 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(originModule);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | );
|
---|
51 | });
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | module.exports = InferAsyncModulesPlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.