From 17149f425f89201cea4089166e3dc92013a039ac Mon Sep 17 00:00:00 2001 From: Adam Weiss Date: Fri, 3 May 2024 20:48:31 -0400 Subject: [PATCH 1/2] feat: Improve sourcemap compatibility for vue2 --- packages/vite/src/node/server/sourcemap.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index 741ae4331ade22..9b7b7943802176 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -3,7 +3,7 @@ import fsp from 'node:fs/promises' import convertSourceMap from 'convert-source-map' import type { ExistingRawSourceMap, SourceMap } from 'rollup' import type { Logger } from '../logger' -import { blankReplacer, createDebugger } from '../utils' +import { blankReplacer, createDebugger, fsPathFromUrl } from '../utils' const debug = createDebugger('vite:sourcemap', { onlyWhenFocused: true, @@ -53,7 +53,7 @@ export async function injectSourcesContent( // inject content from source file when sourcesContent is null sourceRootPromise ??= computeSourceRoute(map, file) const sourceRoot = await sourceRootPromise - let resolvedSourcePath = decodeURI(sourcePath) + let resolvedSourcePath = fsPathFromUrl(decodeURI(sourcePath)) if (sourceRoot) { resolvedSourcePath = path.resolve(sourceRoot, resolvedSourcePath) } From 083290468292ee13ffb680cf16bb3736f8824978 Mon Sep 17 00:00:00 2001 From: Adam Weiss Date: Sat, 4 May 2024 08:40:01 -0400 Subject: [PATCH 2/2] Use cleanUrl --- packages/vite/src/node/server/sourcemap.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/server/sourcemap.ts b/packages/vite/src/node/server/sourcemap.ts index 9b7b7943802176..684dff128e597d 100644 --- a/packages/vite/src/node/server/sourcemap.ts +++ b/packages/vite/src/node/server/sourcemap.ts @@ -3,7 +3,8 @@ import fsp from 'node:fs/promises' import convertSourceMap from 'convert-source-map' import type { ExistingRawSourceMap, SourceMap } from 'rollup' import type { Logger } from '../logger' -import { blankReplacer, createDebugger, fsPathFromUrl } from '../utils' +import { blankReplacer, createDebugger } from '../utils' +import { cleanUrl } from '../../shared/utils' const debug = createDebugger('vite:sourcemap', { onlyWhenFocused: true, @@ -53,7 +54,7 @@ export async function injectSourcesContent( // inject content from source file when sourcesContent is null sourceRootPromise ??= computeSourceRoute(map, file) const sourceRoot = await sourceRootPromise - let resolvedSourcePath = fsPathFromUrl(decodeURI(sourcePath)) + let resolvedSourcePath = cleanUrl(decodeURI(sourcePath)) if (sourceRoot) { resolvedSourcePath = path.resolve(sourceRoot, resolvedSourcePath) }