mirror of https://github.com/webpack/webpack.git
Merge pull request #9032 from Connormiha/optimize-check-availible-chunk
Move isAvailible from method to module
This commit is contained in:
commit
251605e0cc
|
|
@ -109,6 +109,23 @@ const getModulesSizes = modules => {
|
|||
return sizes;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Chunk} a chunk
|
||||
* @param {Chunk} b chunk
|
||||
* @returns {boolean} true, if a is always a parent of b
|
||||
*/
|
||||
const isAvailableChunk = (a, b) => {
|
||||
const queue = new Set(b.groupsIterable);
|
||||
for (const chunkGroup of queue) {
|
||||
if (a.isInGroup(chunkGroup)) continue;
|
||||
if (chunkGroup.isInitial()) return false;
|
||||
for (const parent of chunkGroup.parentsIterable) {
|
||||
queue.add(parent);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
class ChunkGraphModule {
|
||||
constructor() {
|
||||
/** @type {SortableSet<Chunk>} */
|
||||
|
|
@ -622,31 +639,14 @@ class ChunkGraph {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Chunk} a chunk
|
||||
* @param {Chunk} b chunk
|
||||
* @returns {boolean} true, if a is always a parent of b
|
||||
*/
|
||||
const isAvailable = (a, b) => {
|
||||
const queue = new Set(b.groupsIterable);
|
||||
for (const chunkGroup of queue) {
|
||||
if (a.isInGroup(chunkGroup)) continue;
|
||||
if (chunkGroup.isInitial()) return false;
|
||||
for (const parent of chunkGroup.parentsIterable) {
|
||||
queue.add(parent);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const hasRuntimeA = chunkA.hasRuntime();
|
||||
const hasRuntimeB = chunkB.hasRuntime();
|
||||
|
||||
if (hasRuntimeA !== hasRuntimeB) {
|
||||
if (hasRuntimeA) {
|
||||
return isAvailable(chunkA, chunkB);
|
||||
return isAvailableChunk(chunkA, chunkB);
|
||||
} else if (hasRuntimeB) {
|
||||
return isAvailable(chunkB, chunkA);
|
||||
return isAvailableChunk(chunkB, chunkA);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue