Skip to content

Resolve relative source maps and honor sourceRoot#307

Merged
TwitchBronBron merged 3 commits intomasterfrom
bugfix/relitive-sourcemap-not-resolving-correctly
Apr 6, 2026
Merged

Resolve relative source maps and honor sourceRoot#307
TwitchBronBron merged 3 commits intomasterfrom
bugfix/relitive-sourcemap-not-resolving-correctly

Conversation

@chrisdp
Copy link
Copy Markdown
Collaborator

@chrisdp chrisdp commented Mar 26, 2026

In SourceMapManager.ts, a relative sourceRoot was passed directly to path.resolve(), which resolves it against process.cwd() instead of the source map file's directory.

Fix (two changes):

  • Resolve sourceRoot against path.dirname(sourceMapPath) first, so relative sourceRoots work correctly — e.g. ../../src in a map at pkg/components/foo.brs.map now correctly resolves to src/ at the project root.
  • Clear parsedSourceMap.sourceRoot after resolving, so SourceMapConsumer doesn't try to re-apply it on top of the already-absolute sources paths.In SourceMapManager.ts:72, a relative sourceRoot was passed directly to path.resolve(), which resolves it against process.cwd() instead of the source map file's directory.

@chrisdp chrisdp requested a review from TwitchBronBron March 26, 2026 17:03
@chrisdp chrisdp added the bug Something isn't working label Mar 26, 2026
@TwitchBronBron TwitchBronBron changed the title first pass at correctly resolving relitive source maps first pass at correctly resolving relative source maps Mar 26, 2026
Copy link
Copy Markdown
Member

@TwitchBronBron TwitchBronBron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, once you've tested and verified this works, it's good to merge

@TwitchBronBron TwitchBronBron changed the title first pass at correctly resolving relative source maps Resolve relative source maps and honor sourceRoot Apr 6, 2026
@TwitchBronBron TwitchBronBron merged commit af31533 into master Apr 6, 2026
7 checks passed
@TwitchBronBron TwitchBronBron deleted the bugfix/relitive-sourcemap-not-resolving-correctly branch April 6, 2026 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants