-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Open
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.
Description
Version
v22.2.0
Platform
Linux 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
I'm using esbuild to generate a very small source map for the next code:
const { getSourceMapsEnabled } = require('internal/source_map/source_map_cache');
console.log(getSourceMapsEnabled());
throw new Error();
I'm calling an internal function I found to see if the source maps are enabled. Here's the code, esbuild spits out:
// test.js
var { getSourceMapsEnabled } = require("internal/source_map/source_map_cache");
console.log(getSourceMapsEnabled());
throw new Error();
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidGVzdC5qcyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiY29uc3QgeyBnZXRTb3VyY2VNYXBzRW5hYmxlZCB9ID0gcmVxdWlyZSgnaW50ZXJuYWwvc291cmNlX21hcC9zb3VyY2VfbWFwX2NhY2hlJyk7XG5jb25zb2xlLmxvZyhnZXRTb3VyY2VNYXBzRW5hYmxlZCgpKTtcbnRocm93IG5ldyBFcnJvcigpO1xuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUFBLElBQU0sRUFBRSxxQkFBcUIsSUFBSSxRQUFRLHNDQUFzQztBQUMvRSxRQUFRLElBQUkscUJBQXFCLENBQUM7QUFDbEMsTUFBTSxJQUFJLE1BQU07IiwKICAibmFtZXMiOiBbXQp9Cg==
If you were to write this to a file, say otherFile.js
and run it like so:
node --expose-internals --enable-source-maps otherFile.js
You would see the source maps are being used correctly, replacing the name of the file with the name of the original file ("test.js").
true
/tmp/test.js:3
throw new Error();
^
Error
at Object.<anonymous> (/tmp/test.js:3:7)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:12)
at node:internal/main/run_main_module:30:49
Node.js v22.2.0
However, if you were to pipe it through stdin, the source maps will not work and instead you'll just get [stdin]
.
cat otherFile.js | node --expose-internals --enable-source-maps
true
[stdin]:4
throw new Error();
^
Error
at [stdin]:4:7
at runScriptInThisContext (node:internal/vm:209:10)
at node:internal/process/execution:118:14
at [stdin]-wrapper:6:24
at runScript (node:internal/process/execution:101:62)
at evalScript (node:internal/process/execution:136:3)
at node:internal/main/eval_stdin:32:5
at Socket.<anonymous> (node:internal/process/execution:237:5)
at Socket.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1696:12)
Node.js v22.2.0
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
It should probably build a stack trace with the source map information.
What do you see instead?
Source maps are not being used.
Additional information
No response
Metadata
Metadata
Assignees
Labels
source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.