Skip to content

Commit a995907

Browse files
authored
fix: use relative path for sources field (#14247)
1 parent 4bf31e5 commit a995907

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/vite/src/node/server/send.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type {
33
OutgoingHttpHeaders,
44
ServerResponse,
55
} from 'node:http'
6+
import path from 'node:path'
67
import getEtag from 'etag'
78
import type { SourceMap } from 'rollup'
89
import MagicString from 'magic-string'
@@ -69,7 +70,11 @@ export function send(
6970
content = getCodeWithSourcemap(
7071
type,
7172
content.toString(),
72-
ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }),
73+
ms.generateMap({
74+
source: path.basename(urlWithoutTimestamp),
75+
hires: 'boundary',
76+
includeContent: true,
77+
}),
7378
)
7479
}
7580
}

playground/js-sourcemap/__tests__/js-sourcemap.spec.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ if (!isBuild) {
1818
{
1919
"mappings": "AAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;",
2020
"sources": [
21-
"/foo.js",
21+
"foo.js",
22+
],
23+
"sourcesContent": [
24+
"export const foo = 'foo'
25+
",
2226
],
2327
"version": 3,
2428
}

0 commit comments

Comments
 (0)