Skip to content

Commit

Permalink
Land reverted fix for chunk file names (#48625)
Browse files Browse the repository at this point in the history
This PR re-adds #48583, which was accidentally reverted in #48589
(unrelated) somehow.
  • Loading branch information
shuding authored Apr 20, 2023
1 parent 82a01c1 commit 1f6a45d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions packages/next/src/build/webpack/plugins/flight-manifest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ export class ClientReferenceManifestPlugin {
cssFiles: {},
clientModules: {},
}
const dev = this.dev

const clientRequestsSet = new Set()

Expand Down Expand Up @@ -256,13 +255,18 @@ export class ClientReferenceManifestPlugin {
return null
}

return (
requiredChunk.id +
':' +
(requiredChunk.name || requiredChunk.id) +
(dev ? '' : '-' + requiredChunk.hash)
)
// Get the actual chunk file names from the chunk file list.
// It's possible that the chunk is generated via `import()`, in
// that case the chunk file name will be '[name].[contenthash]'
// instead of '[name]-[chunkhash]'.
return [...requiredChunk.files].map((file) => {
// It's possible that a chunk also emits CSS files, that will
// be handled separatedly.
if (!file.endsWith('.js')) return null
return requiredChunk.id + ':' + file
})
})
.flat()
.filter(nonNullable)
}
const requiredChunks = getAppPathRequiredChunks()
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/client/app-index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ self.__next_require__ =
// eslint-disable-next-line no-undef
;(self as any).__next_chunk_load__ = (chunk: string) => {
if (!chunk) return Promise.resolve()
const [chunkId, chunkFileName] = chunk.split(':')
chunkFilenameMap[chunkId] = `static/chunks/${chunkFileName}.js`
const [chunkId, chunkFilePath] = chunk.split(':')
chunkFilenameMap[chunkId] = chunkFilePath

// @ts-ignore
// eslint-disable-next-line no-undef
Expand Down

0 comments on commit 1f6a45d

Please sign in to comment.