source: frontend/node_modules/webpack/lib/FlagEntryExportAsUsedPlugin.js@ ae6cd79

Last change on this file since ae6cd79 was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 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
8const { getEntryRuntime } = require("./util/runtime");
9
10/** @typedef {import("./Compiler")} Compiler */
11
12const PLUGIN_NAME = "FlagEntryExportAsUsedPlugin";
13
14class FlagEntryExportAsUsedPlugin {
15 /**
16 * Creates an instance of FlagEntryExportAsUsedPlugin.
17 * @param {boolean} nsObjectUsed true, if the ns object is used
18 * @param {string} explanation explanation for the reason
19 */
20 constructor(nsObjectUsed, explanation) {
21 this.nsObjectUsed = nsObjectUsed;
22 this.explanation = explanation;
23 }
24
25 /**
26 * Applies the plugin by registering its hooks on the compiler.
27 * @param {Compiler} compiler the compiler instance
28 * @returns {void}
29 */
30 apply(compiler) {
31 compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
32 const moduleGraph = compilation.moduleGraph;
33 compilation.hooks.seal.tap(PLUGIN_NAME, () => {
34 for (const [
35 entryName,
36 { dependencies: deps, options }
37 ] of compilation.entries) {
38 const runtime = getEntryRuntime(compilation, entryName, options);
39 for (const dep of deps) {
40 const module = moduleGraph.getModule(dep);
41 if (module) {
42 const exportsInfo = moduleGraph.getExportsInfo(module);
43 if (this.nsObjectUsed) {
44 exportsInfo.setUsedInUnknownWay(runtime);
45 } else {
46 exportsInfo.setAllKnownExportsUsed(runtime);
47 }
48 moduleGraph.addExtraReason(module, this.explanation);
49 }
50 }
51 }
52 });
53 });
54 }
55}
56
57module.exports = FlagEntryExportAsUsedPlugin;
Note: See TracBrowser for help on using the repository browser.