inputSourceMap should work when it is in an external file (#10623)
* fix: construct comment block for fromMapFileComment * add test * small tweak: redundant capturing group
This commit is contained in:
parent
a2b5437b01
commit
d08702c9d2
@ -65,7 +65,8 @@ export default function normalizeFile(
|
|||||||
if (typeof options.filename === "string" && lastComment) {
|
if (typeof options.filename === "string" && lastComment) {
|
||||||
try {
|
try {
|
||||||
inputMap = convertSourceMap.fromMapFileComment(
|
inputMap = convertSourceMap.fromMapFileComment(
|
||||||
lastComment,
|
// fromMapFileComment requires the whole comment block
|
||||||
|
`//${lastComment}`,
|
||||||
path.dirname(options.filename),
|
path.dirname(options.filename),
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -156,7 +157,7 @@ function parser(
|
|||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$/;
|
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=(?:[^\s'"`]+?)[ \t]*$/;
|
||||||
|
|
||||||
function extractCommentsFromList(regex, comments, lastComment) {
|
function extractCommentsFromList(regex, comments, lastComment) {
|
||||||
if (comments) {
|
if (comments) {
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
var foo = function () {
|
||||||
|
return 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=input.js.map
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["original.js"],"names":[],"mappings":"AAAA,UAAU,Y;SAAM,C;CAAC","sourcesContent":["var foo = () => 4;"]}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"inputSourceMap": true
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
var foo = function () {
|
||||||
|
return 4;
|
||||||
|
};
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"mappings": "AAAA,IAAA,GAAA,GAAU,Y;SAAM,C;AAAC,CAAjB",
|
||||||
|
"names": [],
|
||||||
|
"sources": ["original.js"],
|
||||||
|
"sourcesContent": ["var foo = () => 4;"],
|
||||||
|
"version": 3
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user