Skip to content

Commit

Permalink
fix(enhanced): ensure async boundary works on dependOn
Browse files Browse the repository at this point in the history
  • Loading branch information
ScriptedAlchemy committed Apr 19, 2024
1 parent 03fcb40 commit b12f149
Showing 1 changed file with 8 additions and 22 deletions.
30 changes: 8 additions & 22 deletions packages/enhanced/src/lib/container/AsyncBoundaryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@ class AsyncEntryStartupPlugin {
});
}

getChunkByName(
compilation: Compilation,
dependOn: string[],
): (string | number | undefined)[] {
getChunkByName(compilation: Compilation, dependOn: string[]): Chunk[] {
const byname = [];
for (const name of dependOn) {
const chunk = compilation.namedChunks.get(name);
if (chunk) {
byname.push(chunk.id || chunk.name);
byname.push(chunk);
}
}
return byname;
Expand Down Expand Up @@ -120,15 +117,17 @@ class AsyncEntryStartupPlugin {
compilation.chunkGraph.getTreeRuntimeRequirements(runtimeItem);

const entryOptions = upperContext.chunk.getEntryOptions();
const chunkInitials = Array.from(
// upperContext.chunk.getAllInitialChunks()
const chunkInitialsSet = new Set(
compilation.chunkGraph.getChunkEntryDependentChunksIterable(
upperContext.chunk,
),
);

chunkInitials.push(upperContext.chunk);

chunkInitialsSet.add(upperContext.chunk);
const dependOn = entryOptions?.dependOn || [];
const dependOnChunks = this.getChunkByName(compilation, dependOn);
dependOnChunks.map((c) => chunkInitialsSet.add(c));
const chunkInitials = Array.from(chunkInitialsSet);
const initialChunks = chunkInitials.map((chunk: Chunk) => chunk.id);
const hasRemoteModules = chunkInitials.some((chunk: Chunk) =>
compilation.chunkGraph.getChunkModulesIterableBySourceType(
Expand All @@ -143,19 +142,6 @@ class AsyncEntryStartupPlugin {
),
);

const dependOn = entryOptions?.dependOn || [];
const dependOnIDs = this.getChunkByName(compilation, dependOn);

const chunkIds = Array.from(
compilation.chunkGraph.getChunkEntryDependentChunksIterable(
upperContext.chunk,
),
).map((chunk) => {
return chunk.id;
});

chunkIds.unshift(upperContext.chunk.id);

remotes = this._getRemotes(
compiler.webpack.RuntimeGlobals,
requirements,
Expand Down

0 comments on commit b12f149

Please sign in to comment.