Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use preliminaryFileName for chunkMetadata key
Browse files Browse the repository at this point in the history
sapphi-red committed Oct 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b1ff879 commit 2f09b9c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vite/src/node/plugins/metadata.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ export function metadataPlugin(): Plugin {
async renderChunk(_code, chunk) {
// Since the chunk come from rust side, mutate it directly will not sync back to rust side.
// The next usage will lost the metadata
chunkMetadataMap.set(chunk.name, {
chunkMetadataMap.set(chunk.fileName, {
importedAssets: new Set(),
importedCss: new Set(),
})
@@ -28,6 +28,7 @@ export function metadataPlugin(): Plugin {
export function getChunkMetadata(
chunk: RenderedChunk | OutputChunk,
): ChunkMetadata | undefined {
// TODO: chunk.name is not unique, use something unique like chunk.preliminaryFileName / chunk.fileName
return chunkMetadataMap.get(chunk.name)
const preliminaryFileName =
'preliminaryFileName' in chunk ? chunk.preliminaryFileName : chunk.fileName
return chunkMetadataMap.get(preliminaryFileName)
}

0 comments on commit 2f09b9c

Please sign in to comment.