Skip to content

Commit 1566f61

Browse files
patak-devpoyoho
andauthoredJun 26, 2022
perf: avoid sourcemap chains during dev (#8796)
Co-authored-by: yoho <panyoho@gmail.com>
1 parent 8bb452d commit 1566f61

File tree

12 files changed

+378
-505
lines changed

12 files changed

+378
-505
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,44 @@
11
// Vitest Snapshot v1
22

33
exports[`fixture > transform 1`] = `
4-
"import * as __vite_glob_1_0 from \\"./modules/a.ts\\"
5-
import * as __vite_glob_1_1 from \\"./modules/b.ts\\"
6-
import * as __vite_glob_1_2 from \\"./modules/index.ts\\"
7-
import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\"
8-
import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\"
9-
import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\"
10-
import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\"
11-
import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\"
12-
import \\"../../../../../../types/importMeta\\";
13-
export const basic = Object.assign({
14-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
15-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),
16-
\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")
17-
});
18-
export const basicEager = Object.assign({
19-
\\"./modules/a.ts\\": __vite_glob_1_0,
20-
\\"./modules/b.ts\\": __vite_glob_1_1,
21-
\\"./modules/index.ts\\": __vite_glob_1_2
22-
});
23-
export const ignore = Object.assign({
24-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
25-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")
26-
});
27-
export const namedEager = Object.assign({
28-
\\"./modules/a.ts\\": __vite_glob_3_0,
29-
\\"./modules/b.ts\\": __vite_glob_3_1,
30-
\\"./modules/index.ts\\": __vite_glob_3_2
31-
});
32-
export const namedDefault = Object.assign({
33-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),
34-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),
35-
\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])
36-
});
37-
export const eagerAs = Object.assign({
38-
\\"./modules/a.ts\\": __vite_glob_5_0,
39-
\\"./modules/b.ts\\": __vite_glob_5_1
40-
});
41-
export const rawImportModule = Object.assign({
42-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),
43-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")
44-
});
45-
export const excludeSelf = Object.assign({
46-
\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")
47-
});
48-
export const customQueryString = Object.assign({
49-
\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom\\")
50-
});
51-
export const customQueryObject = Object.assign({
52-
\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true\\")
53-
});
54-
export const parent = Object.assign({
55-
56-
});
57-
export const rootMixedRelative = Object.assign({
58-
\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url\\").then(m => m[\\"default\\"]),
59-
\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url\\").then(m => m[\\"default\\"]),
60-
\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url\\").then(m => m[\\"default\\"]),
61-
\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url\\").then(m => m[\\"default\\"]),
62-
\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url\\").then(m => m[\\"default\\"]),
63-
\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url\\").then(m => m[\\"default\\"]),
64-
\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url\\").then(m => m[\\"default\\"])
65-
});
66-
export const cleverCwd1 = Object.assign({
67-
\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")
68-
});
69-
export const cleverCwd2 = Object.assign({
70-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
71-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),
72-
\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),
73-
\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")
74-
});
4+
"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"../../../../../../types/importMeta\\";
5+
export const basic = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")});
6+
export const basicEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2});
7+
export const ignore = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")});
8+
export const namedEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2});
9+
export const namedDefault = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])});
10+
export const eagerAs = Object.assign({\\"./modules/a.ts\\": __vite_glob_5_0,\\"./modules/b.ts\\": __vite_glob_5_1});
11+
export const rawImportModule = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")});
12+
export const excludeSelf = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")});
13+
export const customQueryString = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom\\")});
14+
export const customQueryObject = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true\\")});
15+
export const parent = Object.assign({});
16+
export const rootMixedRelative = Object.assign({\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url\\").then(m => m[\\"default\\"])});
17+
export const cleverCwd1 = Object.assign({\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")});
18+
export const cleverCwd2 = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")});
7519
"
7620
`;
7721

7822
exports[`fixture > transform with restoreQueryExtension 1`] = `
79-
"import * as __vite_glob_1_0 from \\"./modules/a.ts\\"
80-
import * as __vite_glob_1_1 from \\"./modules/b.ts\\"
81-
import * as __vite_glob_1_2 from \\"./modules/index.ts\\"
82-
import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\"
83-
import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\"
84-
import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\"
85-
import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\"
86-
import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\"
87-
import \\"../../../../../../types/importMeta\\";
88-
export const basic = Object.assign({
89-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
90-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),
91-
\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")
92-
});
93-
export const basicEager = Object.assign({
94-
\\"./modules/a.ts\\": __vite_glob_1_0,
95-
\\"./modules/b.ts\\": __vite_glob_1_1,
96-
\\"./modules/index.ts\\": __vite_glob_1_2
97-
});
98-
export const ignore = Object.assign({
99-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
100-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")
101-
});
102-
export const namedEager = Object.assign({
103-
\\"./modules/a.ts\\": __vite_glob_3_0,
104-
\\"./modules/b.ts\\": __vite_glob_3_1,
105-
\\"./modules/index.ts\\": __vite_glob_3_2
106-
});
107-
export const namedDefault = Object.assign({
108-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),
109-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),
110-
\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])
111-
});
112-
export const eagerAs = Object.assign({
113-
\\"./modules/a.ts\\": __vite_glob_5_0,
114-
\\"./modules/b.ts\\": __vite_glob_5_1
115-
});
116-
export const rawImportModule = Object.assign({
117-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),
118-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")
119-
});
120-
export const excludeSelf = Object.assign({
121-
\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")
122-
});
123-
export const customQueryString = Object.assign({
124-
\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom&lang.ts\\")
125-
});
126-
export const customQueryObject = Object.assign({
127-
\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true&lang.ts\\")
128-
});
129-
export const parent = Object.assign({
130-
131-
});
132-
export const rootMixedRelative = Object.assign({
133-
\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
134-
\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
135-
\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
136-
\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
137-
\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
138-
\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url&lang.ts\\").then(m => m[\\"default\\"]),
139-
\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url&lang.ts\\").then(m => m[\\"default\\"])
140-
});
141-
export const cleverCwd1 = Object.assign({
142-
\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")
143-
});
144-
export const cleverCwd2 = Object.assign({
145-
\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),
146-
\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),
147-
\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),
148-
\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")
149-
});
23+
"import * as __vite_glob_1_0 from \\"./modules/a.ts\\";import * as __vite_glob_1_1 from \\"./modules/b.ts\\";import * as __vite_glob_1_2 from \\"./modules/index.ts\\";import { name as __vite_glob_3_0 } from \\"./modules/a.ts\\";import { name as __vite_glob_3_1 } from \\"./modules/b.ts\\";import { name as __vite_glob_3_2 } from \\"./modules/index.ts\\";import { default as __vite_glob_5_0 } from \\"./modules/a.ts?raw\\";import { default as __vite_glob_5_1 } from \\"./modules/b.ts?raw\\";import \\"../../../../../../types/importMeta\\";
24+
export const basic = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\")});
25+
export const basicEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_1_0,\\"./modules/b.ts\\": __vite_glob_1_1,\\"./modules/index.ts\\": __vite_glob_1_2});
26+
export const ignore = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\")});
27+
export const namedEager = Object.assign({\\"./modules/a.ts\\": __vite_glob_3_0,\\"./modules/b.ts\\": __vite_glob_3_1,\\"./modules/index.ts\\": __vite_glob_3_2});
28+
export const namedDefault = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\").then(m => m[\\"default\\"]),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\").then(m => m[\\"default\\"]),\\"./modules/index.ts\\": () => import(\\"./modules/index.ts\\").then(m => m[\\"default\\"])});
29+
export const eagerAs = Object.assign({\\"./modules/a.ts\\": __vite_glob_5_0,\\"./modules/b.ts\\": __vite_glob_5_1});
30+
export const rawImportModule = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts?raw\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts?raw\\")});
31+
export const excludeSelf = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts\\")});
32+
export const customQueryString = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?custom&lang.ts\\")});
33+
export const customQueryObject = Object.assign({\\"./sibling.ts\\": () => import(\\"./sibling.ts?foo=bar&raw=true&lang.ts\\")});
34+
export const parent = Object.assign({});
35+
export const rootMixedRelative = Object.assign({\\"/css.spec.ts\\": () => import(\\"../../css.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/define.spec.ts\\": () => import(\\"../../define.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/esbuild.spec.ts\\": () => import(\\"../../esbuild.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/import.spec.ts\\": () => import(\\"../../import.spec.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts?url&lang.ts\\").then(m => m[\\"default\\"]),\\"/importGlob/fixture-b/index.ts\\": () => import(\\"../fixture-b/index.ts?url&lang.ts\\").then(m => m[\\"default\\"])});
36+
export const cleverCwd1 = Object.assign({\\"./node_modules/framework/pages/hello.page.js\\": () => import(\\"./node_modules/framework/pages/hello.page.js\\")});
37+
export const cleverCwd2 = Object.assign({\\"./modules/a.ts\\": () => import(\\"./modules/a.ts\\"),\\"./modules/b.ts\\": () => import(\\"./modules/b.ts\\"),\\"../fixture-b/a.ts\\": () => import(\\"../fixture-b/a.ts\\"),\\"../fixture-b/b.ts\\": () => import(\\"../fixture-b/b.ts\\")});
15038
"
15139
`;
15240

15341
exports[`fixture > virtual modules 1`] = `
154-
"Object.assign({
155-
\\"/modules/a.ts\\": () => import(\\"/modules/a.ts\\"),
156-
\\"/modules/b.ts\\": () => import(\\"/modules/b.ts\\"),
157-
\\"/modules/index.ts\\": () => import(\\"/modules/index.ts\\")
158-
})
159-
Object.assign({
160-
\\"/../fixture-b/a.ts\\": () => import(\\"/../fixture-b/a.ts\\"),
161-
\\"/../fixture-b/b.ts\\": () => import(\\"/../fixture-b/b.ts\\"),
162-
\\"/../fixture-b/index.ts\\": () => import(\\"/../fixture-b/index.ts\\")
163-
})"
42+
"Object.assign({\\"/modules/a.ts\\": () => import(\\"/modules/a.ts\\"),\\"/modules/b.ts\\": () => import(\\"/modules/b.ts\\"),\\"/modules/index.ts\\": () => import(\\"/modules/index.ts\\")})
43+
Object.assign({\\"/../fixture-b/a.ts\\": () => import(\\"/../fixture-b/a.ts\\"),\\"/../fixture-b/b.ts\\": () => import(\\"/../fixture-b/b.ts\\"),\\"/../fixture-b/index.ts\\": () => import(\\"/../fixture-b/index.ts\\")})"
16444
`;

Diff for: ‎packages/vite/src/node/plugins/assetImportMetaUrl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import MagicString from 'magic-string'
33
import { stripLiteral } from 'strip-literal'
44
import type { Plugin } from '../plugin'
55
import type { ResolvedConfig } from '../config'
6-
import { transformResult } from '../utils'
6+
import { transformStableResult } from '../utils'
77
import { fileToUrl } from './asset'
88
import { preloadHelperId } from './importAnalysisBuild'
99

@@ -81,7 +81,7 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
8181
)
8282
}
8383
if (s) {
84-
return transformResult(s, id, config)
84+
return transformStableResult(s, id, config)
8585
}
8686
}
8787
return null

Diff for: ‎packages/vite/src/node/plugins/define.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import MagicString from 'magic-string'
2-
import type { TransformResult } from 'rollup'
32
import type { ResolvedConfig } from '../config'
43
import type { Plugin } from '../plugin'
4+
import { transformStableResult } from '../utils'
55
import { isCSSRequest } from './css'
66
import { isHTMLRequest } from './html'
77

@@ -144,11 +144,7 @@ export function definePlugin(config: ResolvedConfig): Plugin {
144144
return null
145145
}
146146

147-
const result: TransformResult = { code: s.toString() }
148-
if (config.build.sourcemap) {
149-
result.map = s.generateMap({ hires: true })
150-
}
151-
return result
147+
return transformStableResult(s, id, config)
152148
}
153149
}
154150
}

Diff for: ‎packages/vite/src/node/plugins/dynamicImportVars.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
normalizePath,
1212
parseRequest,
1313
requestQuerySplitRE,
14-
transformResult
14+
transformStableResult
1515
} from '../utils'
1616

1717
export const dynamicImportHelperId = '/@vite/dynamic-import-helper'
@@ -209,7 +209,7 @@ export function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin {
209209
`import __variableDynamicImportRuntimeHelper from "${dynamicImportHelperId}";`
210210
)
211211
}
212-
return transformResult(s, importer, config)
212+
return transformStableResult(s, importer, config)
213213
}
214214
}
215215
}

Diff for: ‎packages/vite/src/node/plugins/importAnalysis.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
removeImportQuery,
4141
stripBomTag,
4242
timeFrom,
43-
transformResult,
43+
transformStableResult,
4444
unwrapId
4545
} from '../utils'
4646
import type { ResolvedConfig } from '../config'
@@ -711,7 +711,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
711711
}
712712

713713
if (s) {
714-
return transformResult(s, importer, config)
714+
return transformStableResult(s, importer, config)
715715
} else {
716716
return source
717717
}

Diff for: ‎packages/vite/src/node/plugins/importMetaGlob.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import type { Plugin } from '../plugin'
1717
import type { ViteDevServer } from '../server'
1818
import type { ModuleNode } from '../server/moduleGraph'
1919
import type { ResolvedConfig } from '../config'
20-
import { normalizePath, slash, transformResult } from '../utils'
20+
import { normalizePath, slash, transformStableResult } from '../utils'
2121

2222
const { isMatch, scan } = micromatch
2323

@@ -75,7 +75,7 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
7575
server!.watcher.add(dirname(file))
7676
})
7777
}
78-
return transformResult(result.s, id, config)
78+
return transformStableResult(result.s, id, config)
7979
}
8080
}
8181
}
@@ -426,7 +426,7 @@ export async function transformGlobImport(
426426

427427
files.forEach((i) => matchedFiles.add(i))
428428

429-
const replacement = `Object.assign({\n${objectProps.join(',\n')}\n})`
429+
const replacement = `Object.assign({${objectProps.join(',')}})`
430430
s.overwrite(start, end, replacement)
431431

432432
return staticImports
@@ -435,7 +435,7 @@ export async function transformGlobImport(
435435
)
436436
).flat()
437437

438-
if (staticImports.length) s.prepend(`${staticImports.join('\n')}\n`)
438+
if (staticImports.length) s.prepend(`${staticImports.join(';')};`)
439439

440440
return {
441441
s,

Diff for: ‎packages/vite/src/node/plugins/workerImportMetaUrl.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
injectQuery,
1111
normalizePath,
1212
parseRequest,
13-
transformResult
13+
transformStableResult
1414
} from '../utils'
1515
import { getDepsOptimizer } from '../optimizer'
1616
import type { WorkerType } from './worker'
@@ -136,7 +136,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
136136
}
137137

138138
if (s) {
139-
return transformResult(s, id, config)
139+
return transformStableResult(s, id, config)
140140
}
141141

142142
return null

Diff for: ‎packages/vite/src/node/utils.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,21 @@ function normalizeSingleAlias({
10281028
return alias
10291029
}
10301030

1031-
export function transformResult(
1031+
/**
1032+
* Transforms transpiled code result where line numbers aren't altered,
1033+
* so we can skip sourcemap generation during dev
1034+
*/
1035+
export function transformStableResult(
10321036
s: MagicString,
10331037
id: string,
10341038
config: ResolvedConfig
10351039
): TransformResult {
1036-
const isBuild = config.command === 'build'
1037-
const needSourceMap = !isBuild || config.build.sourcemap
10381040
return {
10391041
code: s.toString(),
1040-
map: needSourceMap ? s.generateMap({ hires: true, source: id }) : null
1042+
map:
1043+
config.command === 'build' && config.build.sourcemap
1044+
? s.generateMap({ hires: true, source: id })
1045+
: null
10411046
}
10421047
}
10431048

Diff for: ‎playground/vue-sourcemap/__tests__/__snapshots__/serve.spec.ts.snap

+311-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,149 @@
11
// Vitest Snapshot v1
22

3+
exports[`serve:vue-sourcemap > css 1`] = `
4+
{
5+
"mappings": ";AAQA;EACE,UAAU;AACZ",
6+
"sources": [
7+
"/root/Css.vue",
8+
],
9+
"sourcesContent": [
10+
"<template>
11+
<p class=\\"css\\">&lt;css&gt;</p>
12+
<p :class=\\"$style['css-module']\\">&lt;css&gt; module</p>
13+
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
14+
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
15+
</template>
16+
17+
<style>
18+
.css {
19+
color: red;
20+
}
21+
</style>
22+
23+
<style module>
24+
.css-module {
25+
color: red;
26+
}
27+
</style>
28+
29+
<style scoped>
30+
.css-scoped {
31+
color: red;
32+
}
33+
</style>
34+
35+
<style scoped>
36+
.css-scoped-nested {
37+
color: red;
38+
.dummy {
39+
color: green;
40+
}
41+
font-weight: bold;
42+
}
43+
</style>
44+
",
45+
],
46+
"version": 3,
47+
}
48+
`;
49+
50+
exports[`serve:vue-sourcemap > css module 1`] = `
51+
{
52+
"mappings": ";AAcA;EACE,UAAU;AACZ",
53+
"sources": [
54+
"/root/Css.vue",
55+
],
56+
"sourcesContent": [
57+
"<template>
58+
<p class=\\"css\\">&lt;css&gt;</p>
59+
<p :class=\\"$style['css-module']\\">&lt;css&gt; module</p>
60+
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
61+
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
62+
</template>
63+
64+
<style>
65+
.css {
66+
color: red;
67+
}
68+
</style>
69+
70+
<style module>
71+
.css-module {
72+
color: red;
73+
}
74+
</style>
75+
76+
<style scoped>
77+
.css-scoped {
78+
color: red;
79+
}
80+
</style>
81+
82+
<style scoped>
83+
.css-scoped-nested {
84+
color: red;
85+
.dummy {
86+
color: green;
87+
}
88+
font-weight: bold;
89+
}
90+
</style>
91+
",
92+
],
93+
"version": 3,
94+
}
95+
`;
96+
97+
exports[`serve:vue-sourcemap > css scoped 1`] = `
98+
{
99+
"mappings": ";AAoBA;EACE,UAAU;AACZ",
100+
"sources": [
101+
"/root/Css.vue",
102+
],
103+
"sourcesContent": [
104+
"<template>
105+
<p class=\\"css\\">&lt;css&gt;</p>
106+
<p :class=\\"$style['css-module']\\">&lt;css&gt; module</p>
107+
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
108+
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
109+
</template>
110+
111+
<style>
112+
.css {
113+
color: red;
114+
}
115+
</style>
116+
117+
<style module>
118+
.css-module {
119+
color: red;
120+
}
121+
</style>
122+
123+
<style scoped>
124+
.css-scoped {
125+
color: red;
126+
}
127+
</style>
128+
129+
<style scoped>
130+
.css-scoped-nested {
131+
color: red;
132+
.dummy {
133+
color: green;
134+
}
135+
font-weight: bold;
136+
}
137+
</style>
138+
",
139+
],
140+
"version": 3,
141+
}
142+
`;
143+
3144
exports[`serve:vue-sourcemap > js 1`] = `
4145
{
5-
"mappings": "mIAKA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;wBARlB,oBAAiB,WAAd,MAAU",
146+
"mappings": "AAKA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;;;;;wBARlB,oBAAiB,WAAd,MAAU",
6147
"sources": [
7148
"/root/Js.vue",
8149
],
@@ -23,3 +164,172 @@ console.log('setup')
23164
"version": 3,
24165
}
25166
`;
167+
168+
exports[`serve:vue-sourcemap > less with additionalData 1`] = `
169+
{
170+
"mappings": "AAKA;EACE",
171+
"sources": [
172+
"/root/Less.vue",
173+
],
174+
"sourcesContent": [
175+
"<template>
176+
<p class=\\"less\\">&lt;less&gt; with additionalData</p>
177+
</template>
178+
179+
<style lang=\\"less\\">
180+
.less {
181+
color: @color;
182+
}
183+
</style>
184+
",
185+
],
186+
"version": 3,
187+
}
188+
`;
189+
190+
exports[`serve:vue-sourcemap > no script 1`] = `
191+
{
192+
"mappings": ";;;wBACE,oBAAwB,WAArB,aAAiB",
193+
"sourceRoot": "",
194+
"sources": [
195+
"/root/NoScript.vue",
196+
],
197+
"sourcesContent": [
198+
"<template>
199+
<p>&lt;no-script&gt;</p>
200+
</template>
201+
",
202+
],
203+
"version": 3,
204+
}
205+
`;
206+
207+
exports[`serve:vue-sourcemap > no template 1`] = `
208+
{
209+
"mappings": "AACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;;",
210+
"sources": [
211+
"/root/NoTemplate.vue",
212+
],
213+
"sourcesContent": [
214+
"<script>
215+
console.log('script')
216+
</script>
217+
218+
<script setup>
219+
console.log('setup')
220+
</script>
221+
",
222+
],
223+
"version": 3,
224+
}
225+
`;
226+
227+
exports[`serve:vue-sourcemap > sass 1`] = `
228+
{
229+
"mappings": "AAKA;EACE",
230+
"sources": [
231+
"/root/Sass.vue",
232+
],
233+
"sourcesContent": [
234+
"<template>
235+
<p class=\\"sass\\">&lt;sass&gt;</p>
236+
</template>
237+
238+
<style lang=\\"sass\\">
239+
.sass
240+
color: red
241+
</style>
242+
",
243+
],
244+
"version": 3,
245+
}
246+
`;
247+
248+
exports[`serve:vue-sourcemap > sass with import 1`] = `
249+
{
250+
"mappings": "AAAA;EACE;;ACOF;EACE",
251+
"sources": [
252+
"/root/sassWithImportImported.sass",
253+
"/root/SassWithImport.vue",
254+
],
255+
"sourcesContent": [
256+
".sass-with-import-imported
257+
color: red
258+
",
259+
"<template>
260+
<p class=\\"sass-with-import\\">&lt;sass&gt; with import</p>
261+
<p class=\\"sass-with-import-imported\\">&lt;sass&gt; with import (imported)</p>
262+
</template>
263+
264+
<style lang=\\"sass\\">
265+
@import './sassWithImportImported'
266+
267+
.sass-with-import
268+
color: red
269+
</style>
270+
",
271+
],
272+
"version": 3,
273+
}
274+
`;
275+
276+
exports[`serve:vue-sourcemap > src imported 1`] = `
277+
{
278+
"mappings": "AAAA;EACE,UAAU;AACZ",
279+
"sources": [
280+
"/root/src-import/src-import.css",
281+
],
282+
"sourcesContent": [
283+
".src-import {
284+
color: red;
285+
}
286+
",
287+
],
288+
"version": 3,
289+
}
290+
`;
291+
292+
exports[`serve:vue-sourcemap > src imported sass 1`] = `
293+
{
294+
"mappings": "AAAA;EACE;;ACCF;EACE",
295+
"sources": [
296+
"/root/src-import/src-import-imported.sass",
297+
"/root/src-import/src-import.sass",
298+
],
299+
"sourcesContent": [
300+
".src-import-sass-imported
301+
color: red
302+
",
303+
"@import './src-import-imported'
304+
305+
.src-import-sass
306+
color: red
307+
",
308+
],
309+
"version": 3,
310+
}
311+
`;
312+
313+
exports[`serve:vue-sourcemap > ts 1`] = `
314+
{
315+
"mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU",
316+
"sources": [
317+
"/root/Ts.vue",
318+
],
319+
"sourcesContent": [
320+
"<template>
321+
<p>&lt;ts&gt;</p>
322+
</template>
323+
324+
<script lang=\\"ts\\">
325+
console.log('ts script')
326+
</script>
327+
328+
<script lang=\\"ts\\" setup>
329+
console.log('ts setup')
330+
</script>
331+
",
332+
],
333+
"version": 3,
334+
}
335+
`;

Diff for: ‎playground/vue-sourcemap/__tests__/serve.spec.ts

+11-298
Original file line numberDiff line numberDiff line change
@@ -29,310 +29,55 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
2929
const res = await page.request.get(new URL('./Ts.vue', page.url()).href)
3030
const js = await res.text()
3131
const map = extractSourcemap(js)
32-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
33-
{
34-
"mappings": ";AAKA,QAAQ,IAAI,WAAW;;;;;AAIvB,YAAQ,IAAI,UAAU;;;;;;;;uBARpB,oBAAiB,WAAd,MAAU",
35-
"sources": [
36-
"/root/Ts.vue",
37-
],
38-
"sourcesContent": [
39-
"<template>
40-
<p>&lt;ts&gt;</p>
41-
</template>
42-
43-
<script lang=\\"ts\\">
44-
console.log('ts script')
45-
</script>
46-
47-
<script lang=\\"ts\\" setup>
48-
console.log('ts setup')
49-
</script>
50-
",
51-
],
52-
"version": 3,
53-
}
54-
`)
32+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
5533
})
5634

5735
test('css', async () => {
5836
const css = await getStyleTagContentIncluding('.css ')
5937
const map = extractSourcemap(css)
60-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
61-
{
62-
"mappings": ";AAQA;EACE,UAAU;AACZ",
63-
"sources": [
64-
"/root/Css.vue",
65-
],
66-
"sourcesContent": [
67-
"<template>
68-
<p class=\\"css\\">&lt;css&gt;</p>
69-
<p :class=\\"\$style['css-module']\\">&lt;css&gt; module</p>
70-
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
71-
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
72-
</template>
73-
74-
<style>
75-
.css {
76-
color: red;
77-
}
78-
</style>
79-
80-
<style module>
81-
.css-module {
82-
color: red;
83-
}
84-
</style>
85-
86-
<style scoped>
87-
.css-scoped {
88-
color: red;
89-
}
90-
</style>
91-
92-
<style scoped>
93-
.css-scoped-nested {
94-
color: red;
95-
.dummy {
96-
color: green;
97-
}
98-
font-weight: bold;
99-
}
100-
</style>
101-
",
102-
],
103-
"version": 3,
104-
}
105-
`)
38+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
10639
})
10740

10841
test('css module', async () => {
10942
const css = await getStyleTagContentIncluding('._css-module_')
11043
const map = extractSourcemap(css)
111-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
112-
{
113-
"mappings": ";AAcA;EACE,UAAU;AACZ",
114-
"sources": [
115-
"/root/Css.vue",
116-
],
117-
"sourcesContent": [
118-
"<template>
119-
<p class=\\"css\\">&lt;css&gt;</p>
120-
<p :class=\\"\$style['css-module']\\">&lt;css&gt; module</p>
121-
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
122-
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
123-
</template>
124-
125-
<style>
126-
.css {
127-
color: red;
128-
}
129-
</style>
130-
131-
<style module>
132-
.css-module {
133-
color: red;
134-
}
135-
</style>
136-
137-
<style scoped>
138-
.css-scoped {
139-
color: red;
140-
}
141-
</style>
142-
143-
<style scoped>
144-
.css-scoped-nested {
145-
color: red;
146-
.dummy {
147-
color: green;
148-
}
149-
font-weight: bold;
150-
}
151-
</style>
152-
",
153-
],
154-
"version": 3,
155-
}
156-
`)
44+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
15745
})
15846

15947
test('css scoped', async () => {
16048
const css = await getStyleTagContentIncluding('.css-scoped[data-v-')
16149
const map = extractSourcemap(css)
162-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
163-
{
164-
"mappings": ";AAoBA;EACE,UAAU;AACZ",
165-
"sources": [
166-
"/root/Css.vue",
167-
],
168-
"sourcesContent": [
169-
"<template>
170-
<p class=\\"css\\">&lt;css&gt;</p>
171-
<p :class=\\"\$style['css-module']\\">&lt;css&gt; module</p>
172-
<p class=\\"css-scoped\\">&lt;css&gt; scoped</p>
173-
<p class=\\"css-scoped-nested\\">&lt;css&gt; scoped with nested</p>
174-
</template>
175-
176-
<style>
177-
.css {
178-
color: red;
179-
}
180-
</style>
181-
182-
<style module>
183-
.css-module {
184-
color: red;
185-
}
186-
</style>
187-
188-
<style scoped>
189-
.css-scoped {
190-
color: red;
191-
}
192-
</style>
193-
194-
<style scoped>
195-
.css-scoped-nested {
196-
color: red;
197-
.dummy {
198-
color: green;
199-
}
200-
font-weight: bold;
201-
}
202-
</style>
203-
",
204-
],
205-
"version": 3,
206-
}
207-
`)
50+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
20851
})
20952

21053
test('sass', async () => {
21154
const css = await getStyleTagContentIncluding('.sass ')
21255
const map = extractSourcemap(css)
213-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
214-
{
215-
"mappings": "AAKA;EACE",
216-
"sources": [
217-
"/root/Sass.vue",
218-
],
219-
"sourcesContent": [
220-
"<template>
221-
<p class=\\"sass\\">&lt;sass&gt;</p>
222-
</template>
223-
224-
<style lang=\\"sass\\">
225-
.sass
226-
color: red
227-
</style>
228-
",
229-
],
230-
"version": 3,
231-
}
232-
`)
56+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
23357
})
23458

23559
test('sass with import', async () => {
23660
const css = await getStyleTagContentIncluding('.sass-with-import ')
23761
const map = extractSourcemap(css)
238-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
239-
{
240-
"mappings": "AAAA;EACE;;ACOF;EACE",
241-
"sources": [
242-
"/root/sassWithImportImported.sass",
243-
"/root/SassWithImport.vue",
244-
],
245-
"sourcesContent": [
246-
".sass-with-import-imported
247-
color: red
248-
",
249-
"<template>
250-
<p class=\\"sass-with-import\\">&lt;sass&gt; with import</p>
251-
<p class=\\"sass-with-import-imported\\">&lt;sass&gt; with import (imported)</p>
252-
</template>
253-
254-
<style lang=\\"sass\\">
255-
@import './sassWithImportImported'
256-
257-
.sass-with-import
258-
color: red
259-
</style>
260-
",
261-
],
262-
"version": 3,
263-
}
264-
`)
62+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
26563
})
26664

26765
test('less with additionalData', async () => {
26866
const css = await getStyleTagContentIncluding('.less ')
26967
const map = extractSourcemap(css)
270-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
271-
{
272-
"mappings": "AAKA;EACE",
273-
"sources": [
274-
"/root/Less.vue",
275-
],
276-
"sourcesContent": [
277-
"<template>
278-
<p class=\\"less\\">&lt;less&gt; with additionalData</p>
279-
</template>
280-
281-
<style lang=\\"less\\">
282-
.less {
283-
color: @color;
284-
}
285-
</style>
286-
",
287-
],
288-
"version": 3,
289-
}
290-
`)
68+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
29169
})
29270

29371
test('src imported', async () => {
29472
const css = await getStyleTagContentIncluding('.src-import[data-v-')
29573
const map = extractSourcemap(css)
296-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
297-
{
298-
"mappings": "AAAA;EACE,UAAU;AACZ",
299-
"sources": [
300-
"/root/src-import/src-import.css",
301-
],
302-
"sourcesContent": [
303-
".src-import {
304-
color: red;
305-
}
306-
",
307-
],
308-
"version": 3,
309-
}
310-
`)
74+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
31175
})
31276

31377
test('src imported sass', async () => {
31478
const css = await getStyleTagContentIncluding('.src-import-sass[data-v-')
31579
const map = extractSourcemap(css)
316-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
317-
{
318-
"mappings": "AAAA;EACE;;ACCF;EACE",
319-
"sources": [
320-
"/root/src-import/src-import-imported.sass",
321-
"/root/src-import/src-import.sass",
322-
],
323-
"sourcesContent": [
324-
".src-import-sass-imported
325-
color: red
326-
",
327-
"@import './src-import-imported'
328-
329-
.src-import-sass
330-
color: red
331-
",
332-
],
333-
"version": 3,
334-
}
335-
`)
80+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
33681
})
33782

33883
test('no script', async () => {
@@ -341,21 +86,7 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
34186
)
34287
const js = await res.text()
34388
const map = extractSourcemap(js)
344-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
345-
{
346-
"mappings": ";;;wBACE",
347-
"sources": [
348-
"/root/NoScript.vue",
349-
],
350-
"sourcesContent": [
351-
"<template>
352-
<p>&lt;no-script&gt;</p>
353-
</template>
354-
",
355-
],
356-
"version": 3,
357-
}
358-
`)
89+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
35990
})
36091

36192
test('no template', async () => {
@@ -364,24 +95,6 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
36495
)
36596
const js = await res.text()
36697
const map = extractSourcemap(js)
367-
expect(formatSourcemapForSnapshot(map)).toMatchInlineSnapshot(`
368-
{
369-
"mappings": "2IACA,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;;AAGP;AACd,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC",
370-
"sources": [
371-
"/root/NoTemplate.vue",
372-
],
373-
"sourcesContent": [
374-
"<script>
375-
console.log('script')
376-
</script>
377-
378-
<script setup>
379-
console.log('setup')
380-
</script>
381-
",
382-
],
383-
"version": 3,
384-
}
385-
`)
98+
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
38699
})
387100
})

Diff for: ‎playground/worker/__tests__/sourcemap/__snapshots__/sourcemap-worker.spec.ts.snap

-14
This file was deleted.

Diff for: ‎playground/worker/__tests__/sourcemap/sourcemap-worker.spec.ts

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import fs from 'node:fs'
22
import path from 'node:path'
3-
import {
4-
extractSourcemap,
5-
formatSourcemapForSnapshot,
6-
isBuild,
7-
isServe,
8-
page,
9-
testDir
10-
} from '~utils'
3+
import { isBuild, testDir } from '~utils'
114

125
describe.runIf(isBuild)('build', () => {
136
// assert correct files
@@ -120,16 +113,6 @@ describe.runIf(isBuild)('build', () => {
120113
})
121114
})
122115

123-
describe.runIf(isServe)('serve:worker-sourcemap', () => {
124-
test('nested worker', async () => {
125-
const res = await page.request.get(
126-
new URL('./possible-ts-output-worker.mjs?worker_file', page.url()).href
127-
)
128-
const map = extractSourcemap(await res.text())
129-
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot()
130-
})
131-
})
132-
133116
function getSourceMapUrl(code: string): string {
134117
const regex = /\/\/[#@]\s(?:source(?:Mapping)?URL)=\s*(\S+)/g
135118
const results = regex.exec(code)

0 commit comments

Comments
 (0)
Please sign in to comment.