Skip to content

Commit

Permalink
rebase and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
halfnelson committed Oct 29, 2020
1 parent 9583d72 commit 7138271
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/compiler/preprocess/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ function get_replacement(
let decoded_map: DecodedSourceMap;
if (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);
}
sourcemap_add_offset(decoded_map, get_location(offset + prefix.length));
}
const processed_with_map = StringWithSourcemap.from_processed(processed.code, decoded_map);
Expand Down Expand Up @@ -146,12 +147,13 @@ export default async function preprocess(

if (processed && processed.dependencies) dependencies.push(...processed.dependencies);
source = processed ? processed.code : source;
if (processed && processed.map)
if (processed && processed.map) {
sourcemap_list.unshift(
typeof(processed.map) === 'string'
? JSON.parse(processed.map)
: processed.map
);
}
}

for (const fn of script) {
Expand Down
8 changes: 5 additions & 3 deletions src/compiler/utils/string_with_sourcemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ function merge_tables<T>(this_table: T[], other_table): [T[], number[], boolean,
}

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]);
}
}

export class StringWithSourcemap {
Expand All @@ -69,15 +70,16 @@ export class StringWithSourcemap {

constructor(string = '', map = null) {
this.string = string;
if (map)
if (map) {
this.map = map as DecodedSourceMap;
else
} else {
this.map = {
version: 3,
mappings: [],
sources: [],
names: []
};
}
}

// concat in-place (mutable), return this (chainable)
Expand Down

0 comments on commit 7138271

Please sign in to comment.