From 72bec587df1570e3caf3f339c1f93ad224e24126 Mon Sep 17 00:00:00 2001 From: wmzy <1256573276@qq.com> Date: Fri, 23 Jul 2021 13:19:44 +0800 Subject: [PATCH] fix: transform without `sourcesContent` --- .../vite/src/node/server/pluginContainer.ts | 18 +++++++++++------- packages/vite/src/node/utils.ts | 7 ++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index 8dd2cb4cb18e2c..deed66ab734e30 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -341,13 +341,17 @@ export async function createPluginContainer( if (!combinedMap) { combinedMap = m as SourceMap } else { - combinedMap = combineSourcemaps(this.filename, [ - { - ...(m as RawSourceMap), - sourcesContent: combinedMap.sourcesContent - }, - combinedMap as RawSourceMap - ]) as SourceMap + combinedMap = combineSourcemaps( + this.filename, + [ + { + ...(m as RawSourceMap), + sourcesContent: combinedMap.sourcesContent + }, + combinedMap as RawSourceMap + ], + true + ) as SourceMap } } if (!combinedMap) { diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index e77f9a4db89ba6..bd2185ec9abbd2 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -433,7 +433,8 @@ const nullSourceMap: RawSourceMap = { } export function combineSourcemaps( filename: string, - sourcemapList: Array + sourcemapList: Array, + excludeContent = true ): RawSourceMap { if ( sourcemapList.length === 0 || @@ -448,7 +449,7 @@ export function combineSourcemaps( const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === undefined if (useArrayInterface) { - map = remapping(sourcemapList, () => null, true) + map = remapping(sourcemapList, () => null, excludeContent) } else { map = remapping( sourcemapList[0], @@ -459,7 +460,7 @@ export function combineSourcemaps( return { ...nullSourceMap } } }, - true + excludeContent ) } if (!map.file) {