From a2ce20dcdf546d05bcfe533db2bfbd4b8ddfe8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Fri, 25 Mar 2022 04:00:37 +0900 Subject: [PATCH] fix: sourcemap missing source files warning with cached vue (#7442) --- packages/vite/src/node/utils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 4e0f230fd7edfd..edb3410751868a 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -615,13 +615,16 @@ export function combineSourcemaps( // hack for parse broken with normalized absolute paths on windows (C:/path/to/something). // escape them to linux like paths - sourcemapList.forEach((sourcemap) => { - sourcemap.sources = sourcemap.sources.map((source) => + // also avoid mutation here to prevent breaking plugin's using cache to generate sourcemaps like vue (see #7442) + sourcemapList = sourcemapList.map((sourcemap) => { + const newSourcemaps = { ...sourcemap } + newSourcemaps.sources = sourcemap.sources.map((source) => source ? escapeToLinuxLikePath(source) : null ) if (sourcemap.sourceRoot) { - sourcemap.sourceRoot = escapeToLinuxLikePath(sourcemap.sourceRoot) + newSourcemaps.sourceRoot = escapeToLinuxLikePath(sourcemap.sourceRoot) } + return newSourcemaps }) const escapedFilename = escapeToLinuxLikePath(filename)