source: frontend/node_modules/webpack/lib/FlagAllModulesAsUsedPlugin.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 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, mergeRuntimeOwned } = require("./util/runtime");
9
10/** @typedef {import("./Compiler")} Compiler */
11/** @typedef {import("./Module").FactoryMeta} FactoryMeta */
12/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
13
14const PLUGIN_NAME = "FlagAllModulesAsUsedPlugin";
15class FlagAllModulesAsUsedPlugin {
16 /**
17 * Creates an instance of FlagAllModulesAsUsedPlugin.
18 * @param {string} explanation explanation
19 */
20 constructor(explanation) {
21 this.explanation = explanation;
22 }
23
24 /**
25 * Applies the plugin by registering its hooks on the compiler.
26 * @param {Compiler} compiler the compiler instance
27 * @returns {void}
28 */
29 apply(compiler) {
30 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
31 const moduleGraph = compilation.moduleGraph;
32 compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, (modules) => {
33 /** @type {RuntimeSpec} */
34 let runtime;
35 for (const [name, { options }] of compilation.entries) {
36 runtime = mergeRuntimeOwned(
37 runtime,
38 getEntryRuntime(compilation, name, options)
39 );
40 }
41 for (const module of modules) {
42 const exportsInfo = moduleGraph.getExportsInfo(module);
43 exportsInfo.setUsedInUnknownWay(runtime);
44 moduleGraph.addExtraReason(module, this.explanation);
45 if (module.factoryMeta === undefined) {
46 module.factoryMeta = {};
47 }
48 /** @type {FactoryMeta} */
49 (module.factoryMeta).sideEffectFree = false;
50 }
51 });
52 });
53 }
54}
55
56module.exports = FlagAllModulesAsUsedPlugin;
Note: See TracBrowser for help on using the repository browser.