-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(vite-node): fix source map of inlined node_modules #7557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
34b87c0
8f7b281
f1264fb
bf9ec27
683b063
8f360cf
edca9bb
2bd5534
6159c8c
c406c72
d0f42b0
bbfcf9f
4a53951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ export default antfu( | |
| 'test/network-imports/public/[email protected]', | ||
| 'test/coverage-test/src/transpiled.js', | ||
| 'test/coverage-test/src/original.ts', | ||
| 'test/cli/deps/error/*', | ||
| 'examples/**/mockServiceWorker.js', | ||
| 'examples/sveltekit/.svelte-kit', | ||
| 'packages/browser/**/esm-client-injector.js', | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import 'node:path' | ||
|
|
||
| export default function testStack() { | ||
| innerTestStack() | ||
| } | ||
|
|
||
| import 'node:util' | ||
|
|
||
| function innerTestStack() { | ||
| throw new Error('__TEST_STACK__') | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "@vitest/test-dep-error", | ||
| "type": "module", | ||
| "private": true, | ||
| "exports": { | ||
| ".": "./index.js", | ||
| "./*": "./*" | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'node:path' | ||
|
|
||
| export type Dummy = { | ||
| foo: "foo", | ||
| } | ||
|
|
||
| /** | ||
| * dummy | ||
| * dummy | ||
| */ | ||
| export default function testStack() { | ||
| innerTestStack() | ||
| } | ||
|
|
||
| import 'node:util' | ||
|
|
||
| /** | ||
| * bar | ||
| * bar | ||
| */ | ||
| function innerTestStack() { | ||
| throw new Error('__TEST_STACK_TRANSPILED_INLINE__') | ||
| } | ||
|
|
||
| // transpiled-inline.js is copied from | ||
| // https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXA9aW5saW5lIC0tc291cmNlZmlsZT10cmFuc3BpbGVkLWlubGluZS50cwBpbXBvcnQgJ25vZGU6cGF0aCcKCmV4cG9ydCB0eXBlIER1bW15ID0gewogIGZvbzogImZvbyIsCn0KCi8qKgogKiBkdW1teQogKiBkdW1teQogKi8KZXhwb3J0IGRlZmF1bHQgZnVuY3Rpb24gdGVzdFN0YWNrKCkgewogIGlubmVyVGVzdFN0YWNrKCkKfQoKaW1wb3J0ICdub2RlOnV0aWwnCgovKioKICogYmFyCiAqIGJhcgogKi8KZnVuY3Rpb24gaW5uZXJUZXN0U3RhY2soKSB7CiAgdGhyb3cgbmV3IEVycm9yKCdfX1RFU1RfU1RBQ0tfVFJBTlNQSUxFRF9JTkxJTkVfXycpCn0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import 'node:path' | ||
|
|
||
| export type Dummy = { | ||
| foo: "foo", | ||
| } | ||
|
|
||
| /** | ||
| * dummy | ||
| * dummy | ||
| */ | ||
| export default function testStack() { | ||
| innerTestStack() | ||
| } | ||
|
|
||
| import 'node:util' | ||
|
|
||
| /** | ||
| * bar | ||
| * bar | ||
| */ | ||
| function innerTestStack() { | ||
| throw new Error('__TEST_STACK_TRANSPILED__') | ||
| } | ||
|
|
||
| // transpiled.js and transpiled.js.map are copied from | ||
| // https://esbuild.github.io/try/#dAAwLjI1LjAALS1sb2FkZXI9dHMgLS1zb3VyY2VtYXAgLS1zb3VyY2VmaWxlPXRyYW5zcGlsZWQudHMAaW1wb3J0ICdub2RlOnBhdGgnCgpleHBvcnQgdHlwZSBEdW1teSA9IHsKICBmb286ICJmb28iLAp9CgovKioKICogZHVtbXkKICogZHVtbXkKICovCmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIHRlc3RTdGFjaygpIHsKICBpbm5lclRlc3RTdGFjaygpCn0KCmltcG9ydCAnbm9kZTp1dGlsJwoKLyoqCiAqIGJhcgogKiBiYXIKICovCmZ1bmN0aW9uIGlubmVyVGVzdFN0YWNrKCkgewogIHRocm93IG5ldyBFcnJvcignX19URVNUX1NUQUNLX1RSQU5TUElMRURfXycpCn0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import 'node:path' | ||
|
|
||
| export type Dummy = { | ||
| foo: "foo", | ||
| } | ||
|
|
||
| /** | ||
| * dummy | ||
| * dummy | ||
| */ | ||
| export default function testStack() { | ||
| innerTestStack() | ||
| } | ||
|
|
||
| import 'node:util' | ||
|
|
||
| /** | ||
| * bar | ||
| * bar | ||
| */ | ||
| function innerTestStack() { | ||
| throw new Error('__TEST_STACK_TS__') | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { test } from 'vitest' | ||
| import testStack from "@vitest/test-dep-error" | ||
| import testStackTs from "@vitest/test-dep-error/ts.ts" | ||
| import testStackTranspiled from "@vitest/test-dep-error/transpiled.js" | ||
| import testStackTranspiledInline from "@vitest/test-dep-error/transpiled-inline.js" | ||
|
|
||
| test('js', () => { | ||
| testStack() | ||
| }) | ||
|
|
||
| test('ts', () => { | ||
| testStackTs() | ||
| }) | ||
|
|
||
| test('transpiled', () => { | ||
| testStackTranspiled() | ||
| }) | ||
|
|
||
| test('transpiled inline', () => { | ||
| testStackTranspiledInline() | ||
| }) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,132 @@ Error: Something truly horrible has happened! | |||||||||||||||||||
| " | ||||||||||||||||||||
| `; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| exports[`stacktrace in dependency package > external 1`] = ` | ||||||||||||||||||||
| " | ||||||||||||||||||||
| ⎯⎯ Failed Tests 4 ⎯⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > js | ||||||||||||||||||||
| Error: __TEST_STACK__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/index.js:10:9 | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/index.js:4:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:8:12 | ||||||||||||||||||||
| 6| | ||||||||||||||||||||
| 7| test('js', () => { | ||||||||||||||||||||
| 8| testStack() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 9| }) | ||||||||||||||||||||
| 10| | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[1/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > ts | ||||||||||||||||||||
| Error: __TEST_STACK_TS__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/ts.ts:22:9 | ||||||||||||||||||||
| 20| */ | ||||||||||||||||||||
| 21| function innerTestStack() { | ||||||||||||||||||||
| 22| throw new Error('__TEST_STACK_TS__') | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 23| } | ||||||||||||||||||||
| 24| | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/ts.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:12:14 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[2/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > transpiled | ||||||||||||||||||||
| Error: __TEST_STACK_TRANSPILED__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/transpiled.ts:22:9 | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/transpiled.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:16:22 | ||||||||||||||||||||
| 14| | ||||||||||||||||||||
| 15| test('transpiled', () => { | ||||||||||||||||||||
| 16| testStackTranspiled() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 17| }) | ||||||||||||||||||||
| 18| | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[3/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > transpiled inline | ||||||||||||||||||||
| Error: __TEST_STACK_TRANSPILED_INLINE__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/transpiled-inline.ts:22:9 | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/transpiled-inline.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:20:28 | ||||||||||||||||||||
| 18| | ||||||||||||||||||||
| 19| test('transpiled inline', () => { | ||||||||||||||||||||
| 20| testStackTranspiledInline() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 21| }) | ||||||||||||||||||||
| 22| | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[4/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| " | ||||||||||||||||||||
| `; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| exports[`stacktrace in dependency package > inline 1`] = ` | ||||||||||||||||||||
| " | ||||||||||||||||||||
| ⎯⎯ Failed Tests 4 ⎯⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > js | ||||||||||||||||||||
| Error: __TEST_STACK__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/index.js:10:9 | ||||||||||||||||||||
| 8| | ||||||||||||||||||||
| 9| function innerTestStack() { | ||||||||||||||||||||
| 10| throw new Error('__TEST_STACK__') | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 11| } | ||||||||||||||||||||
| 12| | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/index.js:4:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:8:12 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[1/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > ts | ||||||||||||||||||||
| Error: __TEST_STACK_TS__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/ts.ts:22:9 | ||||||||||||||||||||
| 20| */ | ||||||||||||||||||||
| 21| function innerTestStack() { | ||||||||||||||||||||
| 22| throw new Error('__TEST_STACK_TS__') | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 23| } | ||||||||||||||||||||
| 24| | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/ts.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:12:14 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[2/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > transpiled | ||||||||||||||||||||
| Error: __TEST_STACK_TRANSPILED__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/transpiled.ts:22:9 | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/transpiled.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:16:22 | ||||||||||||||||||||
| 14| | ||||||||||||||||||||
| 15| test('transpiled', () => { | ||||||||||||||||||||
| 16| testStackTranspiled() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 17| }) | ||||||||||||||||||||
| 18| | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[3/4]⎯ | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FAIL error-in-package.test.js > transpiled inline | ||||||||||||||||||||
| Error: __TEST_STACK_TRANSPILED_INLINE__ | ||||||||||||||||||||
| ❯ innerTestStack (NODE_MODULES)/@vitest/test-dep-error/transpiled-inline.ts:22:9 | ||||||||||||||||||||
| ❯ testStack (NODE_MODULES)/@vitest/test-dep-error/transpiled-inline.ts:12:3 | ||||||||||||||||||||
| ❯ error-in-package.test.js:20:28 | ||||||||||||||||||||
| 18| | ||||||||||||||||||||
| 19| test('transpiled inline', () => { | ||||||||||||||||||||
| 20| testStackTranspiledInline() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 21| }) | ||||||||||||||||||||
| 22| | ||||||||||||||||||||
|
|
||||||||||||||||||||
| ⎯⎯[4/4]⎯ | ||||||||||||||||||||
|
Comment on lines
+120
to
+146
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error frames don't show the original ts file content because it's not found by vitest/packages/vitest/src/node/error.ts Lines 127 to 135 in bbfcf9f
After removing |
||||||||||||||||||||
|
|
||||||||||||||||||||
| " | ||||||||||||||||||||
| `; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| exports[`stacktrace in vmThreads 1`] = ` | ||||||||||||||||||||
| " | ||||||||||||||||||||
| ⎯⎯ Failed Tests 1 ⎯⎯ | ||||||||||||||||||||
|
|
@@ -117,6 +243,17 @@ exports[`stacktraces should respect sourcemaps > error-in-deps.test.js 1`] = ` | |||||||||||||||||||
| " | ||||||||||||||||||||
| `; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| exports[`stacktraces should respect sourcemaps > error-in-package.test.js 1`] = ` | ||||||||||||||||||||
| " ❯ error-in-package.test.js:8:12 | ||||||||||||||||||||
| 6| | ||||||||||||||||||||
| 7| test('js', () => { | ||||||||||||||||||||
| 8| testStack() | ||||||||||||||||||||
| | ^ | ||||||||||||||||||||
| 9| }) | ||||||||||||||||||||
| 10| | ||||||||||||||||||||
| " | ||||||||||||||||||||
| `; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| exports[`stacktraces should respect sourcemaps > error-with-stack.test.js 1`] = ` | ||||||||||||||||||||
| " ❯ d error-with-stack.test.js:20:9 | ||||||||||||||||||||
| 18| | ||||||||||||||||||||
|
|
||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.