UEA-Prodem
This commit is contained in:
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = readInputSourceMapFile;
|
||||
function readInputSourceMapFile() {
|
||||
throw new Error("Reading input source map files is not supported in browsers");
|
||||
}
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=read-input-source-map-file-browser.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"names":["readInputSourceMapFile","Error"],"sources":["../../src/transformation/read-input-source-map-file-browser.ts"],"sourcesContent":["export default function readInputSourceMapFile(): never {\n throw new Error(\n \"Reading input source map files is not supported in browsers\",\n );\n}\n"],"mappings":";;;;;;AAAe,SAASA,sBAAsBA,CAAA,EAAU;EACtD,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;AACH;AAAC","ignoreList":[]}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = readInputSourceMapFile;
|
||||
function _fs() {
|
||||
const data = require("fs");
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _path() {
|
||||
const data = require("path");
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _debug() {
|
||||
const data = require("debug");
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _convertSourceMap() {
|
||||
const data = require("convert-source-map");
|
||||
_convertSourceMap = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
const debug = _debug()("babel:transform:file");
|
||||
function findUpSync(name, {
|
||||
cwd,
|
||||
stopAt
|
||||
} = {}) {
|
||||
let directory = _path().resolve(cwd || "");
|
||||
const {
|
||||
root
|
||||
} = _path().parse(directory);
|
||||
stopAt = _path().resolve(directory, stopAt || root);
|
||||
const isAbsoluteName = _path().isAbsolute(name);
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : _path().join(directory, name);
|
||||
try {
|
||||
const stats = _fs().statSync(filePath);
|
||||
if (stats.isFile()) {
|
||||
return filePath;
|
||||
}
|
||||
} catch (_) {}
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
directory = _path().dirname(directory);
|
||||
}
|
||||
}
|
||||
function getInputMapPath(filename, root, inputMapURL) {
|
||||
const inputFileDir = _path().dirname(filename);
|
||||
const inputMapPath = _path().resolve(inputFileDir, inputMapURL);
|
||||
const relativeToInputFileDir = _path().relative(inputFileDir, inputMapPath);
|
||||
if (relativeToInputFileDir.startsWith("..") || _path().isAbsolute(relativeToInputFileDir)) {
|
||||
const inputPackageJSONPath = findUpSync("package.json", {
|
||||
cwd: inputFileDir,
|
||||
stopAt: root
|
||||
});
|
||||
const inputFileRoot = inputPackageJSONPath ? _path().dirname(inputPackageJSONPath) : root;
|
||||
const relativeInputMapPath = _path().relative(inputFileRoot, inputMapPath);
|
||||
if (relativeInputMapPath.startsWith("..") || _path().isAbsolute(relativeInputMapPath)) {
|
||||
debug(`discarding input sourcemap "${inputMapPath}" outside of package root "${inputFileRoot}"`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return inputMapPath;
|
||||
}
|
||||
function readInputSourceMapFile(filename, root, inputMapURL) {
|
||||
const inputMapPath = getInputMapPath(filename, root, inputMapURL);
|
||||
if (inputMapPath) {
|
||||
const inputMapContent = _fs().readFileSync(inputMapPath, "utf8");
|
||||
return _convertSourceMap().fromJSON(inputMapContent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
0 && 0;
|
||||
|
||||
//# sourceMappingURL=read-input-source-map-file.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export default function readInputSourceMapFile(): never {
|
||||
throw new Error(
|
||||
"Reading input source map files is not supported in browsers",
|
||||
);
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import buildDebug from "debug";
|
||||
import convertSourceMap from "convert-source-map";
|
||||
import type { SourceMapConverter } from "convert-source-map";
|
||||
|
||||
const debug = buildDebug("babel:transform:file");
|
||||
|
||||
// Revised from https://github.com/sindresorhus/find-up-simple/blob/f10133c55dcbf36f84a246c6f1bbfed178dcb774/index.js#L36
|
||||
// for Node.js 6 compatibility
|
||||
function findUpSync(
|
||||
name: string,
|
||||
{
|
||||
cwd,
|
||||
stopAt,
|
||||
}: {
|
||||
cwd?: string;
|
||||
stopAt?: string;
|
||||
} = {},
|
||||
) {
|
||||
let directory = path.resolve(cwd || "");
|
||||
const { root } = path.parse(directory);
|
||||
stopAt = path.resolve(directory, stopAt || root);
|
||||
const isAbsoluteName = path.isAbsolute(name);
|
||||
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
||||
|
||||
try {
|
||||
const stats = fs.statSync(filePath);
|
||||
if (stats.isFile()) {
|
||||
return filePath;
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
}
|
||||
|
||||
function getInputMapPath(
|
||||
filename: string,
|
||||
root: string,
|
||||
inputMapURL: string,
|
||||
): string | null {
|
||||
const inputFileDir = path.dirname(filename);
|
||||
const inputMapPath = path.resolve(inputFileDir, inputMapURL);
|
||||
const relativeToInputFileDir = path.relative(inputFileDir, inputMapPath);
|
||||
|
||||
if (
|
||||
relativeToInputFileDir.startsWith("..") ||
|
||||
path.isAbsolute(relativeToInputFileDir)
|
||||
) {
|
||||
const inputPackageJSONPath = findUpSync("package.json", {
|
||||
cwd: inputFileDir,
|
||||
stopAt: root,
|
||||
});
|
||||
const inputFileRoot = inputPackageJSONPath
|
||||
? path.dirname(inputPackageJSONPath)
|
||||
: root;
|
||||
const relativeInputMapPath = path.relative(inputFileRoot, inputMapPath);
|
||||
if (
|
||||
relativeInputMapPath.startsWith("..") ||
|
||||
path.isAbsolute(relativeInputMapPath)
|
||||
) {
|
||||
debug(
|
||||
`discarding input sourcemap "${inputMapPath}" outside of package root "${inputFileRoot}"`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return inputMapPath;
|
||||
}
|
||||
|
||||
export default function readInputSourceMapFile(
|
||||
filename: string,
|
||||
root: string,
|
||||
inputMapURL: string,
|
||||
): SourceMapConverter | null {
|
||||
const inputMapPath = getInputMapPath(filename, root, inputMapURL);
|
||||
if (inputMapPath) {
|
||||
const inputMapContent = fs.readFileSync(inputMapPath, "utf8");
|
||||
return convertSourceMap.fromJSON(inputMapContent);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user