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,6 +27,13 @@ export default function normalizeFile(
let inputMap = null; let inputMap = null;
if (options.inputSourceMap !== false) { if (options.inputSourceMap !== false) {
// 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) {
try { try {
inputMap = convertSourceMap.fromSource(code); inputMap = convertSourceMap.fromSource(code);
@ -37,6 +44,7 @@ export default function normalizeFile(
debug("discarding unknown inline input sourcemap", err); debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code); code = convertSourceMap.removeComments(code);
} }
}
if (!inputMap) { if (!inputMap) {
try { try {
@ -50,10 +58,6 @@ export default function normalizeFile(
code = convertSourceMap.removeMapFileComments(code); code = convertSourceMap.removeMapFileComments(code);
} }
} }
if (!inputMap && typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
} }
if (ast) { if (ast) {