From a04983d75c847596f9aad14a43b8067e44e62c97 Mon Sep 17 00:00:00 2001 From: Ming Date: Tue, 31 Oct 2023 14:14:52 +0800 Subject: [PATCH] fix: should not filter mf entrys when compiler is rspack (#4886) --- .changeset/yellow-suits-applaud.md | 6 +++ .../shared/bundlerPlugins/RouterPlugin.ts | 37 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 .changeset/yellow-suits-applaud.md diff --git a/.changeset/yellow-suits-applaud.md b/.changeset/yellow-suits-applaud.md new file mode 100644 index 000000000000..286f7d49b607 --- /dev/null +++ b/.changeset/yellow-suits-applaud.md @@ -0,0 +1,6 @@ +--- +'@modern-js/app-tools': patch +--- + +fix: should not filter mf entrys when compiler is rspack +fix: 不应该过滤 mf entry,当 compiler 是 rspack 的时候 diff --git a/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts b/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts index 6967110e7f17..62c9c7da9c5b 100644 --- a/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts +++ b/packages/solutions/app-tools/src/builder/shared/bundlerPlugins/RouterPlugin.ts @@ -106,6 +106,7 @@ export class RouterPlugin { } const { webpack } = compiler; + const isRspack = webpack.rspackVersion; const { Compilation, sources } = webpack; const { RawSource } = sources; @@ -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];