Prefer object sourcemaps over file-inlined sourcemaps.

This commit is contained in:
Logan Smyth 2018-06-18 21:49:23 -07:00
parent 5895277b32
commit 3c90baaf6c

View File

@ -27,15 +27,23 @@ export default function normalizeFile(
let inputMap = null;
if (options.inputSourceMap !== false) {
try {
inputMap = convertSourceMap.fromSource(code);
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (inputMap) {
if (!inputMap) {
try {
inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
}
if (!inputMap) {
@ -50,10 +58,6 @@ export default function normalizeFile(
code = convertSourceMap.removeMapFileComments(code);
}
}
if (!inputMap && typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
}
if (ast) {