Skip to content

Commit

Permalink
fix: use relative path for sources field (vitejs#14247)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored and Gaubee committed Sep 13, 2023
1 parent b64c8d6 commit 7fddbb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/vite/src/node/server/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
OutgoingHttpHeaders,
ServerResponse,
} from 'node:http'
import path from 'node:path'
import getEtag from 'etag'
import type { SourceMap } from 'rollup'
import MagicString from 'magic-string'
Expand Down Expand Up @@ -69,7 +70,11 @@ export function send(
content = getCodeWithSourcemap(
type,
content.toString(),
ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }),
ms.generateMap({
source: path.basename(urlWithoutTimestamp),
hires: 'boundary',
includeContent: true,
}),
)
}
}
Expand Down
6 changes: 5 additions & 1 deletion playground/js-sourcemap/__tests__/js-sourcemap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ if (!isBuild) {
{
"mappings": "AAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;",
"sources": [
"/foo.js",
"foo.js",
],
"sourcesContent": [
"export const foo = 'foo'
",
],
"version": 3,
}
Expand Down

0 comments on commit 7fddbb7

Please sign in to comment.