evanw / evanw/node-source-map-support

File path is lost when translating stack traces

Open
#120 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.2k
Forks
223
PR merge metrics
No merged PRs in 30d

Description

When using node-source-map-support (v0.2.10) via `babel-node`, file paths are being lost for the files local to the package. This also occurs when I override babel's copy to `source-map-support@0.4.0`

With the file `foo/bar.js`:

```
console.trace();
console.log(new Error().stack);
```

When running the file via regular node, I get stack traces with full file paths:

```
> node foo/bar.js
Trace
at Object. (/babel-repro/foo/bar.js:1:71)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
Error
at Object. (/babel-repro/foo/bar.js:2:13)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:117:18)
at node.js:951:3
```

When running with `babel-node`, the path of the source file is lost:

```
> babel-node foo/bar.js
Trace
at Object. (bar.js:1:17)
at Module._compile (module.js:434:26)
at loader (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:130:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:140:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at /Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/lib/_babel-node.js:161:27
at Object. (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/lib/_babel-node.js:162:7)
at Module._compile (module.js:434:26)
Error
at Object. (bar.js:2:13)
at Module._compile (module.js:434:26)
at loader (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:130:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/node_modules/babel-register/lib/node.js:140:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at /Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/lib/_babel-node.js:161:27
at Object. (/Users/ian/.nvm/versions/node/v4.1.0/lib/node_modules/babel-cli/lib/_babel-node.js:162:7)
at Module._compile (module.js:434:26)
```

This occurs at any directory depth; only the file's base name survives. Is there something Babel's doing incorrectly here?

For reference, Babel [sets up source-map-support via `babel-register`](https://github.com/babel/babel/blob/master/packages/babel-register/src/node.js#L13-L26)

Related Babel issue: https://phabricator.babeljs.io/T6839

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.