rebase and fix lint

pull/5584/head
halfnelson 5 years ago
parent 9583d72c92
commit 713827126a

@ -104,8 +104,9 @@ function get_replacement(
let decoded_map: DecodedSourceMap; let decoded_map: DecodedSourceMap;
if (processed.map) { if (processed.map) {
decoded_map = typeof processed.map === 'string' ? JSON.parse(processed.map) : processed.map; decoded_map = typeof processed.map === 'string' ? JSON.parse(processed.map) : processed.map;
if (typeof(decoded_map.mappings) === 'string') if (typeof(decoded_map.mappings) === 'string') {
decoded_map.mappings = decode_mappings(decoded_map.mappings); decoded_map.mappings = decode_mappings(decoded_map.mappings);
}
sourcemap_add_offset(decoded_map, get_location(offset + prefix.length)); sourcemap_add_offset(decoded_map, get_location(offset + prefix.length));
} }
const processed_with_map = StringWithSourcemap.from_processed(processed.code, decoded_map); const processed_with_map = StringWithSourcemap.from_processed(processed.code, decoded_map);
@ -146,13 +147,14 @@ export default async function preprocess(
if (processed && processed.dependencies) dependencies.push(...processed.dependencies); if (processed && processed.dependencies) dependencies.push(...processed.dependencies);
source = processed ? processed.code : source; source = processed ? processed.code : source;
if (processed && processed.map) if (processed && processed.map) {
sourcemap_list.unshift( sourcemap_list.unshift(
typeof(processed.map) === 'string' typeof(processed.map) === 'string'
? JSON.parse(processed.map) ? JSON.parse(processed.map)
: processed.map : processed.map
); );
} }
}
for (const fn of script) { for (const fn of script) {
const get_location = getLocator(source); const get_location = getLocator(source);

@ -59,9 +59,10 @@ function merge_tables<T>(this_table: T[], other_table): [T[], number[], boolean,
} }
function pushArray<T>(_this: T[], other: T[]) { function pushArray<T>(_this: T[], other: T[]) {
for (let i = 0; i < other.length; i++) for (let i = 0; i < other.length; i++) {
_this.push(other[i]); _this.push(other[i]);
} }
}
export class StringWithSourcemap { export class StringWithSourcemap {
string: string; string: string;
@ -69,9 +70,9 @@ export class StringWithSourcemap {
constructor(string = '', map = null) { constructor(string = '', map = null) {
this.string = string; this.string = string;
if (map) if (map) {
this.map = map as DecodedSourceMap; this.map = map as DecodedSourceMap;
else } else {
this.map = { this.map = {
version: 3, version: 3,
mappings: [], mappings: [],
@ -79,6 +80,7 @@ export class StringWithSourcemap {
names: [] names: []
}; };
} }
}
// concat in-place (mutable), return this (chainable) // concat in-place (mutable), return this (chainable)
// will also mutate the `other` object // will also mutate the `other` object

Loading…
Cancel
Save