-
Notifications
You must be signed in to change notification settings - Fork 364
Open
Labels
needs-triageUnconfirmed issuesUnconfirmed issues
Description
;(async () => {
let mozilla = require('source-map')
let map;
map = {
version: 3,
sections: [
{
offset: { line: 0, column: 0 },
map: {
version: 3,
sources: ['123', '456'],
sourcesContent: ['a\nb\nc\n', ''],
mappings: 'AAAA;AACA;AACA;'
}
}
]
}
// this map works for some reason
/*map = {
version: 3,
sources: ['123', '456'],
sourcesContent: ['a\nb\nc\n', ''],
mappings: 'AAAA;AACA;AACA;'
}*/
let consumer = await new mozilla.SourceMapConsumer(map)
consumer.sourceRoot = null; // https://github.com/mozilla/source-map/issues/345
let generator = mozilla.SourceMapGenerator.fromSourceMap(consumer)
console.log(generator.toJSON())
})().catch(console.log)
This errors out:
Error: "456" is not in the SourceMap.
at IndexedSourceMapConsumer.sourceContentFor (/tmp/node_modules/source-map/lib/source-map-consumer.js:840:11)
at /tmp/node_modules/source-map/lib/source-map-generator.js:82:42
at Array.forEach (<anonymous>)
at Function.fromSourceMap (/tmp/node_modules/source-map/lib/source-map-generator.js:72:32)
at /tmp/123/test.js:29:46
The issue is in here somewhere:
source-map/lib/source-map-consumer.js
Line 880 in 7a26340
if (content) { |
Content is empty - ''
- but it is still in the sourcemap. I believe it should be if (content == null) {
check, i.e. null or undefined, letting empty string pass along.
this may be related to #345, so tagging it just in case
Metadata
Metadata
Assignees
Labels
needs-triageUnconfirmed issuesUnconfirmed issues