Skip to content

Commit

Permalink
fix: should not filter mf entrys when compiler is rspack (#4886)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe authored Oct 31, 2023
1 parent e93fac9 commit a04983d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
6 changes: 6 additions & 0 deletions .changeset/yellow-suits-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/app-tools': patch
---

fix: should not filter mf entrys when compiler is rspack
fix: 不应该过滤 mf entry,当 compiler 是 rspack 的时候
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class RouterPlugin {
}

const { webpack } = compiler;
const isRspack = webpack.rspackVersion;
const { Compilation, sources } = webpack;
const { RawSource } = sources;

Expand Down Expand Up @@ -205,22 +206,28 @@ export class RouterPlugin {
};

const entryNames = Array.from(compilation.entrypoints.keys());
const orignalEntryIds = Object.keys(compilation.options.entry).map(
entryName => {
const chunk = compilation.namedChunks.get(
entryName,
) as webpack.Chunk;
if (chunk) {
return chunk.id;
}
return entryName;
},
);
const entryChunks = this.getEntryChunks(compilation, chunks).filter(
chunk => orignalEntryIds.includes(chunk.id as string),
);
const entryChunkFiles = this.getEntryChunkFiles(entryChunks);
let entryChunks = [];
if (isRspack) {
entryChunks = this.getEntryChunks(compilation, chunks);
} else {
const orignalEntryIds = Object.keys(compilation.options.entry).map(
entryName => {
const chunk = compilation.namedChunks.get(
entryName,
) as webpack.Chunk;
if (chunk) {
return chunk.id;
}
return entryName;
},
);

entryChunks = this.getEntryChunks(compilation, chunks).filter(
chunk => orignalEntryIds.includes(chunk.id as string),
);
}

const entryChunkFiles = this.getEntryChunkFiles(entryChunks);
const entryChunkFileIds = entryChunks.map(chunk => chunk.id);
for (let i = 0; i < entryChunkFiles.length; i++) {
const entryName = entryNames[i];
Expand Down

0 comments on commit a04983d

Please sign in to comment.