Skip to content

Commit 1bfe21b

Browse files
authored
refactor: simplify manifest plugin code (#18890)
1 parent bfbb130 commit 1bfe21b

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

packages/vite/src/node/plugins/manifest.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function manifestPlugin(): Plugin {
5959
function getChunkName(chunk: OutputChunk) {
6060
return (
6161
getChunkOriginalFileName(chunk, root, format) ??
62-
`_` + path.basename(chunk.fileName)
62+
`_${path.basename(chunk.fileName)}`
6363
)
6464
}
6565

@@ -142,8 +142,6 @@ export function manifestPlugin(): Plugin {
142142
}
143143
}
144144

145-
const fileNameToAsset = new Map<string, ManifestChunk>()
146-
147145
for (const file in bundle) {
148146
const chunk = bundle[file]
149147
if (chunk.type === 'chunk') {
@@ -153,7 +151,7 @@ export function manifestPlugin(): Plugin {
153151
const src =
154152
chunk.originalFileNames.length > 0
155153
? chunk.originalFileNames[0]
156-
: '_' + path.basename(chunk.fileName)
154+
: `_${path.basename(chunk.fileName)}`
157155
const isEntry = entryCssAssetFileNames.has(chunk.fileName)
158156
const asset = createAsset(chunk, src, isEntry)
159157

@@ -162,7 +160,6 @@ export function manifestPlugin(): Plugin {
162160
const file = manifest[src]?.file
163161
if (!(file && endsWithJSRE.test(file))) {
164162
manifest[src] = asset
165-
fileNameToAsset.set(chunk.fileName, asset)
166163
}
167164

168165
for (const originalFileName of chunk.originalFileNames.slice(1)) {
@@ -201,7 +198,7 @@ export function getChunkOriginalFileName(
201198
if (format === 'system' && !chunk.name.includes('-legacy')) {
202199
const ext = path.extname(name)
203200
const endPos = ext.length !== 0 ? -ext.length : undefined
204-
name = name.slice(0, endPos) + `-legacy` + ext
201+
name = `${name.slice(0, endPos)}-legacy${ext}`
205202
}
206203
return name.replace(/\0/g, '')
207204
}

0 commit comments

Comments
 (0)