source: frontend/node_modules/webpack/lib/ids/NaturalChunkIdsPlugin.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 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 { compareChunksNatural } = require("../util/comparators");
9const { assignAscendingChunkIds } = require("./IdHelpers");
10
11/** @typedef {import("../Chunk")} Chunk */
12/** @typedef {import("../Compiler")} Compiler */
13
14const PLUGIN_NAME = "NaturalChunkIdsPlugin";
15
16class NaturalChunkIdsPlugin {
17 /**
18 * Applies the plugin by registering its hooks on the compiler.
19 * @param {Compiler} compiler the compiler instance
20 * @returns {void}
21 */
22 apply(compiler) {
23 compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
24 compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => {
25 const chunkGraph = compilation.chunkGraph;
26 const compareNatural = compareChunksNatural(chunkGraph);
27 /** @type {Chunk[]} */
28 const chunksInNaturalOrder = [...chunks].sort(compareNatural);
29 assignAscendingChunkIds(chunksInNaturalOrder, compilation);
30 });
31 });
32 }
33}
34
35module.exports = NaturalChunkIdsPlugin;
Note: See TracBrowser for help on using the repository browser.