Skip to content

Commit

Permalink
fix: use preliminaryFileName for chunkMetadata key
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 10, 2024
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
Expand Up @@ -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(),
})
Expand All @@ -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.