Skip to content

Commit 55cfd04

Browse files
authored
perf: skip sourcemap generation for renderChunk hook of import-analysis-build plugin (#19921)
1 parent ffab442 commit 55cfd04

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

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

+5-12
Original file line numberDiff line numberDiff line change
@@ -403,18 +403,11 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
403403
if (code.indexOf(isModernFlag) > -1) {
404404
const re = new RegExp(isModernFlag, 'g')
405405
const isModern = String(format === 'es')
406-
if (this.environment.config.build.sourcemap) {
407-
const s = new MagicString(code)
408-
let match: RegExpExecArray | null
409-
while ((match = re.exec(code))) {
410-
s.update(match.index, match.index + isModernFlag.length, isModern)
411-
}
412-
return {
413-
code: s.toString(),
414-
map: s.generateMap({ hires: 'boundary' }),
415-
}
416-
} else {
417-
return code.replace(re, isModern)
406+
const isModernWithPadding =
407+
isModern + ' '.repeat(isModernFlag.length - isModern.length)
408+
return {
409+
code: code.replace(re, isModernWithPadding),
410+
map: null,
418411
}
419412
}
420413
return null

0 commit comments

Comments
 (0)