From de98e0b232509d5f40c135d540a70e415272ff85 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 3 May 2017 15:35:00 +0200 Subject: node_modules --- .../lib/optimize/FlagIncludedChunksPlugin.js | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js (limited to 'node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js') diff --git a/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js b/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js new file mode 100644 index 000000000..e8b5a9457 --- /dev/null +++ b/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js @@ -0,0 +1,35 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class FlagIncludedChunksPlugin { + + apply(compiler) { + compiler.plugin("compilation", (compilation) => { + compilation.plugin("optimize-chunk-ids", (chunks) => { + chunks.forEach((chunkA) => { + chunks.forEach((chunkB) => { + // as we iterate the same iterables twice + // skip if we find ourselves + if(chunkA === chunkB) return; + + // instead of swapping A and B just bail + // as we loop twice the current A will be B and B then A + if(chunkA.modules.length < chunkB.modules.length) return; + + if(chunkB.modules.length === 0) return; + + // is chunkB in chunkA? + for(let i = 0; i < chunkB.modules.length; i++) { + if(chunkA.modules.indexOf(chunkB.modules[i]) < 0) return; + } + chunkA.ids.push(chunkB.id); + }); + }); + }); + }); + } +} +module.exports = FlagIncludedChunksPlugin; -- cgit v1.2.3