optimize merge_tables, verbose remapper error

pull/5428/head
Milan Hauth 5 years ago
parent 47ffc055fb
commit b739bdbe19

@ -217,10 +217,21 @@ export default async function preprocess(
// remapper can throw error
// `Transformation map ${i} must have exactly one source file.`
// for 0 <= i <= (sourcemap_list.length - 2)
const map: ReturnType<typeof remapper> =
sourcemap_list.length == 0
? null
: remapper(sourcemap_list as any, () => null, true); // true: skip optional field `sourcesContent`
let map: ReturnType<typeof remapper>;
try {
map =
sourcemap_list.length == 0
? null
: remapper(sourcemap_list as any, () => null, true); // true: skip optional field `sourcesContent`
} catch (error) {
throw { ...error, message: error.message +
'\n\ncould not combine sourcemaps:\n' +
JSON.stringify((sourcemap_list as any).map(m => {
return { ...m, mappings: JSON.stringify(m.mappings).slice(0, 100)+' ....'};
}), null, 2)
};
}
if (map && !map.file) delete map.file; // skip optional field `file`

@ -53,6 +53,12 @@ function merge_tables<T>(this_table: T[], other_table): [T[], number[], boolean]
has_changed = true;
}
}
if (has_changed) {
if (idx_map.find((val, idx) => val != idx) === undefined) {
// idx_map is identity map [0, 1, 2, 3, 4, ....]
has_changed = false;
}
}
return [new_table, idx_map, has_changed];
}

@ -1,12 +1,12 @@
export function test({ assert, preprocessed, js, css }) {
const msg_expected = 'Transformation map 0 must have exactly one source file.';
assert.notEqual(preprocessed.error, undefined, 'expected preprocessed.error');
assert.notEqual(preprocessed.error, undefined, 'expected preprocessed.error');
const msg_expected_prefix = 'Transformation map 0 must have exactly one source file.';
assert.equal(
preprocessed.error.message.slice(0, msg_expected.length),
msg_expected
preprocessed.error.message.slice(0, msg_expected_prefix.length),
msg_expected_prefix
);
}

Loading…
Cancel
Save