Commit 986094d
fix(register): always inline source maps in auto mode so debuggers work (#1062)
The auto source-map mode introduced in 1.12.0 only inlined the map into
the emitted code when `process.sourceMapsEnabled` was true (i.e. Node was
started with `--enable-source-maps`). Otherwise it fell back to store-only
mode, which populates SourcemapMap for `@swc-node/sourcemap-support` to
rewrite `Error.stack`, but emits no inline `//# sourceMappingURL=`.
The V8 inspector reads that inline map off the running code to bind
breakpoints, and it does so regardless of `--enable-source-maps`. With no
inline map, debuggers (VS Code, `node --inspect`) stopped binding
breakpoints or landed on the wrong line. This is the 1.12.0 regression in
#1059.
Auto mode now always inlines the map, and additionally stores it only when
native source maps are off (so stack traces stay correct without retaining
a duplicate map when Node already handles them). This restores the 1.11.1
behavior of always emitting an inline map. The `inline`/`store`/`none`
env modes are unchanged.
Closes #1059
Claude-Session: https://claude.ai/code/session_01LXSDomd3mGu4SL4TJ9q6T2
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent eec0e8c commit 986094d
2 files changed
Lines changed: 42 additions & 3 deletions
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
127 | 158 | | |
128 | 159 | | |
129 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
0 commit comments