When source set to null, mapping does not generated.
When source set to empty string there is an error during mapping calculation (not during SourceNode creation as expected if empty string is forbidden).
This code snippet demonstrates both problems: https://runkit.com/embed/47lduu6k2173
Source code of the snippet:
let SourceNode = require('source-map').SourceNode;
function test(source) {
let node = new SourceNode(
null,
null,
source,
[
'prefix',
new SourceNode(1, 0, source, 'code'),
'suffix',
]
);
let { code, map } = node.toStringWithSourceMap();
console.log(map.toJSON(), code);
}
// {version: 3, sources: ["source"], names: [], mappings: "MAAA,I"}
test("source");// OK
// {version: 3, sources: [], names: [], mappings: ""}
test(null); // Empty mapping
// Error: Invalid mapping: {"generated":{"line":1,"column":6},"source":"","original":{"line":1,"column":0},"name":null}
test(""); // Error
When
sourceset tonull, mapping does not generated.When
sourceset to empty string there is an error during mapping calculation (not duringSourceNodecreation as expected if empty string is forbidden).This code snippet demonstrates both problems: https://runkit.com/embed/47lduu6k2173
Source code of the snippet: