source: imaps-frontend/node_modules/webpack/lib/FlagAllModulesAsUsedPlugin.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 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, 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 * @param {string} explanation explanation
18 */
19 constructor(explanation) {
20 this.explanation = explanation;
21 }
22
23 /**
24 * Apply the plugin
25 * @param {Compiler} compiler the compiler instance
26 * @returns {void}
27 */
28 apply(compiler) {
29 compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
30 const moduleGraph = compilation.moduleGraph;
31 compilation.hooks.optimizeDependencies.tap(PLUGIN_NAME, modules => {
32 /** @type {RuntimeSpec} */
33 let runtime;
34 for (const [name, { options }] of compilation.entries) {
35 runtime = mergeRuntimeOwned(
36 runtime,
37 getEntryRuntime(compilation, name, options)
38 );
39 }
40 for (const module of modules) {
41 const exportsInfo = moduleGraph.getExportsInfo(module);
42 exportsInfo.setUsedInUnknownWay(runtime);
43 moduleGraph.addExtraReason(module, this.explanation);
44 if (module.factoryMeta === undefined) {
45 module.factoryMeta = {};
46 }
47 /** @type {FactoryMeta} */
48 (module.factoryMeta).sideEffectFree = false;
49 }
50 });
51 });
52 }
53}
54
55module.exports = FlagAllModulesAsUsedPlugin;
Note: See TracBrowser for help on using the repository browser.