TypeError when creating a SourceMapGenerator from a SourceMapConsumer of an index map
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Start with lib/source-map-generator.js around fromSourceMap and lib/util.js around relative, then reproduce the failure using the test.js example in the issue. Add a regression test for converting an index-map SourceMapConsumer, and consider the existing sourceRoot comparisons. Done means conversion no longer throws and the relevant tests pass.
Written by the indexing model from the issue text.
Description
When calling SourceMapGenerator.fromSourceMap with a SourceMapConsumer for an index map, the following error is thrown:
TypeError: Cannot read property 'replace' of undefined
at Object.relative (C:\dev\scratch\source-map-test\node_modules\source-map\lib\util.js:255:17)
at C:\dev\scratch\source-map-test\node_modules\source-map\lib\source-map-generator.js:75:31
at Array.forEach (<anonymous>)
at Function.fromSourceMap (C:\dev\scratch\source-map-test\node_modules\source-map\lib\source-map-generator.js:72:32)
at test (C:\dev\scratch\source-map-test\test.js:17:52)
at <anonymous>
test.js
const sourcemap = require("source-map");
async function test() {
const map = {
file: "generated.js",
version: 3,
sections: [
{ offset: { column: 0, line: 0 }, map: {
file: "part.js",
version: 3,
sources: ["source.js"],
mappings: "",
names: []
} }
]
};
const consumer = await new sourcemap.SourceMapConsumer(map);
const generator = sourcemap.SourceMapGenerator.fromSourceMap(consumer); // TypeError
}
The error seems to be due to a strict inequality (!==) check on sourceRoot whereas all other checks against sourceRoot use loose inequality (!=).
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mozilla/source-map
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
mozilla/source-map#530 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
mozilla/source-map#527 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
mozilla/source-map#524 · 6 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
mozilla/source-map#516 ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
mozilla/source-map#510 · 1 reaction ·
All issues in mozilla/source-map
Similar issues
-
bug confirmed issue
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
open-webui/open-webui#30750 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100