Skip to content

Commit 34aa322

Browse files
authored
fix(vite-node): fix source map of inlined node_modules (#7557)
1 parent 0fb21fa commit 34aa322

File tree

15 files changed

+317
-1
lines changed

15 files changed

+317
-1
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default antfu(
2323
'test/network-imports/public/[email protected]',
2424
'test/coverage-test/src/transpiled.js',
2525
'test/coverage-test/src/original.ts',
26+
'test/cli/deps/error/*',
2627
'examples/**/mockServiceWorker.js',
2728
'examples/sveltekit/.svelte-kit',
2829
'packages/browser/**/esm-client-injector.js',

packages/vite-node/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ export class ViteNodeServer {
428428
}
429429

430430
const sourcemap = this.options.sourcemap ?? 'inline'
431-
if (sourcemap === 'inline' && result && !id.includes('node_modules')) {
431+
if (sourcemap === 'inline' && result) {
432432
result = await this.processTransformResult(filepath, result)
433433
}
434434

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/deps/error/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import 'node:path'
2+
3+
export default function testStack() {
4+
innerTestStack()
5+
}
6+
7+
import 'node:util'
8+
9+
function innerTestStack() {
10+
throw new Error('__TEST_STACK__')
11+
}

test/cli/deps/error/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@vitest/test-dep-error",
3+
"type": "module",
4+
"private": true,
5+
"exports": {
6+
".": "./index.js",
7+
"./*": "./*"
8+
}
9+
}

test/cli/deps/error/transpiled-inline.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'node:path'
2+
3+
export type Dummy = {
4+
foo: "foo",
5+
}
6+
7+
/**
8+
* dummy
9+
* dummy
10+
*/
11+
export default function testStack() {
12+
innerTestStack()
13+
}
14+
15+
import 'node:util'
16+
17+
/**
18+
* bar
19+
* bar
20+
*/
21+
function innerTestStack() {
22+
throw new Error('__TEST_STACK_TRANSPILED_INLINE__')
23+
}
24+
25+
// transpiled-inline.js is copied from
26+
// https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXA9aW5saW5lIC0tc291cmNlZmlsZT10cmFuc3BpbGVkLWlubGluZS50cwBpbXBvcnQgJ25vZGU6cGF0aCcKCmV4cG9ydCB0eXBlIER1bW15ID0gewogIGZvbzogImZvbyIsCn0KCi8qKgogKiBkdW1teQogKiBkdW1teQogKi8KZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdGVzdFN0YWNrKCkgewogIGlubmVyVGVzdFN0YWNrKCkKfQoKaW1wb3J0ICdub2RlOnV0aWwnCgovKioKICogYmFyCiAqIGJhcgogKi8KZnVuY3Rpb24gaW5uZXJUZXN0U3RhY2soKSB7CiAgdGhyb3cgbmV3IEVycm9yKCdfX1RFU1RfU1RBQ0tfVFJBTlNQSUxFRF9JTkxJTkVfXycpCn0

test/cli/deps/error/transpiled.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/deps/error/transpiled.js.map

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/deps/error/transpiled.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'node:path'
2+
3+
export type Dummy = {
4+
foo: "foo",
5+
}
6+
7+
/**
8+
* dummy
9+
* dummy
10+
*/
11+
export default function testStack() {
12+
innerTestStack()
13+
}
14+
15+
import 'node:util'
16+
17+
/**
18+
* bar
19+
* bar
20+
*/
21+
function innerTestStack() {
22+
throw new Error('__TEST_STACK_TRANSPILED__')
23+
}
24+
25+
// transpiled.js and transpiled.js.map are copied from
26+
// https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXAgLS1zb3VyY2VmaWxlPXRyYW5zcGlsZWQudHMAaW1wb3J0ICdub2RlOnBhdGgnCgpleHBvcnQgdHlwZSBEdW1teSA9IHsKICBmb286ICJmb28iLAp9CgovKioKICogZHVtbXkKICogZHVtbXkKICovCmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIHRlc3RTdGFjaygpIHsKICBpbm5lclRlc3RTdGFjaygpCn0KCmltcG9ydCAnbm9kZTp1dGlsJwoKLyoqCiAqIGJhcgogKiBiYXIKICovCmZ1bmN0aW9uIGlubmVyVGVzdFN0YWNrKCkgewogIHRocm93IG5ldyBFcnJvcignX19URVNUX1NUQUNLX1RSQU5TUElMRURfXycpCn0

0 commit comments

Comments
 (0)