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.0 KB
|
Rev | Line | |
---|
[79a0317] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Florent Cailhol @ooflorent
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | const {
|
---|
| 9 | compareModulesByPreOrderIndexOrIdentifier
|
---|
| 10 | } = require("../util/comparators");
|
---|
| 11 | const {
|
---|
| 12 | assignAscendingModuleIds,
|
---|
| 13 | getUsedModuleIdsAndModules
|
---|
| 14 | } = require("./IdHelpers");
|
---|
| 15 |
|
---|
| 16 | /** @typedef {import("../Compiler")} Compiler */
|
---|
| 17 | /** @typedef {import("../Module")} Module */
|
---|
| 18 |
|
---|
| 19 | class NaturalModuleIdsPlugin {
|
---|
| 20 | /**
|
---|
| 21 | * Apply the plugin
|
---|
| 22 | * @param {Compiler} compiler the compiler instance
|
---|
| 23 | * @returns {void}
|
---|
| 24 | */
|
---|
| 25 | apply(compiler) {
|
---|
| 26 | compiler.hooks.compilation.tap("NaturalModuleIdsPlugin", compilation => {
|
---|
| 27 | compilation.hooks.moduleIds.tap("NaturalModuleIdsPlugin", modules => {
|
---|
| 28 | const [usedIds, modulesInNaturalOrder] =
|
---|
| 29 | getUsedModuleIdsAndModules(compilation);
|
---|
| 30 | modulesInNaturalOrder.sort(
|
---|
| 31 | compareModulesByPreOrderIndexOrIdentifier(compilation.moduleGraph)
|
---|
| 32 | );
|
---|
| 33 | assignAscendingModuleIds(usedIds, modulesInNaturalOrder, compilation);
|
---|
| 34 | });
|
---|
| 35 | });
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | module.exports = NaturalModuleIdsPlugin;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.