Skip to content

Pass sourceMapUrl through in SourceMapConsumer.fromSourceMap - #545

Open
sebxt wants to merge 1 commit into
mozilla:masterfrom
sebxt:fix/fromsourcemap-ignores-url
Open

sebxt wants to merge 1 commit into
mozilla:masterfrom
sebxt:fix/fromsourcemap-ignores-url

Conversation

@sebxt

@sebxt sebxt commented Oct 20, 2026

Copy link
Copy Markdown

SourceMapConsumer.fromSourceMap accepts a sourceMapUrl argument (see the JSDoc and source-map.d.ts), but BasicSourceMapConsumer.fromSourceMap did not forward it to the constructor. As a result relative sources were not resolved against the map's URL, unlike new SourceMapConsumer(map, url).

This forwards the URL to the constructor.

Testing: added test SourceMapConsumer.fromSourceMap with a source map URL in test/test-source-map-consumer.js, which checks sources, originalPositionFor and sourceContentFor against the resolved URL. It fails on current master ('src/a.js' == 'http://example.com/maps/src/a.js') and passes with the fix. npm test passes (191 / 191), and eslint and prettier are clean on the touched files.

Fixes #544

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SourceMapConsumer.fromSourceMap ignores its sourceMapUrl argument

1 participant