Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
4d50ff30
Unverified
Commit
4d50ff30
authored
Oct 08, 2021
by
Tobias Koppers
Committed by
GitHub
Oct 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update webpack (#29738)
parent
fcdba560
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
322 additions
and
434 deletions
+322
-434
bundle5.js
packages/next/compiled/webpack/bundle5.js
+317
-429
package.json
packages/next/package.json
+1
-1
yarn.lock
yarn.lock
+4
-4
No files found.
packages/next/compiled/webpack/bundle5.js
View file @
4d50ff30
...
@@ -38,7 +38,7 @@ module.exports = JSON.parse("{\"application/1d-interleaved-parityfec\":{\"source
...
@@ -38,7 +38,7 @@ module.exports = JSON.parse("{\"application/1d-interleaved-parityfec\":{\"source
/***/ (function(module) {
/***/ (function(module) {
"use strict";
"use strict";
module.exports = {"i8":"5.58.
0
"};
module.exports = {"i8":"5.58.
1
"};
/***/ }),
/***/ }),
...
@@ -23127,201 +23127,6 @@ class Chunk {
...
@@ -23127,201 +23127,6 @@ class Chunk {
module.exports = Chunk;
module.exports = Chunk;
/***/ }),
/***/ 70359:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
const SortableSet = __webpack_require__(67563);
/** @typedef {import("./Chunk")} Chunk */
/**
* @template T
* @param {SortableSet<T>} set the set
* @returns {T[]} set as array
*/
const getArray = set => {
return Array.from(set);
};
let debugId = 1;
class ChunkCombination {
constructor() {
this.debugId = debugId++;
this.size = 0;
/**
* (do not modify)
* @type {SortableSet<Chunk>}
*/
this._chunks = new SortableSet();
/** @type {ChunkCombination} */
this._parent = undefined;
this._lastChunk = undefined;
/** @type {WeakMap<Chunk, ChunkCombination>} */
this._addMap = new WeakMap();
/** @type {WeakMap<Chunk, ChunkCombination>} */
this._removeCache = new WeakMap();
}
/**
* @returns {Iterable<Chunk>} iterable of chunks
*/
get chunksIterable() {
return this._chunks;
}
/**
* @param {Chunk} chunk chunk to add
* @returns {ChunkCombination} new chunk combination
*/
with(chunk) {
if (this._chunks.has(chunk)) return this;
let next = this._addMap.get(chunk);
if (next !== undefined) return next;
// must insert chunks in order to maintain order-independent identity of ChunkCombination
if (!this._parent || this._lastChunk.debugId < chunk.debugId) {
next = new ChunkCombination();
for (const chunk of this._chunks) {
next._chunks.add(chunk);
}
next._chunks.add(chunk);
next._removeCache.set(chunk, this);
next.size = this.size + 1;
next._parent = this;
next._lastChunk = chunk;
} else {
next = this._parent.with(chunk).with(this._lastChunk);
}
this._addMap.set(chunk, next);
return next;
}
/**
* @param {Chunk} chunk chunk to remove
* @returns {ChunkCombination} new chunk combination
*/
without(chunk) {
if (!this._chunks.has(chunk)) return this;
let next = this._removeCache.get(chunk);
if (next !== undefined) return next;
const stack = [this._lastChunk];
let current = this._parent;
while (current._lastChunk !== chunk) {
stack.push(current._lastChunk);
current = current._parent;
}
next = current._parent;
while (stack.length) next = next.with(stack.pop());
this._removeCache.set(chunk, next);
return next;
}
withAll(other) {
if (other.size === 0) return this;
if (this.size === 0) return other;
const stack = [];
/** @type {ChunkCombination} */
let current = this;
for (;;) {
if (current._lastChunk.debugId < other._lastChunk.debugId) {
stack.push(other._lastChunk);
other = other._parent;
if (other.size === 0) {
while (stack.length) current = current.with(stack.pop());
return current;
}
} else {
stack.push(current._lastChunk);
current = current._parent;
if (current.size === 0) {
while (stack.length) other = other.with(stack.pop());
return other;
}
}
}
}
hasSharedChunks(other) {
if (this.size > other.size) {
const chunks = this._chunks;
for (const chunk of other._chunks) {
if (chunks.has(chunk)) return true;
}
} else {
const chunks = other._chunks;
for (const chunk of this._chunks) {
if (chunks.has(chunk)) return true;
}
}
return false;
}
/**
* @param {ChunkCombination} other other combination
* @returns {boolean} true, when other is a subset of this combination
*/
isSubset(other) {
// TODO: This could be more efficient when using the debugId order of the combinations
/** @type {ChunkCombination} */
let current = this;
let otherSize = other.size;
let currentSize = current.size;
if (otherSize === 0) return true;
for (;;) {
if (currentSize === 0) return false;
if (otherSize === 1) {
if (currentSize === 1) {
return current._lastChunk === other._lastChunk;
} else {
return current._chunks.has(other._lastChunk);
}
}
if (otherSize * 8 < currentSize) {
// go for the Set access when current >> other
const chunks = current._chunks;
for (const item of other._chunks) {
if (!chunks.has(item)) return false;
}
return true;
}
const otherId = other._lastChunk.debugId;
// skip over nodes in current that have higher ids
while (otherId < current._lastChunk.debugId) {
current = current._parent;
currentSize--;
if (currentSize === 0) return false;
}
if (otherId > current._lastChunk.debugId) {
return false;
}
other = other._parent;
otherSize--;
if (otherSize === 0) return true;
current = current._parent;
currentSize--;
}
}
getChunks() {
return this._chunks.getFromUnorderedCache(getArray);
}
}
ChunkCombination.empty = new ChunkCombination();
module.exports = ChunkCombination;
/***/ }),
/***/ }),
/***/ 97860:
/***/ 97860:
...
@@ -23336,7 +23141,6 @@ module.exports = ChunkCombination;
...
@@ -23336,7 +23141,6 @@ module.exports = ChunkCombination;
const util = __webpack_require__(31669);
const util = __webpack_require__(31669);
const ChunkCombination = __webpack_require__(70359);
const Entrypoint = __webpack_require__(86695);
const Entrypoint = __webpack_require__(86695);
const ModuleGraphConnection = __webpack_require__(94144);
const ModuleGraphConnection = __webpack_require__(94144);
const { first } = __webpack_require__(34715);
const { first } = __webpack_require__(34715);
...
@@ -23371,8 +23175,6 @@ const {
...
@@ -23371,8 +23175,6 @@ const {
/** @type {ReadonlySet<string>} */
/** @type {ReadonlySet<string>} */
const EMPTY_SET = new Set();
const EMPTY_SET = new Set();
const EMPTY_RUNTIME_SPEC_SET = new RuntimeSpecSet();
const ZERO_BIG_INT = BigInt(0);
const ZERO_BIG_INT = BigInt(0);
const compareModuleIterables = compareIterables(compareModulesByIdentifier);
const compareModuleIterables = compareIterables(compareModulesByIdentifier);
...
@@ -23510,7 +23312,8 @@ const isAvailableChunk = (a, b) => {
...
@@ -23510,7 +23312,8 @@ const isAvailableChunk = (a, b) => {
class ChunkGraphModule {
class ChunkGraphModule {
constructor() {
constructor() {
this.chunkCombination = ChunkCombination.empty;
/** @type {SortableSet<Chunk>} */
this.chunks = new SortableSet();
/** @type {Set<Chunk> | undefined} */
/** @type {Set<Chunk> | undefined} */
this.entryInChunks = undefined;
this.entryInChunks = undefined;
/** @type {Set<Chunk> | undefined} */
/** @type {Set<Chunk> | undefined} */
...
@@ -23633,7 +23436,7 @@ class ChunkGraph {
...
@@ -23633,7 +23436,7 @@ class ChunkGraph {
connectChunkAndModule(chunk, module) {
connectChunkAndModule(chunk, module) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
const cgc = this._getChunkGraphChunk(chunk);
const cgc = this._getChunkGraphChunk(chunk);
cgm.chunk
Combination = cgm.chunkCombination.with
(chunk);
cgm.chunk
s.add
(chunk);
cgc.modules.add(module);
cgc.modules.add(module);
}
}
...
@@ -23646,7 +23449,7 @@ class ChunkGraph {
...
@@ -23646,7 +23449,7 @@ class ChunkGraph {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
const cgc = this._getChunkGraphChunk(chunk);
const cgc = this._getChunkGraphChunk(chunk);
cgc.modules.delete(module);
cgc.modules.delete(module);
cgm.chunk
Combination = cgm.chunkCombination.without
(chunk);
cgm.chunk
s.delete
(chunk);
}
}
/**
/**
...
@@ -23657,7 +23460,7 @@ class ChunkGraph {
...
@@ -23657,7 +23460,7 @@ class ChunkGraph {
const cgc = this._getChunkGraphChunk(chunk);
const cgc = this._getChunkGraphChunk(chunk);
for (const module of cgc.modules) {
for (const module of cgc.modules) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
cgm.chunk
Combination = cgm.chunkCombination.without
(chunk);
cgm.chunk
s.delete
(chunk);
}
}
cgc.modules.clear();
cgc.modules.clear();
chunk.disconnectFromGroups();
chunk.disconnectFromGroups();
...
@@ -23724,13 +23527,13 @@ class ChunkGraph {
...
@@ -23724,13 +23527,13 @@ class ChunkGraph {
const oldCgm = this._getChunkGraphModule(oldModule);
const oldCgm = this._getChunkGraphModule(oldModule);
const newCgm = this._getChunkGraphModule(newModule);
const newCgm = this._getChunkGraphModule(newModule);
for (const chunk of oldCgm.chunk
Combination._chunk
s) {
for (const chunk of oldCgm.chunks) {
const cgc = this._getChunkGraphChunk(chunk);
const cgc = this._getChunkGraphChunk(chunk);
cgc.modules.delete(oldModule);
cgc.modules.delete(oldModule);
cgc.modules.add(newModule);
cgc.modules.add(newModule);
newCgm.chunk
Combination = newCgm.chunkCombination.with
(chunk);
newCgm.chunk
s.add
(chunk);
}
}
oldCgm.chunk
Combination = ChunkCombination.empty
;
oldCgm.chunk
s.clear()
;
if (oldCgm.entryInChunks !== undefined) {
if (oldCgm.entryInChunks !== undefined) {
if (newCgm.entryInChunks === undefined) {
if (newCgm.entryInChunks === undefined) {
...
@@ -23817,22 +23620,13 @@ class ChunkGraph {
...
@@ -23817,22 +23620,13 @@ class ChunkGraph {
return cgm.entryInChunks !== undefined;
return cgm.entryInChunks !== undefined;
}
}
/**
* @param {Module} module the module
* @returns {ChunkCombination} chunk combination (do not modify)
*/
getModuleChunkCombination(module) {
const cgm = this._getChunkGraphModule(module);
return cgm.chunkCombination;
}
/**
/**
* @param {Module} module the module
* @param {Module} module the module
* @returns {Iterable<Chunk>} iterable of chunks (do not modify)
* @returns {Iterable<Chunk>} iterable of chunks (do not modify)
*/
*/
getModuleChunksIterable(module) {
getModuleChunksIterable(module) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
return cgm.chunk
Combination._chunk
s;
return cgm.chunks;
}
}
/**
/**
...
@@ -23842,9 +23636,8 @@ class ChunkGraph {
...
@@ -23842,9 +23636,8 @@ class ChunkGraph {
*/
*/
getOrderedModuleChunksIterable(module, sortFn) {
getOrderedModuleChunksIterable(module, sortFn) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
const chunks = cgm.chunkCombination._chunks;
cgm.chunks.sortWith(sortFn);
chunks.sortWith(sortFn);
return cgm.chunks;
return chunks;
}
}
/**
/**
...
@@ -23853,7 +23646,7 @@ class ChunkGraph {
...
@@ -23853,7 +23646,7 @@ class ChunkGraph {
*/
*/
getModuleChunks(module) {
getModuleChunks(module) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
return cgm.chunk
Combination.getChunks(
);
return cgm.chunk
s.getFromCache(getArray
);
}
}
/**
/**
...
@@ -23862,7 +23655,7 @@ class ChunkGraph {
...
@@ -23862,7 +23655,7 @@ class ChunkGraph {
*/
*/
getNumberOfModuleChunks(module) {
getNumberOfModuleChunks(module) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
return cgm.chunk
Combination
.size;
return cgm.chunk
s
.size;
}
}
/**
/**
...
@@ -23871,10 +23664,7 @@ class ChunkGraph {
...
@@ -23871,10 +23664,7 @@ class ChunkGraph {
*/
*/
getModuleRuntimes(module) {
getModuleRuntimes(module) {
const cgm = this._getChunkGraphModule(module);
const cgm = this._getChunkGraphModule(module);
if (cgm.chunkCombination.size === 0) return EMPTY_RUNTIME_SPEC_SET;
return cgm.chunks.getFromUnorderedCache(getModuleRuntimes);
return cgm.chunkCombination._chunks.getFromUnorderedCache(
getModuleRuntimes
);
}
}
/**
/**
...
@@ -24238,7 +24028,8 @@ class ChunkGraph {
...
@@ -24238,7 +24028,8 @@ class ChunkGraph {
// Merge runtime
// Merge runtime
chunkA.runtime = mergeRuntime(chunkA.runtime, chunkB.runtime);
chunkA.runtime = mergeRuntime(chunkA.runtime, chunkB.runtime);
for (const module of this.getChunkModulesIterable(chunkB)) {
// getChunkModules is used here to create a clone, because disconnectChunkAndModule modifies
for (const module of this.getChunkModules(chunkB)) {
this.disconnectChunkAndModule(chunkB, module);
this.disconnectChunkAndModule(chunkB, module);
this.connectChunkAndModule(chunkA, module);
this.connectChunkAndModule(chunkA, module);
}
}
...
@@ -30258,7 +30049,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
...
@@ -30258,7 +30049,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
this.moduleGraph.removeConnection(dep);
this.moduleGraph.removeConnection(dep);
if (this.chunkGraph) {
if (this.chunkGraph) {
for (const chunk of this.chunkGraph.getModuleChunks
Iterable
(
for (const chunk of this.chunkGraph.getModuleChunks(
originalModule
originalModule
)) {
)) {
this.patchChunksAfterReasonRemoval(originalModule, chunk);
this.patchChunksAfterReasonRemoval(originalModule, chunk);
...
@@ -31469,7 +31260,7 @@ This prevents using hashes of each other and should be avoided.`);
...
@@ -31469,7 +31260,7 @@ This prevents using hashes of each other and should be avoided.`);
strictModuleErrorHandling,
strictModuleErrorHandling,
strictModuleExceptionHandling
strictModuleExceptionHandling
} = this.outputOptions;
} = this.outputOptions;
const __nested_webpack_require_1477
95
__ = id => {
const __nested_webpack_require_1477
87
__ = id => {
const cached = moduleCache[id];
const cached = moduleCache[id];
if (cached !== undefined) {
if (cached !== undefined) {
if (cached.error) throw cached.error;
if (cached.error) throw cached.error;
...
@@ -31478,20 +31269,20 @@ This prevents using hashes of each other and should be avoided.`);
...
@@ -31478,20 +31269,20 @@ This prevents using hashes of each other and should be avoided.`);
const moduleArgument = moduleArgumentsById.get(id);
const moduleArgument = moduleArgumentsById.get(id);
return __webpack_require_module__(moduleArgument, id);
return __webpack_require_module__(moduleArgument, id);
};
};
const interceptModuleExecution = (__nested_webpack_require_1477
95
__[
const interceptModuleExecution = (__nested_webpack_require_1477
87
__[
RuntimeGlobals.interceptModuleExecution.replace(
RuntimeGlobals.interceptModuleExecution.replace(
"__webpack_require__.",
"__webpack_require__.",
""
""
)
)
] = []);
] = []);
const moduleCache = (__nested_webpack_require_1477
95
__[
const moduleCache = (__nested_webpack_require_1477
87
__[
RuntimeGlobals.moduleCache.replace(
RuntimeGlobals.moduleCache.replace(
"__webpack_require__.",
"__webpack_require__.",
""
""
)
)
] = {});
] = {});
context.__webpack_require__ = __nested_webpack_require_1477
95
__;
context.__webpack_require__ = __nested_webpack_require_1477
87
__;
/**
/**
* @param {ExecuteModuleArgument} moduleArgument the module argument
* @param {ExecuteModuleArgument} moduleArgument the module argument
...
@@ -31507,7 +31298,7 @@ This prevents using hashes of each other and should be avoided.`);
...
@@ -31507,7 +31298,7 @@ This prevents using hashes of each other and should be avoided.`);
loaded: false,
loaded: false,
error: undefined
error: undefined
},
},
require: __nested_webpack_require_1477
95
__
require: __nested_webpack_require_1477
87
__
};
};
interceptModuleExecution.forEach(handler =>
interceptModuleExecution.forEach(handler =>
handler(execOptions)
handler(execOptions)
...
@@ -31547,7 +31338,7 @@ This prevents using hashes of each other and should be avoided.`);
...
@@ -31547,7 +31338,7 @@ This prevents using hashes of each other and should be avoided.`);
moduleArgumentsMap.get(runtimeModule)
moduleArgumentsMap.get(runtimeModule)
);
);
}
}
exports = __nested_webpack_require_1477
95
__(module.identifier());
exports = __nested_webpack_require_1477
87
__(module.identifier());
} catch (e) {
} catch (e) {
const err = new WebpackError(
const err = new WebpackError(
`Execution of module code from module graph (${module.readableIdentifier(
`Execution of module code from module graph (${module.readableIdentifier(
...
@@ -54212,6 +54003,26 @@ class NormalModuleFactory extends ModuleFactory {
...
@@ -54212,6 +54003,26 @@ class NormalModuleFactory extends ModuleFactory {
: "") +
: "") +
stringifyLoadersAndResource(loaders, resourceData.resource);
stringifyLoadersAndResource(loaders, resourceData.resource);
const settings = {};
const useLoadersPost = [];
const useLoaders = [];
const useLoadersPre = [];
// handle .webpack[] suffix
let resource;
let match;
if (
matchResourceData &&
typeof (resource = matchResourceData.resource) === "string" &&
(match = /\.webpack\[([^\]]+)\]$/.exec(resource))
) {
settings.type = match[1];
matchResourceData.resource = matchResourceData.resource.slice(
0,
-settings.type.length - 10
);
} else {
settings.type = "javascript/auto";
const resourceDataForRules = matchResourceData || resourceData;
const resourceDataForRules = matchResourceData || resourceData;
const result = this.ruleSet.exec({
const result = this.ruleSet.exec({
resource: resourceDataForRules.path,
resource: resourceDataForRules.path,
...
@@ -54220,7 +54031,9 @@ class NormalModuleFactory extends ModuleFactory {
...
@@ -54220,7 +54031,9 @@ class NormalModuleFactory extends ModuleFactory {
resourceFragment: resourceDataForRules.fragment,
resourceFragment: resourceDataForRules.fragment,
scheme,
scheme,
assertions,
assertions,
mimetype: matchResourceData ? "" : resourceData.data.mimetype || "",
mimetype: matchResourceData
? ""
: resourceData.data.mimetype || "",
dependency: dependencyType,
dependency: dependencyType,
descriptionData: matchResourceData
descriptionData: matchResourceData
? undefined
? undefined
...
@@ -54229,10 +54042,6 @@ class NormalModuleFactory extends ModuleFactory {
...
@@ -54229,10 +54042,6 @@ class NormalModuleFactory extends ModuleFactory {
compiler: contextInfo.compiler,
compiler: contextInfo.compiler,
issuerLayer: contextInfo.issuerLayer || ""
issuerLayer: contextInfo.issuerLayer || ""
});
});
const settings = {};
const useLoadersPost = [];
const useLoaders = [];
const useLoadersPre = [];
for (const r of result) {
for (const r of result) {
if (r.type === "use") {
if (r.type === "use") {
if (!noAutoLoaders && !noPrePostAutoLoaders) {
if (!noAutoLoaders && !noPrePostAutoLoaders) {
...
@@ -54257,6 +54066,7 @@ class NormalModuleFactory extends ModuleFactory {
...
@@ -54257,6 +54066,7 @@ class NormalModuleFactory extends ModuleFactory {
settings[r.type] = r.value;
settings[r.type] = r.value;
}
}
}
}
}
let postLoaders, normalLoaders, preLoaders;
let postLoaders, normalLoaders, preLoaders;
...
@@ -54274,23 +54084,6 @@ class NormalModuleFactory extends ModuleFactory {
...
@@ -54274,23 +54084,6 @@ class NormalModuleFactory extends ModuleFactory {
}
}
for (const loader of preLoaders) allLoaders.push(loader);
for (const loader of preLoaders) allLoaders.push(loader);
let type = settings.type;
let type = settings.type;
if (!type) {
let resource;
let match;
if (
matchResourceData &&
typeof (resource = matchResourceData.resource) === "string" &&
(match = /\.webpack\[([^\]]+)\]$/.exec(resource))
) {
type = match[1];
matchResourceData.resource = matchResourceData.resource.slice(
0,
-type.length - 10
);
} else {
type = "javascript/auto";
}
}
const resolveOptions = settings.resolve;
const resolveOptions = settings.resolve;
const layer = settings.layer;
const layer = settings.layer;
if (layer !== undefined && !layers) {
if (layer !== undefined && !layers) {
...
@@ -104945,10 +104738,11 @@ module.exports = SideEffectsFlagPlugin;
...
@@ -104945,10 +104738,11 @@ module.exports = SideEffectsFlagPlugin;
const Chunk
Combination = __webpack_require__(70359
);
const Chunk
= __webpack_require__(65574
);
const { STAGE_ADVANCED } = __webpack_require__(68145);
const { STAGE_ADVANCED } = __webpack_require__(68145);
const WebpackError = __webpack_require__(68422);
const WebpackError = __webpack_require__(68422);
const { requestToId } = __webpack_require__(72922);
const { requestToId } = __webpack_require__(72922);
const { isSubset } = __webpack_require__(34715);
const SortableSet = __webpack_require__(67563);
const SortableSet = __webpack_require__(67563);
const {
const {
compareModulesByIdentifier,
compareModulesByIdentifier,
...
@@ -104965,7 +104759,6 @@ const MinMaxSizeWarning = __webpack_require__(46681);
...
@@ -104965,7 +104759,6 @@ const MinMaxSizeWarning = __webpack_require__(46681);
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
...
@@ -105095,9 +104888,9 @@ const MinMaxSizeWarning = __webpack_require__(46681);
...
@@ -105095,9 +104888,9 @@ const MinMaxSizeWarning = __webpack_require__(46681);
* @property {number} cacheGroupIndex
* @property {number} cacheGroupIndex
* @property {string} name
* @property {string} name
* @property {Record<string, number>} sizes
* @property {Record<string, number>} sizes
* @property {
ChunkCombination
} chunks
* @property {
Set<Chunk>
} chunks
* @property {Set<Chunk>} reuseableChunks
* @property {Set<Chunk>} reuseableChunks
* @property {Set<
ChunkCombination>} chunkCombination
s
* @property {Set<
bigint | Chunk>} chunksKey
s
*/
*/
const defaultGetName = /** @type {GetName} */ (() => {});
const defaultGetName = /** @type {GetName} */ (() => {});
...
@@ -105144,6 +104937,19 @@ const mapObject = (obj, fn) => {
...
@@ -105144,6 +104937,19 @@ const mapObject = (obj, fn) => {
return newObj;
return newObj;
};
};
/**
* @template T
* @param {Set<T>} a set
* @param {Set<T>} b other set
* @returns {boolean} true if at least one item of a is in b
*/
const isOverlap = (a, b) => {
for (const item of a) {
if (b.has(item)) return true;
}
return false;
};
const compareModuleIterables = compareIterables(compareModulesByIdentifier);
const compareModuleIterables = compareIterables(compareModulesByIdentifier);
/**
/**
...
@@ -105696,132 +105502,207 @@ module.exports = class SplitChunksPlugin {
...
@@ -105696,132 +105502,207 @@ module.exports = class SplitChunksPlugin {
logger.time("prepare");
logger.time("prepare");
const chunkGraph = compilation.chunkGraph;
const chunkGraph = compilation.chunkGraph;
const moduleGraph = compilation.moduleGraph;
const moduleGraph = compilation.moduleGraph;
// Give each selected chunk an index (to create strings from chunks)
/** @type {Map<Chunk, bigint>} */
const chunkIndexMap = new Map();
const ZERO = BigInt("0");
const ONE = BigInt("1");
let index = ONE;
for (const chunk of chunks) {
chunkIndexMap.set(chunk, index);
index = index << ONE;
}
/**
* @param {Iterable<Chunk>} chunks list of chunks
* @returns {bigint | Chunk} key of the chunks
*/
const getKey = chunks => {
const iterator = chunks[Symbol.iterator]();
let result = iterator.next();
if (result.done) return ZERO;
const first = result.value;
result = iterator.next();
if (result.done) return first;
let key =
chunkIndexMap.get(first) | chunkIndexMap.get(result.value);
while (!(result = iterator.next()).done) {
key = key | chunkIndexMap.get(result.value);
}
return key;
};
const keyToString = key => {
if (typeof key === "bigint") return key.toString(16);
return chunkIndexMap.get(key).toString(16);
};
const getChunkCombinationsInGraph = memoize(() => {
const getChunkSetsInGraph = memoize(() => {
/** @type {Set<ChunkCombination>} */
/** @type {Map<bigint, Set<Chunk>>} */
const chunkCombinationsInGraph = new Set();
const chunkSetsInGraph = new Map();
/** @type {Set<Chunk>} */
const singleChunkSets = new Set();
for (const module of compilation.modules) {
for (const module of compilation.modules) {
const chunkCombination =
const chunks = chunkGraph.getModuleChunksIterable(module);
chunkGraph.getModuleChunkCombination(module);
const chunksKey = getKey(chunks);
chunkCombinationsInGraph.add(chunkCombination);
if (typeof chunksKey === "bigint") {
if (!chunkSetsInGraph.has(chunksKey)) {
chunkSetsInGraph.set(chunksKey, new Set(chunks));
}
}
return chunkCombinationsInGraph;
} else {
singleChunkSets.add(chunksKey);
}
}
return { chunkSetsInGraph, singleChunkSets };
});
});
/**
/**
* @param {Module} module the module
* @param {Module} module the module
* @returns {Iterable<Chunk
Combination
>} groups of chunks with equal exports
* @returns {Iterable<Chunk
[]
>} groups of chunks with equal exports
*/
*/
const groupChunksByExports = module => {
const groupChunksByExports = module => {
const exportsInfo = moduleGraph.getExportsInfo(module);
const exportsInfo = moduleGraph.getExportsInfo(module);
const groupedByUsedExports = new Map();
const groupedByUsedExports = new Map();
for (const chunk of chunkGraph.getModuleChunksIterable(module)) {
for (const chunk of chunkGraph.getModuleChunksIterable(module)) {
const key = exportsInfo.getUsageKey(chunk.runtime);
const key = exportsInfo.getUsageKey(chunk.runtime);
const combination =
const list = groupedByUsedExports.get(key);
groupedByUsedExports.get(key) || ChunkCombination.empty;
if (list !== undefined) {
groupedByUsedExports.set(key, combination.with(chunk));
list.push(chunk);
} else {
groupedByUsedExports.set(key, [chunk]);
}
}
}
return groupedByUsedExports.values();
return groupedByUsedExports.values();
};
};
/** @type {Map<Module, Iterable<Chunk
Combination
>>} */
/** @type {Map<Module, Iterable<Chunk
[]
>>} */
const groupedByExportsMap = new Map();
const groupedByExportsMap = new Map();
const getExportsChunkCombinationsInGraph = memoize(() => {
const getExportsChunkSetsInGraph = memoize(() => {
/** @type {Set<ChunkCombination>} */
/** @type {Map<bigint, Set<Chunk>>} */
const chunkCombinationsInGraph = new Set();
const chunkSetsInGraph = new Map();
/** @type {Set<Chunk>} */
const singleChunkSets = new Set();
for (const module of compilation.modules) {
for (const module of compilation.modules) {
const groupedChunks = Array.from(groupChunksByExports(module));
const groupedChunks = Array.from(groupChunksByExports(module));
groupedByExportsMap.set(module, groupedChunks);
groupedByExportsMap.set(module, groupedChunks);
for (const chunkCombination of groupedChunks) {
for (const chunks of groupedChunks) {
chunkCombinationsInGraph.add(chunkCombination);
if (chunks.length === 1) {
singleChunkSets.add(chunks[0]);
} else {
const chunksKey = /** @type {bigint} */ (getKey(chunks));
if (!chunkSetsInGraph.has(chunksKey)) {
chunkSetsInGraph.set(chunksKey, new Set(chunks));
}
}
}
}
}
}
return
chunkCombinationsInGraph
;
return
{ chunkSetsInGraph, singleChunkSets }
;
});
});
// group these set of chunks by count
// group these set of chunks by count
// to allow to check less sets via isSubset
// to allow to check less sets via isSubset
// (only smaller sets can be subset)
// (only smaller sets can be subset)
const groupChunk
CombinationsByCount = chunkCombination
s => {
const groupChunk
SetsByCount = chunkSet
s => {
/** @type {Map<number,
ChunkCombination[]
>} */
/** @type {Map<number,
Array<Set<Chunk>>
>} */
const chunk
Combination
sByCount = new Map();
const chunk
Set
sByCount = new Map();
for (const chunksSet of chunk
Combination
s) {
for (const chunksSet of chunk
Set
s) {
const count = chunksSet.size;
const count = chunksSet.size;
let array = chunk
Combination
sByCount.get(count);
let array = chunk
Set
sByCount.get(count);
if (array === undefined) {
if (array === undefined) {
array = [];
array = [];
chunk
Combination
sByCount.set(count, array);
chunk
Set
sByCount.set(count, array);
}
}
array.push(chunksSet);
array.push(chunksSet);
}
}
return chunk
Combination
sByCount;
return chunk
Set
sByCount;
};
};
const getChunkCombinationsByCount = memoize(() =>
const getChunkSetsByCount = memoize(() =>
groupChunkCombinationsByCount(getChunkCombinationsInGraph())
groupChunkSetsByCount(
getChunkSetsInGraph().chunkSetsInGraph.values()
)
);
);
const getExportsChunkCombinationsByCount = memoize(() =>
const getExportsChunkSetsByCount = memoize(() =>
groupChunkCombinationsByCount(getExportsChunkCombinationsInGraph())
groupChunkSetsByCount(
getExportsChunkSetsInGraph().chunkSetsInGraph.values()
)
);
);
/
**
/
/ Create a list of possible combinations
* Create a list of possible combinations
const createGetCombinations = (
* @param {Map<number, ChunkCombination[]>} chunkCombinationsByCount by count
chunkSets,
* @returns {function(ChunkCombination): ChunkCombination[]} get combinations function
singleChunkSets,
*/
chunkSetsByCount
const createGetCombinations = chunkCombinationsByCount
=> {
)
=> {
/** @type {Map<
ChunkCombination, ChunkCombination
[]>} */
/** @type {Map<
bigint | Chunk, (Set<Chunk> | Chunk)
[]>} */
const combinationsCache = new Map();
const combinationsCache = new Map();
/**
return key => {
* @param {ChunkCombination} chunkCombination chunkCombination
const cacheEntry = combinationsCache.get(key);
* @returns {ChunkCombination[]} combinations
*/
return chunkCombination => {
const cacheEntry = combinationsCache.get(chunkCombination);
if (cacheEntry !== undefined) return cacheEntry;
if (cacheEntry !== undefined) return cacheEntry;
if (
chunkCombination.size === 1
) {
if (
key instanceof Chunk
) {
const result = [
chunkCombination
];
const result = [
key
];
combinationsCache.set(
chunkCombination
, result);
combinationsCache.set(
key
, result);
return result;
return result;
}
}
/** @type {ChunkCombination[]} */
const chunksSet = chunkSets.get(key);
const array = [chunkCombination];
/** @type {(Set<Chunk> | Chunk)[]} */
for (const [count, setArray] of chunkCombinationsByCount) {
const array = [chunksSet];
for (const [count, setArray] of chunkSetsByCount) {
// "equal" is not needed because they would have been merge in the first step
// "equal" is not needed because they would have been merge in the first step
if (count < chunk
Combination
.size) {
if (count < chunk
sSet
.size) {
for (const set of setArray) {
for (const set of setArray) {
if (
chunkCombination.isSubset(
set)) {
if (
isSubset(chunksSet,
set)) {
array.push(set);
array.push(set);
}
}
}
}
}
}
}
}
combinationsCache.set(chunkCombination, array);
for (const chunk of singleChunkSets) {
if (chunksSet.has(chunk)) {
array.push(chunk);
}
}
combinationsCache.set(key, array);
return array;
return array;
};
};
};
};
const getCombinationsFactory = memoize(() => {
const getCombinationsFactory = memoize(() => {
return createGetCombinations(getChunkCombinationsByCount());
const { chunkSetsInGraph, singleChunkSets } = getChunkSetsInGraph();
return createGetCombinations(
chunkSetsInGraph,
singleChunkSets,
getChunkSetsByCount()
);
});
});
const getCombinations = key => getCombinationsFactory()(key);
const getCombinations = key => getCombinationsFactory()(key);
const getExportsCombinationsFactory = memoize(() => {
const getExportsCombinationsFactory = memoize(() => {
return createGetCombinations(getExportsChunkCombinationsByCount());
const { chunkSetsInGraph, singleChunkSets } =
getExportsChunkSetsInGraph();
return createGetCombinations(
chunkSetsInGraph,
singleChunkSets,
getExportsChunkSetsByCount()
);
});
});
const getExportsCombinations = key =>
const getExportsCombinations = key =>
getExportsCombinationsFactory()(key);
getExportsCombinationsFactory()(key);
/** @type {WeakMap<ChunkCombination, WeakMap<ChunkFilterFunction, ChunkCombination>>} */
/**
* @typedef {Object} SelectedChunksResult
* @property {Chunk[]} chunks the list of chunks
* @property {bigint | Chunk} key a key of the list
*/
/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFunction, SelectedChunksResult>>} */
const selectedChunksCacheByChunksSet = new WeakMap();
const selectedChunksCacheByChunksSet = new WeakMap();
/**
/**
* get
chunks
by applying the filter function to the list
* get
list and key
by applying the filter function to the list
* It is cached for performance reasons
* It is cached for performance reasons
* @param {
ChunkCombination
} chunks list of chunks
* @param {
Set<Chunk> | Chunk
} chunks list of chunks
* @param {ChunkFilterFunction} chunkFilter filter function for chunks
* @param {ChunkFilterFunction} chunkFilter filter function for chunks
* @returns {
ChunkCombination} selected chunks
* @returns {
SelectedChunksResult} list and key
*/
*/
const getSelectedChunks = (chunks, chunkFilter) => {
const getSelectedChunks = (chunks, chunkFilter) => {
let entry = selectedChunksCacheByChunksSet.get(chunks);
let entry = selectedChunksCacheByChunksSet.get(chunks);
...
@@ -105829,16 +105710,22 @@ module.exports = class SplitChunksPlugin {
...
@@ -105829,16 +105710,22 @@ module.exports = class SplitChunksPlugin {
entry = new WeakMap();
entry = new WeakMap();
selectedChunksCacheByChunksSet.set(chunks, entry);
selectedChunksCacheByChunksSet.set(chunks, entry);
}
}
/** @type {
ChunkCombination
} */
/** @type {
SelectedChunksResult
} */
let entry2 = entry.get(chunkFilter);
let entry2 = entry.get(chunkFilter);
if (entry2 === undefined) {
if (entry2 === undefined) {
/** @type {ChunkCombination} */
/** @type {Chunk[]} */
let selectedChunks = ChunkCombination.empty;
const selectedChunks = [];
for (const chunk of chunks.chunksIterable) {
if (chunks instanceof Chunk) {
if (chunkFilter(chunk))
if (chunkFilter(chunks)) selectedChunks.push(chunks);
selectedChunks = selectedChunks.with(chunk);
} else {
for (const chunk of chunks) {
if (chunkFilter(chunk)) selectedChunks.push(chunk);
}
}
}
entry2 = selectedChunks;
entry2 = {
chunks: selectedChunks,
key: getKey(selectedChunks)
};
entry.set(chunkFilter, entry2);
entry.set(chunkFilter, entry2);
}
}
return entry2;
return entry2;
...
@@ -105857,7 +105744,8 @@ module.exports = class SplitChunksPlugin {
...
@@ -105857,7 +105744,8 @@ module.exports = class SplitChunksPlugin {
/**
/**
* @param {CacheGroup} cacheGroup the current cache group
* @param {CacheGroup} cacheGroup the current cache group
* @param {number} cacheGroupIndex the index of the cache group of ordering
* @param {number} cacheGroupIndex the index of the cache group of ordering
* @param {ChunkCombination} selectedChunks chunks selected for this module
* @param {Chunk[]} selectedChunks chunks selected for this module
* @param {bigint | Chunk} selectedChunksKey a key of selectedChunks
* @param {Module} module the current module
* @param {Module} module the current module
* @returns {void}
* @returns {void}
*/
*/
...
@@ -105865,20 +105753,25 @@ module.exports = class SplitChunksPlugin {
...
@@ -105865,20 +105753,25 @@ module.exports = class SplitChunksPlugin {
cacheGroup,
cacheGroup,
cacheGroupIndex,
cacheGroupIndex,
selectedChunks,
selectedChunks,
selectedChunksKey,
module
module
) => {
) => {
// Break if minimum number of chunks is not reached
// Break if minimum number of chunks is not reached
if (selectedChunks.
size
< cacheGroup.minChunks) return;
if (selectedChunks.
length
< cacheGroup.minChunks) return;
// Determine name for split chunk
// Determine name for split chunk
const name = cacheGroup.getName(
const name = cacheGroup.getName(
module,
module,
selectedChunks
.getChunks()
,
selectedChunks,
cacheGroup.key
cacheGroup.key
);
);
// Check if the name is ok
// Check if the name is ok
const existingChunk = compilation.namedChunks.get(name);
const existingChunk = compilation.namedChunks.get(name);
if (existingChunk) {
if (existingChunk) {
const parentValidationKey = `${name}|${selectedChunks.debugId}`;
const parentValidationKey = `${name}|${
typeof selectedChunksKey === "bigint"
? selectedChunksKey
: selectedChunksKey.debugId
}`;
const valid = alreadyValidatedParents.get(parentValidationKey);
const valid = alreadyValidatedParents.get(parentValidationKey);
if (valid === false) return;
if (valid === false) return;
if (valid === undefined) {
if (valid === undefined) {
...
@@ -105887,7 +105780,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -105887,7 +105780,7 @@ module.exports = class SplitChunksPlugin {
let isInAllParents = true;
let isInAllParents = true;
/** @type {Set<ChunkGroup>} */
/** @type {Set<ChunkGroup>} */
const queue = new Set();
const queue = new Set();
for (const chunk of selectedChunks
.chunksIterable
) {
for (const chunk of selectedChunks) {
for (const group of chunk.groupsIterable) {
for (const group of chunk.groupsIterable) {
queue.add(group);
queue.add(group);
}
}
...
@@ -105933,7 +105826,9 @@ module.exports = class SplitChunksPlugin {
...
@@ -105933,7 +105826,9 @@ module.exports = class SplitChunksPlugin {
// This automatically merges equal names
// This automatically merges equal names
const key =
const key =
cacheGroup.key +
cacheGroup.key +
(name ? ` name:${name}` : ` chunks:${selectedChunks.debugId}`);
(name
? ` name:${name}`
: ` chunks:${keyToString(selectedChunksKey)}`);
// Add module to maps
// Add module to maps
let info = chunksInfoMap.get(key);
let info = chunksInfoMap.get(key);
if (info === undefined) {
if (info === undefined) {
...
@@ -105948,9 +105843,9 @@ module.exports = class SplitChunksPlugin {
...
@@ -105948,9 +105843,9 @@ module.exports = class SplitChunksPlugin {
cacheGroupIndex,
cacheGroupIndex,
name,
name,
sizes: {},
sizes: {},
chunks:
ChunkCombination.empty
,
chunks:
new Set()
,
reuseableChunks: new Set(),
reuseableChunks: new Set(),
chunk
Combination
s: new Set()
chunk
sKey
s: new Set()
})
})
);
);
}
}
...
@@ -105961,10 +105856,12 @@ module.exports = class SplitChunksPlugin {
...
@@ -105961,10 +105856,12 @@ module.exports = class SplitChunksPlugin {
info.sizes[type] = (info.sizes[type] || 0) + module.size(type);
info.sizes[type] = (info.sizes[type] || 0) + module.size(type);
}
}
}
}
const oldChunksKeysSize = info.chunkCombinations.size;
const oldChunksKeysSize = info.chunksKeys.size;
info.chunkCombinations.add(selectedChunks);
info.chunksKeys.add(selectedChunksKey);
if (oldChunksKeysSize !== info.chunkCombinations.size) {
if (oldChunksKeysSize !== info.chunksKeys.size) {
info.chunks = info.chunks.withAll(selectedChunks);
for (const chunk of selectedChunks) {
info.chunks.add(chunk);
}
}
}
};
};
...
@@ -105985,56 +105882,50 @@ module.exports = class SplitChunksPlugin {
...
@@ -105985,56 +105882,50 @@ module.exports = class SplitChunksPlugin {
continue;
continue;
}
}
const chunkCombination =
// Prepare some values (usedExports = false)
chunkGraph.getModuleChunkCombination(module);
const getCombs = memoize(() => {
const chunks = chunkGraph.getModuleChunksIterable(module);
let cacheGroupIndex = 0;
const chunksKey = getKey(chunks);
for (const cacheGroupSource of cacheGroups) {
return getCombinations(chunksKey);
const cacheGroup = this._getCacheGroup(cacheGroupSource);
});
// Break if minimum number of chunks is not reached
if (chunkCombination.size < cacheGroup.minChunks) continue;
/** @type {Iterable<ChunkCombination>} */
// Prepare some values (usedExports = true)
let combs;
const getCombsByUsedExports = memoize(() => {
if (cacheGroup.usedExports) {
// fill the groupedByExportsMap
// fill the groupedByExportsMap
getExportsChunkCombination
sInGraph();
getExportsChunkSet
sInGraph();
/** @type {Set<ChunkCombination
>} */
/** @type {Set<Set<Chunk> | Chunk
>} */
const set = new Set();
const set = new Set();
const groupedByUsedExports = groupedByExportsMap.get(module);
const groupedByUsedExports = groupedByExportsMap.get(module);
for (const chunkCombination of groupedByUsedExports) {
for (const chunks of groupedByUsedExports) {
const preSelectedChunks = getSelectedChunks(
const chunksKey = getKey(chunks);
chunkCombination,
for (const comb of getExportsCombinations(chunksKey))
cacheGroup.chunksFilter
);
// Break if minimum number of chunks is not reached
if (preSelectedChunks.size < cacheGroup.minChunks) continue;
for (const comb of getExportsCombinations(preSelectedChunks))
set.add(comb);
set.add(comb);
}
}
combs = set;
return set;
} else {
});
const preSelectedChunks = getSelectedChunks(
chunkCombination,
cacheGroup.chunksFilter
);
// Break if minimum number of chunks is not reached
if (preSelectedChunks.size < cacheGroup.minChunks) continue;
combs = getCombinations(preSelectedChunks);
let cacheGroupIndex = 0;
}
for (const cacheGroupSource of cacheGroups) {
const cacheGroup = this._getCacheGroup(cacheGroupSource);
const combs = cacheGroup.usedExports
? getCombsByUsedExports()
: getCombs();
// For all combination of chunk selection
// For all combination of chunk selection
for (const
selectedChunks
of combs) {
for (const
chunkCombination
of combs) {
// Break if minimum number of chunks is not reached
// Break if minimum number of chunks is not reached
const count = chunkCombination.size;
const count =
chunkCombination instanceof Chunk ? 1 : chunkCombination.size;
if (count < cacheGroup.minChunks) continue;
if (count < cacheGroup.minChunks) continue;
// Select chunks by configuration
const { chunks: selectedChunks, key: selectedChunksKey } =
getSelectedChunks(chunkCombination, cacheGroup.chunksFilter);
addModuleToChunksInfoMap(
addModuleToChunksInfoMap(
cacheGroup,
cacheGroup,
cacheGroupIndex,
cacheGroupIndex,
selectedChunks,
selectedChunks,
selectedChunksKey,
module
module
);
);
}
}
...
@@ -106126,12 +106017,12 @@ module.exports = class SplitChunksPlugin {
...
@@ -106126,12 +106017,12 @@ module.exports = class SplitChunksPlugin {
const chunkByName = compilation.namedChunks.get(chunkName);
const chunkByName = compilation.namedChunks.get(chunkName);
if (chunkByName !== undefined) {
if (chunkByName !== undefined) {
newChunk = chunkByName;
newChunk = chunkByName;
const
newChunks = item.chunks.without(newChunk)
;
const
oldSize = item.chunks.size
;
i
sExistingChunk = newChunks !== item.chunks
;
i
tem.chunks.delete(newChunk)
;
i
f (isExistingChunk) item.chunks = newChunks
;
i
sExistingChunk = item.chunks.size !== oldSize
;
}
}
} else if (item.cacheGroup.reuseExistingChunk) {
} else if (item.cacheGroup.reuseExistingChunk) {
outer: for (const chunk of item.chunks
.chunksIterable
) {
outer: for (const chunk of item.chunks) {
if (
if (
chunkGraph.getNumberOfChunkModules(chunk) !==
chunkGraph.getNumberOfChunkModules(chunk) !==
item.modules.size
item.modules.size
...
@@ -106165,7 +106056,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106165,7 +106056,7 @@ module.exports = class SplitChunksPlugin {
}
}
}
}
if (newChunk) {
if (newChunk) {
item.chunks
= item.chunks.without
(newChunk);
item.chunks
.delete
(newChunk);
chunkName = undefined;
chunkName = undefined;
isExistingChunk = true;
isExistingChunk = true;
isReusedWithAllModules = true;
isReusedWithAllModules = true;
...
@@ -106176,7 +106067,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106176,7 +106067,7 @@ module.exports = class SplitChunksPlugin {
item.cacheGroup._conditionalEnforce &&
item.cacheGroup._conditionalEnforce &&
checkMinSize(item.sizes, item.cacheGroup.enforceSizeThreshold);
checkMinSize(item.sizes, item.cacheGroup.enforceSizeThreshold);
let usedChunks = item.chunks
;
const usedChunks = new Set(item.chunks)
;
// Check if maxRequests condition can be fulfilled
// Check if maxRequests condition can be fulfilled
if (
if (
...
@@ -106184,7 +106075,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106184,7 +106075,7 @@ module.exports = class SplitChunksPlugin {
(Number.isFinite(item.cacheGroup.maxInitialRequests) ||
(Number.isFinite(item.cacheGroup.maxInitialRequests) ||
Number.isFinite(item.cacheGroup.maxAsyncRequests))
Number.isFinite(item.cacheGroup.maxAsyncRequests))
) {
) {
for (const chunk of usedChunks
.chunksIterable
) {
for (const chunk of usedChunks) {
// respect max requests
// respect max requests
const maxRequests = chunk.isOnlyInitial()
const maxRequests = chunk.isOnlyInitial()
? item.cacheGroup.maxInitialRequests
? item.cacheGroup.maxInitialRequests
...
@@ -106198,28 +106089,30 @@ module.exports = class SplitChunksPlugin {
...
@@ -106198,28 +106089,30 @@ module.exports = class SplitChunksPlugin {
isFinite(maxRequests) &&
isFinite(maxRequests) &&
getRequests(chunk) >= maxRequests
getRequests(chunk) >= maxRequests
) {
) {
usedChunks
= usedChunks.without
(chunk);
usedChunks
.delete
(chunk);
}
}
}
}
}
}
outer: for (const chunk of usedChunks
.chunksIterable
) {
outer: for (const chunk of usedChunks) {
for (const module of item.modules) {
for (const module of item.modules) {
if (chunkGraph.isModuleInChunk(module, chunk)) continue outer;
if (chunkGraph.isModuleInChunk(module, chunk)) continue outer;
}
}
usedChunks
= usedChunks.without
(chunk);
usedChunks
.delete
(chunk);
}
}
// Were some (invalid) chunks removed from usedChunks?
// Were some (invalid) chunks removed from usedChunks?
// => readd all modules to the queue, as things could have been changed
// => readd all modules to the queue, as things could have been changed
if (usedChunks
!== item.chunks
) {
if (usedChunks
.size < item.chunks.size
) {
if (isExistingChunk) usedChunks
= usedChunks.with
(newChunk);
if (isExistingChunk) usedChunks
.add
(newChunk);
if (usedChunks.size >= item.cacheGroup.minChunks) {
if (usedChunks.size >= item.cacheGroup.minChunks) {
const chunksArr = Array.from(usedChunks);
for (const module of item.modules) {
for (const module of item.modules) {
addModuleToChunksInfoMap(
addModuleToChunksInfoMap(
item.cacheGroup,
item.cacheGroup,
item.cacheGroupIndex,
item.cacheGroupIndex,
usedChunks,
chunksArr,
getKey(usedChunks),
module
module
);
);
}
}
...
@@ -106233,7 +106126,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106233,7 +106126,7 @@ module.exports = class SplitChunksPlugin {
item.cacheGroup._validateRemainingSize &&
item.cacheGroup._validateRemainingSize &&
usedChunks.size === 1
usedChunks.size === 1
) {
) {
const [chunk] = usedChunks
.chunksIterable
;
const [chunk] = usedChunks;
let chunkSizes = Object.create(null);
let chunkSizes = Object.create(null);
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
for (const module of chunkGraph.getChunkModulesIterable(chunk)) {
if (!item.modules.has(module)) {
if (!item.modules.has(module)) {
...
@@ -106267,7 +106160,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106267,7 +106160,7 @@ module.exports = class SplitChunksPlugin {
newChunk = compilation.addChunk(chunkName);
newChunk = compilation.addChunk(chunkName);
}
}
// Walk through all chunks
// Walk through all chunks
for (const chunk of usedChunks
.chunksIterable
) {
for (const chunk of usedChunks) {
// Add graph connections for splitted chunk
// Add graph connections for splitted chunk
chunk.split(newChunk);
chunk.split(newChunk);
}
}
...
@@ -106297,14 +106190,14 @@ module.exports = class SplitChunksPlugin {
...
@@ -106297,14 +106190,14 @@ module.exports = class SplitChunksPlugin {
// Add module to new chunk
// Add module to new chunk
chunkGraph.connectChunkAndModule(newChunk, module);
chunkGraph.connectChunkAndModule(newChunk, module);
// Remove module from used chunks
// Remove module from used chunks
for (const chunk of usedChunks
.chunksIterable
) {
for (const chunk of usedChunks) {
chunkGraph.disconnectChunkAndModule(chunk, module);
chunkGraph.disconnectChunkAndModule(chunk, module);
}
}
}
}
} else {
} else {
// Remove all modules from used chunks
// Remove all modules from used chunks
for (const module of item.modules) {
for (const module of item.modules) {
for (const chunk of usedChunks
.chunksIterable
) {
for (const chunk of usedChunks) {
chunkGraph.disconnectChunkAndModule(chunk, module);
chunkGraph.disconnectChunkAndModule(chunk, module);
}
}
}
}
...
@@ -106346,7 +106239,7 @@ module.exports = class SplitChunksPlugin {
...
@@ -106346,7 +106239,7 @@ module.exports = class SplitChunksPlugin {
// remove all modules from other entries and update size
// remove all modules from other entries and update size
for (const [key, info] of chunksInfoMap) {
for (const [key, info] of chunksInfoMap) {
if (i
nfo.chunks.hasSharedChunks(
usedChunks)) {
if (i
sOverlap(info.chunks,
usedChunks)) {
// update modules and total size
// update modules and total size
// may remove it from the map when < minSize
// may remove it from the map when < minSize
let updated = false;
let updated = false;
...
@@ -130349,7 +130242,6 @@ module.exports = WebAssemblyGenerator;
...
@@ -130349,7 +130242,6 @@ module.exports = WebAssemblyGenerator;
const WebpackError = __webpack_require__(68422);
const WebpackError = __webpack_require__(68422);
const { someInIterable } = __webpack_require__(31065);
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module")} Module */
...
@@ -130387,11 +130279,7 @@ const getInitialModuleChains = (
...
@@ -130387,11 +130279,7 @@ const getInitialModuleChains = (
for (const connection of moduleGraph.getIncomingConnections(head)) {
for (const connection of moduleGraph.getIncomingConnections(head)) {
const newHead = connection.originModule;
const newHead = connection.originModule;
if (newHead) {
if (newHead) {
if (
if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial()))
!someInIterable(chunkGraph.getModuleChunksIterable(newHead), c =>
c.canBeInitial()
)
)
continue;
continue;
final = false;
final = false;
if (alreadyReferencedModules.has(newHead)) continue;
if (alreadyReferencedModules.has(newHead)) continue;
packages/next/package.json
View file @
4d50ff30
...
@@ -249,7 +249,7 @@
...
@@ -249,7 +249,7 @@
"webpack-sources1"
:
"npm:webpack-sources@1.4.3"
,
"webpack-sources1"
:
"npm:webpack-sources@1.4.3"
,
"webpack-sources3"
:
"npm:webpack-sources@3.2.0"
,
"webpack-sources3"
:
"npm:webpack-sources@3.2.0"
,
"webpack4"
:
"npm:webpack@4.44.1"
,
"webpack4"
:
"npm:webpack@4.44.1"
,
"webpack5"
:
"npm:webpack@5.58.
0
"
"webpack5"
:
"npm:webpack@5.58.
1
"
},
},
"resolutions"
:
{
"resolutions"
:
{
"browserslist"
:
"4.16.6"
,
"browserslist"
:
"4.16.6"
,
...
...
yarn.lock
View file @
4d50ff30
...
@@ -19703,10 +19703,10 @@ webpack-sources@^3.2.0:
...
@@ -19703,10 +19703,10 @@ webpack-sources@^3.2.0:
watchpack "^1.7.4"
watchpack "^1.7.4"
webpack-sources "^1.4.1"
webpack-sources "^1.4.1"
"webpack5@npm:webpack@5.58.
0
":
"webpack5@npm:webpack@5.58.
1
":
version "5.58.
0
"
version "5.58.
1
"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.58.
0.tgz#9ec621cf8534f23c25e779e7c35dfde1211d5ccb
"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.58.
1.tgz#df8aad72b617a9d0db8c89d4f410784ee93320d7
"
integrity sha512-
xc2k5MLbR1iah24Z5xUm1nBh1PZXEdUnrX6YkTSOScq/VWbl5JCLREXJzGYqEAUbIO8tZI+Dzv82lGtnuUnVCQ
==
integrity sha512-
4Z/dmbTU+VmkCb2XNgW7wkE5TfEcSooclprn/UEuVeAkwHhn07OcgUsyaKHGtCY/VobjnsYBlyhKeMLiSoOqPg
==
dependencies:
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.50"
"@types/estree" "^0.0.50"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment