Fix inputSourcemapMerge when no JS content is output.

This commit is contained in:
Logan Smyth 2018-05-01 20:31:29 -07:00
parent 494a56df5f
commit a3e622ad15

View File

@ -10,12 +10,6 @@ export default function mergeSourceMap(
const input = buildMappingData(inputMap); const input = buildMappingData(inputMap);
const output = buildMappingData(map); const output = buildMappingData(map);
// Babel-generated maps always map to a single input filename.
if (output.sources.length !== 1) {
throw new Error("Assertion failure - expected a single output file");
}
const defaultSource = output.sources[0];
const mergedGenerator = new sourceMap.SourceMapGenerator(); const mergedGenerator = new sourceMap.SourceMapGenerator();
for (const { source } of input.sources) { for (const { source } of input.sources) {
if (typeof source.content === "string") { if (typeof source.content === "string") {
@ -23,6 +17,9 @@ export default function mergeSourceMap(
} }
} }
if (output.sources.length === 1) {
const defaultSource = output.sources[0];
const insertedMappings = new Map(); const insertedMappings = new Map();
// Process each generated range in the input map, e.g. each range over the // Process each generated range in the input map, e.g. each range over the
@ -84,6 +81,7 @@ export default function mergeSourceMap(
}, },
}); });
} }
}
const result = mergedGenerator.toJSON(); const result = mergedGenerator.toJSON();
// addMapping expects a relative path, and setSourceContent expects an // addMapping expects a relative path, and setSourceContent expects an