|
Last change
on this file since 9af201e was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.4 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 | const PLUGIN_NAME = "InferAsyncModulesPlugin";
|
|---|
| 14 |
|
|---|
| 15 | class InferAsyncModulesPlugin {
|
|---|
| 16 | /**
|
|---|
| 17 | * Applies the plugin by registering its hooks on the compiler.
|
|---|
| 18 | * @param {Compiler} compiler the compiler instance
|
|---|
| 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;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.