This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/webpack/lib/optimize/NaturalChunkOrderPlugin.js
2019-08-11 20:48:02 +02:00

41 lines
1.1 KiB
JavaScript

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/** @typedef {import("../Compiler")} Compiler */
class NaturalChunkOrderPlugin {
/**
* @param {Compiler} compiler webpack compiler
* @returns {void}
*/
apply(compiler) {
compiler.hooks.compilation.tap("NaturalChunkOrderPlugin", compilation => {
compilation.hooks.optimizeChunkOrder.tap(
"NaturalChunkOrderPlugin",
chunks => {
chunks.sort((chunkA, chunkB) => {
const a = chunkA.modulesIterable[Symbol.iterator]();
const b = chunkB.modulesIterable[Symbol.iterator]();
// eslint-disable-next-line no-constant-condition
while (true) {
const aItem = a.next();
const bItem = b.next();
if (aItem.done && bItem.done) return 0;
if (aItem.done) return -1;
if (bItem.done) return 1;
const aModuleId = aItem.value.id;
const bModuleId = bItem.value.id;
if (aModuleId < bModuleId) return -1;
if (aModuleId > bModuleId) return 1;
}
});
}
);
});
}
}
module.exports = NaturalChunkOrderPlugin;