-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Describe the bug
I have a workspace with two packages:
pkg-abuild a bundle of its own code and packages from node_modulespkg-bruns test from vitest that import code frompkg-a
The sourcemaps for errors thrown from inside pkg-a report incorrect source locations:
$ pnpm vitest
Error: Test error
❯ Module.foo ../node_modules/.pnpm/base32-decode@1.0.0/node_modules/base32-decode/index.js:5:9
❯ index.test.js:5:3
Running similar code in node JS produces the correct stack trace:
$ node --enable-source-maps script.js
/Users/dmaretskyi/vitest-sourcemap-bug/pkg-a/index.js:5
throw new Error("Test error");
^
Error: Test error
at foo (/Users/dmaretskyi/vitest-sourcemap-bug/pkg-a/index.js:5:9)
at file:///Users/dmaretskyi/vitest-sourcemap-bug/pkg-b/script.js:3:1
at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async loadESM (node:internal/process/esm_loader:34:7)
at async handleMainPromise (node:internal/modules/run_main:66:12)
Reproduction
https://github.com/dmaretskyi/vitest-sourcemap-bug
See README for repro steps
System Info
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Pro
Memory: 78.80 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.9.0 - ~/.nodenv/versions/20.9.0/bin/node
Yarn: 1.22.21 - ~/.nodenv/versions/20.9.0/bin/yarn
npm: 10.2.4 - ~/.nodenv/versions/20.9.0/bin/npm
pnpm: 8.11.0 - ~/.nodenv/versions/20.9.0/bin/pnpm
bun: 1.0.25 - ~/.bun/bin/bun
Browsers:
Chrome: 128.0.6613.138
Safari: 17.0
npmPackages:
vitest: ^2.1.1 => 2.1.1Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable