Repository navigation
Add experimental support for range mappings in source maps - #18006
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62608 |
9abdbad to
b508a69
Compare
|
commit: |
b1667a1 to
25134a6
Compare
25134a6 to
e8163ab
Compare
e8163ab to
26d955f
Compare
26d955f to
b4053bf
Compare
b4053bf to
3f4b6ca
Compare
|
As the source maps libraries do not support yet merging source maps that use range mappings, we should automatically want and disable ranges when an |
3f4b6ca to
9b2db33
Compare
test262 resultsAs of 2da443c, this PR does not change any test262 results compared to |
Assisted-by: Claude Opus 5.5
0e510fe to
8e25d61
Compare
|
All review comments addressed |
JLHwung
left a comment
There was a problem hiding this comment.
Could you add a test for babel-cli? Currently babel --out-file is not aware of the rangeMappings right?
|
Good catch, I made it throw an error. Unfortunately the source map libraries that we use do not support composition/concatenation yet with range mappins. |
This comment was marked as outdated.
This comment was marked as outdated.
| if (opts.inputSourceMap) { | ||
| if (this.#allowRangeMappings) { | ||
| this.#allowRangeMappings = false; | ||
| console.warn( |
There was a problem hiding this comment.
This comment is from Claude Code:
This warning will be printed per-file if users have enabled sourceMapRanges and the input source contains //# sourceMappingURL comments. Consider warning once per process, or only when inputSourceMap was passed explicitly, would avoid flooding build output.
There was a problem hiding this comment.
The other warnings we have are per-file (e.g. discarding unknown file input sourcemap when the sourceMappingURLs point to source maps that are not actually included together with the input code).
This warning specifically could be for some files and not others, because some files might link to a source map and others may not, so there is value in having the filename there and warning per-file.
Also, there is an easy workaround for users to not see the warning: just disable the option that is a no-op for them.
Fixes #1, Fixes #2This PR implements the range mappings proposal for source maps. WebKit devtools just merged support for it.
The proposal is at stage 3, meaning that while there might be changes it's expected to be quite stable and changes would be due to implementation feedback. Given that we are in close coordination with all the tools implementing it (we have monthly calls in TC39-TG4), we can safely coordinate changes if they will happen.
Given this test case:
without range mappings we generate
{ version: 3, file: undefined, names: [ 'z' ], sourceRoot: undefined, sources: [ 'unknown' ], sourcesContent: [ 'let x, y, z, w;\nx + y + z + w;' ], mappings: 'AAAA,IAAI,CAAC,EAAE,CAAC,EAAEA,CAAC,EAAE,CAAC;AACd,CAAC,GAAG,CAAC,GAAGA,CAAC,GAAK,CAAC', ignoreList: undefined, rangeMappings: undefined }while with range mappings it becomes