Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency source-map to ^0.7.0 #385

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -48,7 +48,7 @@
"pretty-ms": "^4.0.0",
"protobufjs": "~6.8.6",
"semver": "^5.5.1",
"source-map": "^0.6.1",
"source-map": "^0.7.0",
"split": "^1.0.1",
"teeny-request": "^3.3.0"
},
Expand Down
21 changes: 6 additions & 15 deletions ts/src/sourcemapper/sourcemapper.ts
Expand Up @@ -35,7 +35,7 @@ const MAP_EXT = '.map';

export interface MapInfoCompiled {
mapFileDir: string;
mapConsumer: sourceMap.RawSourceMap;
mapConsumer: sourceMap.SourceMapConsumer;
}

export interface GeneratedLocation {
Expand Down Expand Up @@ -68,24 +68,15 @@ async function processSourceMap(
}
mapPath = path.normalize(mapPath);

let contents;
let contents: sourceMap.RawSourceMap;
try {
contents = await readFile(mapPath, 'utf8');
} catch (e) {
throw new Error('Could not read source map file ' + mapPath + ': ' + e);
}

let consumer: sourceMap.RawSourceMap;
let consumer: sourceMap.SourceMapConsumer;
try {
// TODO: Determine how to reconsile the type conflict where `consumer`
// is constructed as a SourceMapConsumer but is used as a
// RawSourceMap.
// TODO: Resolve the cast of `contents as any` (This is needed because the
// type is expected to be of `RawSourceMap` but the existing
// working code uses a string.)
consumer = new sourceMap.SourceMapConsumer(
contents as {} as sourceMap.RawSourceMap) as {} as
sourceMap.RawSourceMap;
consumer = await new sourceMap.SourceMapConsumer(contents);
} catch (e) {
throw new Error(
'An error occurred while reading the ' +
Expand All @@ -100,7 +91,7 @@ async function processSourceMap(
*/
const dir = path.dirname(mapPath);
const generatedBase =
consumer.file ? consumer.file : path.basename(mapPath, MAP_EXT);
contents.file ? contents.file : path.basename(mapPath, MAP_EXT);
const generatedPath = path.resolve(dir, generatedBase);

infoMap.set(generatedPath, {mapFileDir: dir, mapConsumer: consumer});
Expand Down Expand Up @@ -196,7 +187,7 @@ export class SourceMapper {
file: path.resolve(entry.mapFileDir, pos.source),
line: pos.line || undefined,
name: pos.name || location.name,
column: pos.column,
column: pos.column || undefined,
};
}
}
Expand Down