Merge pull request #8198 from loganfsmyth/sourcemap-loading
Prefer explicit object maps, and properly load relative maps.
This commit is contained in:
commit
9bd4b46fd6
@ -160,7 +160,7 @@ declare module "convert-source-map" {
|
|||||||
fromComment(str: string): Converter,
|
fromComment(str: string): Converter,
|
||||||
fromMapFileComment(str: string): Converter,
|
fromMapFileComment(str: string): Converter,
|
||||||
fromSource(str: string): Converter,
|
fromSource(str: string): Converter,
|
||||||
fromMapFileSource(str: string): Converter,
|
fromMapFileSource(str: string, dir: string): Converter,
|
||||||
removeComments(str: string): string,
|
removeComments(str: string): string,
|
||||||
removeMapFileComments(str: string): string,
|
removeMapFileComments(str: string): string,
|
||||||
generateMapFileComment(path: string, options?: ?{ multiline: boolean }): string,
|
generateMapFileComment(path: string, options?: ?{ multiline: boolean }): string,
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
import path from "path";
|
||||||
import buildDebug from "debug";
|
import buildDebug from "debug";
|
||||||
import * as t from "@babel/types";
|
import * as t from "@babel/types";
|
||||||
import type { PluginPasses } from "../config";
|
import type { PluginPasses } from "../config";
|
||||||
@ -27,6 +28,13 @@ export default function normalizeFile(
|
|||||||
|
|
||||||
let inputMap = null;
|
let inputMap = null;
|
||||||
if (options.inputSourceMap !== false) {
|
if (options.inputSourceMap !== false) {
|
||||||
|
// If an explicit object is passed in, it overrides the processing of
|
||||||
|
// source maps that may be in the file itself.
|
||||||
|
if (typeof options.inputSourceMap === "object") {
|
||||||
|
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!inputMap) {
|
||||||
try {
|
try {
|
||||||
inputMap = convertSourceMap.fromSource(code);
|
inputMap = convertSourceMap.fromSource(code);
|
||||||
|
|
||||||
@ -37,10 +45,15 @@ export default function normalizeFile(
|
|||||||
debug("discarding unknown inline input sourcemap", err);
|
debug("discarding unknown inline input sourcemap", err);
|
||||||
code = convertSourceMap.removeComments(code);
|
code = convertSourceMap.removeComments(code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!inputMap) {
|
if (!inputMap) {
|
||||||
|
if (typeof options.filename === "string") {
|
||||||
try {
|
try {
|
||||||
inputMap = convertSourceMap.fromMapFileSource(code);
|
inputMap = convertSourceMap.fromMapFileSource(
|
||||||
|
code,
|
||||||
|
path.dirname(options.filename),
|
||||||
|
);
|
||||||
|
|
||||||
if (inputMap) {
|
if (inputMap) {
|
||||||
code = convertSourceMap.removeMapFileComments(code);
|
code = convertSourceMap.removeMapFileComments(code);
|
||||||
@ -49,10 +62,10 @@ export default function normalizeFile(
|
|||||||
debug("discarding unknown file input sourcemap", err);
|
debug("discarding unknown file input sourcemap", err);
|
||||||
code = convertSourceMap.removeMapFileComments(code);
|
code = convertSourceMap.removeMapFileComments(code);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
debug("discarding un-loadable file input sourcemap");
|
||||||
|
code = convertSourceMap.removeMapFileComments(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inputMap && typeof options.inputSourceMap === "object") {
|
|
||||||
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user