Ensure that file-path sourcemaps load relative to the file containing the comment.
This commit is contained in:
parent
3c90baaf6c
commit
532c25c8db
@ -160,7 +160,7 @@ declare module "convert-source-map" {
|
||||
fromComment(str: string): Converter,
|
||||
fromMapFileComment(str: string): Converter,
|
||||
fromSource(str: string): Converter,
|
||||
fromMapFileSource(str: string): Converter,
|
||||
fromMapFileSource(str: string, dir: string): Converter,
|
||||
removeComments(str: string): string,
|
||||
removeMapFileComments(str: string): string,
|
||||
generateMapFileComment(path: string, options?: ?{ multiline: boolean }): string,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import path from "path";
|
||||
import buildDebug from "debug";
|
||||
import * as t from "@babel/types";
|
||||
import type { PluginPasses } from "../config";
|
||||
@ -47,14 +48,22 @@ export default function normalizeFile(
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromMapFileSource(code);
|
||||
if (typeof options.filename === "string") {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromMapFileSource(
|
||||
code,
|
||||
path.dirname(options.filename),
|
||||
);
|
||||
|
||||
if (inputMap) {
|
||||
if (inputMap) {
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
} catch (err) {
|
||||
debug("discarding unknown file input sourcemap", err);
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
} catch (err) {
|
||||
debug("discarding unknown file input sourcemap", err);
|
||||
} else {
|
||||
debug("discarding un-loadable file input sourcemap");
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user