source: imaps-frontend/node_modules/webpack/lib/FlagEntryExportAsUsedPlugin.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

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