From 0469abd4a9c9270a1fdc962969e36e63699af8b4 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 10 Dec 2017 21:51:33 +0100 Subject: upgrade dependencies --- .../webpack/lib/optimize/CommonsChunkPlugin.js | 20 ++++++++++---------- .../webpack/lib/optimize/ConcatenatedModule.js | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 16 deletions(-) (limited to 'node_modules/webpack/lib/optimize') diff --git a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js index ab7b69f4a..c0e438a40 100644 --- a/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js +++ b/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js @@ -107,7 +107,7 @@ You can however specify the name of the async chunk by passing the desired strin /** * These chunks are subject to get "common" modules extracted and moved to the common chunk */ - const affectedChunks = this.getAffectedChunks(compilation, chunks, targetChunk, targetChunks, idx, this.selectedChunks, this.async, this.children); + const affectedChunks = this.getAffectedChunks(compilation, chunks, targetChunk, targetChunks, idx, this.selectedChunks, this.async, this.children, this.deepChildren); // bail if no chunk is affected if(!affectedChunks) { @@ -214,7 +214,7 @@ You can however specify the name of the async chunk by passing the desired strin Take a look at the "name"/"names" or async/children option.`); } - getAffectedUnnamedChunks(affectedChunks, targetChunk, asyncOption) { + getAffectedUnnamedChunks(affectedChunks, targetChunk, rootChunk, asyncOption, deepChildrenOption) { let chunks = targetChunk.chunks; chunks && chunks.forEach((chunk) => { if(chunk.isInitial()) { @@ -225,11 +225,11 @@ Take a look at the "name"/"names" or async/children option.`); // b) themselves affected chunks // we can assume that this chunk is an affected chunk too, as there is no way a chunk that // isn't only depending on the target chunk is a parent of the chunk tested - if(asyncOption || chunk.parents.every((parentChunk) => parentChunk === targetChunk || affectedChunks.has(parentChunk))) { + if(asyncOption || chunk.parents.every((parentChunk) => parentChunk === rootChunk || affectedChunks.has(parentChunk))) { // This check not only dedupes the affectedChunks but also guarantees we avoid endless loops - if(!affectedChunks.has(chunk) || affectedChunks.values().next().value === chunk) { + if(!affectedChunks.has(chunk)) { // We mutate the affected chunks before going deeper, so the deeper levels and other branches - // Have the information of this chunk being affected for their assertion if a chunk should + // have the information of this chunk being affected for their assertion if a chunk should // not be affected affectedChunks.add(chunk); @@ -237,16 +237,16 @@ Take a look at the "name"/"names" or async/children option.`); // This guarantees that if a chunk should be an affected chunk, // at the latest the last connection to the same chunk meets the // condition to add it to the affected chunks. - if(this.deepChildren === true) { - this.getAffectedUnnamedChunks(affectedChunks, chunk, asyncOption); + if(deepChildrenOption === true) { + this.getAffectedUnnamedChunks(affectedChunks, chunk, rootChunk, asyncOption, deepChildrenOption); } } } }); } - getAffectedChunks(compilation, allChunks, targetChunk, targetChunks, currentIndex, selectedChunks, asyncOption, children) { - const asyncOrNoSelectedChunk = children || asyncOption; + getAffectedChunks(compilation, allChunks, targetChunk, targetChunks, currentIndex, selectedChunks, asyncOption, childrenOption, deepChildrenOption) { + const asyncOrNoSelectedChunk = childrenOption || asyncOption; if(Array.isArray(selectedChunks)) { return allChunks.filter(chunk => { @@ -258,7 +258,7 @@ Take a look at the "name"/"names" or async/children option.`); if(asyncOrNoSelectedChunk) { let affectedChunks = new Set(); - this.getAffectedUnnamedChunks(affectedChunks, targetChunk, asyncOption); + this.getAffectedUnnamedChunks(affectedChunks, targetChunk, targetChunk, asyncOption, deepChildrenOption); return Array.from(affectedChunks); } diff --git a/node_modules/webpack/lib/optimize/ConcatenatedModule.js b/node_modules/webpack/lib/optimize/ConcatenatedModule.js index 8b201009a..bfb772496 100644 --- a/node_modules/webpack/lib/optimize/ConcatenatedModule.js +++ b/node_modules/webpack/lib/optimize/ConcatenatedModule.js @@ -7,6 +7,7 @@ const Module = require("../Module"); const Template = require("../Template"); const Parser = require("../Parser"); +const crypto = require("crypto"); const acorn = require("acorn"); const escope = require("escope"); const ReplaceSource = require("webpack-sources/lib/ReplaceSource"); @@ -210,6 +211,7 @@ class ConcatenatedModule extends Module { Object.assign(this.assets, m.assets); } } + this._identifier = this._createIdentifier(); } get modules() { @@ -219,12 +221,7 @@ class ConcatenatedModule extends Module { } identifier() { - return this._orderedConcatenationList.map(info => { - switch(info.type) { - case "concatenated": - return info.module.identifier(); - } - }).filter(Boolean).join(" "); + return this._identifier; } readableIdentifier(requestShortener) { @@ -297,6 +294,19 @@ class ConcatenatedModule extends Module { return list; } + _createIdentifier() { + let orderedConcatenationListIdentifiers = ""; + for(let i = 0; i < this._orderedConcatenationList.length; i++) { + if(this._orderedConcatenationList[i].type === "concatenated") { + orderedConcatenationListIdentifiers += this._orderedConcatenationList[i].module.identifier(); + orderedConcatenationListIdentifiers += " "; + } + } + const hash = crypto.createHash("md5"); + hash.update(orderedConcatenationListIdentifiers); + return this.rootModule.identifier() + " " + hash.digest("hex"); + } + source(dependencyTemplates, outputOptions, requestShortener) { // Metainfo for each module const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => { -- cgit v1.2.3