Skip to content

fix(compiler): resolve mapRoot before it is used in source maps - #1063

Merged
camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/emitter-map-root-resolve-directory
Nov 21, 2026
Merged

camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/emitter-map-root-resolve-directory

Conversation

@magurotuna

Copy link
Copy Markdown
Member

tsrs used mapRoot as written:

// "mapRoot": "https://example.com/a/../m"
//# sourceMappingURL=https://example.com/a/../m/a.js.map   (tsrs)
//# sourceMappingURL=https://example.com/m/a.js.map        (tsgo)

With "mapRoot": "^", the map sources were also file:// URLs instead of ../a.ts.

Go resolves mapRoot first in getMapRootDirectory, and then adds the directory of the source file. This PR ports that function with tspath::resolve_file and tspath::to_rooted_path.

Tests: maproot_not_resolved in tsrs_cli.

AI assistance: written with Claude Code.

tsrs used `mapRoot` as written:

```js
// "mapRoot": "https://example.com/a/../m"
//# sourceMappingURL=https://example.com/a/../m/a.js.map   (tsrs)
//# sourceMappingURL=https://example.com/m/a.js.map        (tsgo)
```

With `"mapRoot": "^"`, the map `sources` were also `file://` URLs instead of
`../a.ts`.

Go resolves `mapRoot` first in `getMapRootDirectory`
(`compiler/emitter.go:418`), and then adds the directory of the source file.
Port that function with `tspath::resolve_file` and `tspath::to_rooted_path`.

Tests: `maproot_not_resolved` in `tsrs_cli`.

AI assistance: written with Claude Code.
@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

βœ… 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing magurotuna:fix/emitter-map-root-resolve-directory (847d37b) with main (fd57202)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@camc314
camc314 added this pull request to the merge queue Nov 21, 2026
Merged via the queue into oxc-project:main with commit ae99b78 Nov 21, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants