source: trip-planner-front/node_modules/webpack/lib/ids/NaturalModuleIdsPlugin.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Florent Cailhol @ooflorent
4*/
5
6"use strict";
7
8const {
9 compareModulesByPreOrderIndexOrIdentifier
10} = require("../util/comparators");
11const { assignAscendingModuleIds } = require("./IdHelpers");
12
13/** @typedef {import("../Compiler")} Compiler */
14/** @typedef {import("../Module")} Module */
15
16class NaturalModuleIdsPlugin {
17 /**
18 * Apply the plugin
19 * @param {Compiler} compiler the compiler instance
20 * @returns {void}
21 */
22 apply(compiler) {
23 compiler.hooks.compilation.tap("NaturalModuleIdsPlugin", compilation => {
24 compilation.hooks.moduleIds.tap("NaturalModuleIdsPlugin", modules => {
25 const chunkGraph = compilation.chunkGraph;
26 const modulesInNaturalOrder = Array.from(modules)
27 .filter(
28 m =>
29 m.needId &&
30 chunkGraph.getNumberOfModuleChunks(m) > 0 &&
31 chunkGraph.getModuleId(m) === null
32 )
33 .sort(
34 compareModulesByPreOrderIndexOrIdentifier(compilation.moduleGraph)
35 );
36 assignAscendingModuleIds(modulesInNaturalOrder, compilation);
37 });
38 });
39 }
40}
41
42module.exports = NaturalModuleIdsPlugin;
Note: See TracBrowser for help on using the repository browser.