From 45631b18b762026ba689c163f005de9042fcdafd Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Thu, 31 Aug 2023 12:01:07 +0900 Subject: [PATCH 1/2] fix: use relative path for sources field --- packages/vite/src/node/server/send.ts | 6 +++++- playground/js-sourcemap/__tests__/js-sourcemap.spec.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/server/send.ts b/packages/vite/src/node/server/send.ts index 36f70049c47e88..5582521146e1b1 100644 --- a/packages/vite/src/node/server/send.ts +++ b/packages/vite/src/node/server/send.ts @@ -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' @@ -69,7 +70,10 @@ export function send( content = getCodeWithSourcemap( type, content.toString(), - ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }), + ms.generateMap({ + source: path.basename(urlWithoutTimestamp), + hires: 'boundary', + }), ) } } diff --git a/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts b/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts index 8d1c9d46bc551d..00080aa7abfd23 100644 --- a/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts +++ b/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts @@ -18,7 +18,7 @@ if (!isBuild) { { "mappings": "AAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;", "sources": [ - "/foo.js", + "foo.js", ], "version": 3, } From 00a78a582bb9cf2382bf71d9c086269ab59c5923 Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Thu, 31 Aug 2023 13:42:46 +0900 Subject: [PATCH 2/2] fix: include content --- packages/vite/src/node/server/send.ts | 1 + playground/js-sourcemap/__tests__/js-sourcemap.spec.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/packages/vite/src/node/server/send.ts b/packages/vite/src/node/server/send.ts index 5582521146e1b1..564ab54d8de85f 100644 --- a/packages/vite/src/node/server/send.ts +++ b/packages/vite/src/node/server/send.ts @@ -73,6 +73,7 @@ export function send( ms.generateMap({ source: path.basename(urlWithoutTimestamp), hires: 'boundary', + includeContent: true, }), ) } diff --git a/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts b/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts index 00080aa7abfd23..06d073fe5b1e9e 100644 --- a/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts +++ b/playground/js-sourcemap/__tests__/js-sourcemap.spec.ts @@ -20,6 +20,10 @@ if (!isBuild) { "sources": [ "foo.js", ], + "sourcesContent": [ + "export const foo = 'foo' + ", + ], "version": 3, } `)