Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@babel/core

Package Overview
Dependencies
Maintainers
4
Versions
227
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/core - npm Package Compare versions

Comparing version
7.29.0
to
7.29.6
+12
lib/transformation/read-input-source-map-file-browser.js
"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
{"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":[]}
"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
{"version":3,"names":["_fs","data","require","_path","_debug","_convertSourceMap","debug","buildDebug","findUpSync","name","cwd","stopAt","directory","path","resolve","root","parse","isAbsoluteName","isAbsolute","filePath","join","stats","fs","statSync","isFile","_","dirname","getInputMapPath","filename","inputMapURL","inputFileDir","inputMapPath","relativeToInputFileDir","relative","startsWith","inputPackageJSONPath","inputFileRoot","relativeInputMapPath","readInputSourceMapFile","inputMapContent","readFileSync","convertSourceMap","fromJSON"],"sources":["../../src/transformation/read-input-source-map-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport buildDebug from \"debug\";\nimport convertSourceMap from \"convert-source-map\";\nimport type { SourceMapConverter } from \"convert-source-map\";\n\nconst debug = buildDebug(\"babel:transform:file\");\n\n// Revised from https://github.com/sindresorhus/find-up-simple/blob/f10133c55dcbf36f84a246c6f1bbfed178dcb774/index.js#L36\n// for Node.js 6 compatibility\nfunction findUpSync(\n name: string,\n {\n cwd,\n stopAt,\n }: {\n cwd?: string;\n stopAt?: string;\n } = {},\n) {\n let directory = path.resolve(cwd || \"\");\n const { root } = path.parse(directory);\n stopAt = path.resolve(directory, stopAt || root);\n const isAbsoluteName = path.isAbsolute(name);\n\n while (directory) {\n const filePath = isAbsoluteName ? name : path.join(directory, name);\n\n try {\n const stats = fs.statSync(filePath);\n if (stats.isFile()) {\n return filePath;\n }\n } catch (_) {}\n\n if (directory === stopAt || directory === root) {\n break;\n }\n\n directory = path.dirname(directory);\n }\n}\n\nfunction getInputMapPath(\n filename: string,\n root: string,\n inputMapURL: string,\n): string | null {\n const inputFileDir = path.dirname(filename);\n const inputMapPath = path.resolve(inputFileDir, inputMapURL);\n const relativeToInputFileDir = path.relative(inputFileDir, inputMapPath);\n\n if (\n relativeToInputFileDir.startsWith(\"..\") ||\n path.isAbsolute(relativeToInputFileDir)\n ) {\n const inputPackageJSONPath = findUpSync(\"package.json\", {\n cwd: inputFileDir,\n stopAt: root,\n });\n const inputFileRoot = inputPackageJSONPath\n ? path.dirname(inputPackageJSONPath)\n : root;\n const relativeInputMapPath = path.relative(inputFileRoot, inputMapPath);\n if (\n relativeInputMapPath.startsWith(\"..\") ||\n path.isAbsolute(relativeInputMapPath)\n ) {\n debug(\n `discarding input sourcemap \"${inputMapPath}\" outside of package root \"${inputFileRoot}\"`,\n );\n return null;\n }\n }\n return inputMapPath;\n}\n\nexport default function readInputSourceMapFile(\n filename: string,\n root: string,\n inputMapURL: string,\n): SourceMapConverter | null {\n const inputMapPath = getInputMapPath(filename, root, inputMapURL);\n if (inputMapPath) {\n const inputMapContent = fs.readFileSync(inputMapPath, \"utf8\");\n return convertSourceMap.fromJSON(inputMapContent);\n }\n return null;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,KAAA,YAA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kB,YAAY,CAACT,YAAY,EAAE,MAAM,CAAC;IAC7D,OAAOU,kBAAeA,CAAC,CAACC,QAAQ,CAACH,eAAe,CAAC;EACnD;EACA,OAAO,IAAI;AACb;AAAC","ignoreList":[]}
export default function readInputSourceMapFile(): never {
throw new Error(
"Reading input source map files is not supported in browsers",
);
}
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;
}
+1
-1

@@ -214,3 +214,3 @@ "use strict";

var _parse = require("./parse.js");
const version = exports.version = "7.29.0";
const version = exports.version = "7.29.6";
const resolvePlugin = (name, dirname) => resolvers.resolvePlugin(name, dirname, false).filepath;

@@ -217,0 +217,0 @@ exports.resolvePlugin = resolvePlugin;

@@ -7,16 +7,2 @@ "use strict";

exports.default = normalizeFile;
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() {

@@ -43,2 +29,3 @@ const data = require("debug");

}
var _readInputSourceMapFile = require("./read-input-source-map-file.js");
var _file = require("./file/file.js");

@@ -87,5 +74,4 @@ var _index = require("../parser/index.js");

try {
const match = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment);
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]), "utf8");
inputMap = _convertSourceMap().fromJSON(inputMapContent);
const inputMapURL = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment)[1];
inputMap = (0, _readInputSourceMapFile.default)(options.filename, options.root, inputMapURL);
} catch (err) {

@@ -92,0 +78,0 @@ debug("discarding unknown file input sourcemap", err);

@@ -1,1 +0,1 @@

{"version":3,"names":["_fs","data","require","_path","_debug","_t","_convertSourceMap","_file","_index","_cloneDeep","file","traverseFast","debug","buildDebug","INLINE_SOURCEMAP_REGEX","EXTERNAL_SOURCEMAP_REGEX","normalizeFile","pluginPasses","options","code","ast","type","Error","cloneInputAst","cloneDeep","parser","inputMap","inputSourceMap","convertSourceMap","fromObject","lastComment","extractComments","fromComment","err","filename","match","exec","inputMapContent","fs","readFileSync","path","resolve","dirname","fromJSON","File","extractCommentsFromList","regex","comments","filter","value","test","node","leadingComments","innerComments","trailingComments"],"sources":["../../src/transformation/normalize-file.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport buildDebug from \"debug\";\nimport type { Handler } from \"gensync\";\nimport { file, traverseFast } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { PluginPasses } from \"../config/index.ts\";\nimport convertSourceMap from \"convert-source-map\";\nimport type { SourceMapConverter as Converter } from \"convert-source-map\";\nimport File from \"./file/file.ts\";\nimport parser from \"../parser/index.ts\";\nimport cloneDeep from \"./util/clone-deep.ts\";\nimport type { ResolvedOptions } from \"../config/validation/options.ts\";\n\nconst debug = buildDebug(\"babel:transform:file\");\n\n// These regexps are copied from the convert-source-map package,\n// but without // or /* at the beginning of the comment.\n\nconst INLINE_SOURCEMAP_REGEX =\n /^[@#]\\s+sourceMappingURL=data:(?:application|text)\\/json;(?:charset[:=]\\S+?;)?base64,.*$/;\nconst EXTERNAL_SOURCEMAP_REGEX =\n /^[@#][ \\t]+sourceMappingURL=([^\\s'\"`]+)[ \\t]*$/;\n\nexport type NormalizedFile = {\n code: string;\n ast: t.File;\n inputMap: Converter | null;\n};\n\nexport default function* normalizeFile(\n pluginPasses: PluginPasses,\n options: ResolvedOptions,\n code: string,\n ast?: t.File | t.Program | null,\n): Handler<File> {\n code = `${code || \"\"}`;\n\n if (ast) {\n if (ast.type === \"Program\") {\n ast = file(ast, [], []);\n } else if (ast.type !== \"File\") {\n throw new Error(\"AST root must be a Program or File node\");\n }\n\n if (options.cloneInputAst) {\n ast = cloneDeep(ast);\n }\n } else {\n ast = yield* parser(pluginPasses, options, code);\n }\n\n let inputMap = null;\n if (options.inputSourceMap !== false) {\n // If an explicit object is passed in, it overrides the processing of\n // source maps that may be in the file itself.\n if (typeof options.inputSourceMap === \"object\") {\n inputMap = convertSourceMap.fromObject(options.inputSourceMap);\n }\n\n if (!inputMap) {\n const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);\n if (lastComment) {\n try {\n inputMap = convertSourceMap.fromComment(\"//\" + lastComment);\n } catch (err) {\n if (process.env.BABEL_8_BREAKING) {\n console.warn(\n \"discarding unknown inline input sourcemap\",\n options.filename,\n err,\n );\n } else {\n debug(\"discarding unknown inline input sourcemap\");\n }\n }\n }\n }\n\n if (!inputMap) {\n const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);\n if (typeof options.filename === \"string\" && lastComment) {\n try {\n // when `lastComment` is non-null, EXTERNAL_SOURCEMAP_REGEX must have matches\n const match: [string, string] = EXTERNAL_SOURCEMAP_REGEX.exec(\n lastComment,\n ) as any;\n const inputMapContent = fs.readFileSync(\n path.resolve(path.dirname(options.filename), match[1]),\n \"utf8\",\n );\n inputMap = convertSourceMap.fromJSON(inputMapContent);\n } catch (err) {\n debug(\"discarding unknown file input sourcemap\", err);\n }\n } else if (lastComment) {\n debug(\"discarding un-loadable file input sourcemap\");\n }\n }\n }\n\n return new File(options, {\n code,\n ast: ast,\n inputMap,\n });\n}\n\nfunction extractCommentsFromList(\n regex: RegExp,\n comments: t.Comment[],\n lastComment: string | null,\n): [t.Comment[], string | null] {\n if (comments) {\n comments = comments.filter(({ value }) => {\n if (regex.test(value)) {\n lastComment = value;\n return false;\n }\n return true;\n });\n }\n return [comments, lastComment];\n}\n\nfunction extractComments(regex: RegExp, ast: t.Node) {\n let lastComment: string = null;\n traverseFast(ast, node => {\n [node.leadingComments, lastComment] = extractCommentsFromList(\n regex,\n node.leadingComments,\n lastComment,\n );\n [node.innerComments, lastComment] = extractCommentsFromList(\n regex,\n node.innerComments,\n lastComment,\n );\n [node.trailingComments, lastComment] = extractCommentsFromList(\n regex,\n node.trailingComments,\n lastComment,\n );\n });\n return lastComment;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,IAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,GAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,KAAA,YAAAA,C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MACF,CAAC,MAAM,IAAIH,WAAW,EAAE;QACtBlB,KAAK,CAAC,6CAA6C,CAAC;MACtD;IACF;EACF;EAEA,OAAO,IAAIgC,aAAI,CAAC1B,OAAO,EAAE;IACvBC,IAAI;IACJC,GAAG,EAAEA,GAAG;IACRM;EACF,CAAC,CAAC;AACJ;AAEA,SAASmB,uBAAuBA,CAC9BC,KAAa,EACbC,QAAqB,EACrBjB,WAA0B,EACI;EAC9B,IAAIiB,QAAQ,EAAE;IACZA,QAAQ,GAAGA,QAAQ,CAACC,MAAM,CAAC,CAAC;MAAEC;IAAM,CAAC,KAAK;MACxC,IAAIH,KAAK,CAACI,IAAI,CAACD,KAAK,CAAC,EAAE;QACrBnB,WAAW,GAAGmB,KAAK;QACnB,OAAO,KAAK;MACd;MACA,OAAO,IAAI;IACb,CAAC,CAAC;EACJ;EACA,OAAO,CAACF,QAAQ,EAAEjB,WAAW,CAAC;AAChC;AAEA,SAASC,eAAeA,CAACe,KAAa,EAAE1B,GAAW,EAAE;EACnD,IAAIU,WAAmB,GAAG,IAAI;EAC9BnB,YAAY,CAACS,GAAG,EAAE+B,IAAI,IAAI;IACxB,CAACA,IAAI,CAACC,eAAe,EAAEtB,WAAW,CAAC,GAAGe,uBAAuB,CAC3DC,KAAK,EACLK,IAAI,CAACC,eAAe,EACpBtB,WACF,CAAC;IACD,CAACqB,IAAI,CAACE,aAAa,EAAEvB,WAAW,CAAC,GAAGe,uBAAuB,CACzDC,KAAK,EACLK,IAAI,CAACE,aAAa,EAClBvB,WACF,CAAC;IACD,CAACqB,IAAI,CAACG,gBAAgB,EAAExB,WAAW,CAAC,GAAGe,uBAAuB,CAC5DC,KAAK,EACLK,IAAI,CAACG,gBAAgB,EACrBxB,WACF,CAAC;EACH,CAAC,CAAC;EACF,OAAOA,WAAW;AACpB;AAAC","ignoreList":[]}
{"version":3,"names":["_debug","data","require","_t","_convertSourceMap","_readInputSourceMapFile","_file","_index","_cloneDeep","file","traverseFast","debug","buildDebug","INLINE_SOURCEMAP_REGEX","EXTERNAL_SOURCEMAP_REGEX","normalizeFile","pluginPasses","options","code","ast","type","Error","cloneInputAst","cloneDeep","parser","inputMap","inputSourceMap","convertSourceMap","fromObject","lastComment","extractComments","fromComment","err","filename","inputMapURL","exec","readInputSourceMapFile","root","File","extractCommentsFromList","regex","comments","filter","value","test","node","leadingComments","innerComments","trailingComments"],"sources":["../../src/transformation/normalize-file.ts"],"sourcesContent":["import buildDebug from \"debug\";\nimport type { Handler } from \"gensync\";\nimport { file, traverseFast } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\nimport type { PluginPasses } from \"../config/index.ts\";\nimport convertSourceMap from \"convert-source-map\";\nimport type { SourceMapConverter as Converter } from \"convert-source-map\";\nimport readInputSourceMapFile from \"./read-input-source-map-file.ts\";\nimport File from \"./file/file.ts\";\nimport parser from \"../parser/index.ts\";\nimport cloneDeep from \"./util/clone-deep.ts\";\nimport type { ResolvedOptions } from \"../config/validation/options.ts\";\n\nconst debug = buildDebug(\"babel:transform:file\");\n\n// These regexps are copied from the convert-source-map package,\n// but without // or /* at the beginning of the comment.\n\nconst INLINE_SOURCEMAP_REGEX =\n /^[@#]\\s+sourceMappingURL=data:(?:application|text)\\/json;(?:charset[:=]\\S+?;)?base64,.*$/;\nconst EXTERNAL_SOURCEMAP_REGEX =\n /^[@#][ \\t]+sourceMappingURL=([^\\s'\"`]+)[ \\t]*$/;\n\nexport type NormalizedFile = {\n code: string;\n ast: t.File;\n inputMap: Converter | null;\n};\n\nexport default function* normalizeFile(\n pluginPasses: PluginPasses,\n options: ResolvedOptions,\n code: string,\n ast?: t.File | t.Program | null,\n): Handler<File> {\n code = `${code || \"\"}`;\n\n if (ast) {\n if (ast.type === \"Program\") {\n ast = file(ast, [], []);\n } else if (ast.type !== \"File\") {\n throw new Error(\"AST root must be a Program or File node\");\n }\n\n if (options.cloneInputAst) {\n ast = cloneDeep(ast);\n }\n } else {\n ast = yield* parser(pluginPasses, options, code);\n }\n\n let inputMap = null;\n if (options.inputSourceMap !== false) {\n // If an explicit object is passed in, it overrides the processing of\n // source maps that may be in the file itself.\n if (typeof options.inputSourceMap === \"object\") {\n inputMap = convertSourceMap.fromObject(options.inputSourceMap);\n }\n\n if (!inputMap) {\n const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);\n if (lastComment) {\n try {\n inputMap = convertSourceMap.fromComment(\"//\" + lastComment);\n } catch (err) {\n if (process.env.BABEL_8_BREAKING) {\n console.warn(\n \"discarding unknown inline input sourcemap\",\n options.filename,\n err,\n );\n } else {\n debug(\"discarding unknown inline input sourcemap\");\n }\n }\n }\n }\n\n if (!inputMap) {\n const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);\n if (typeof options.filename === \"string\" && lastComment) {\n try {\n // when `lastComment` is non-null, EXTERNAL_SOURCEMAP_REGEX must have matches\n const inputMapURL: string =\n EXTERNAL_SOURCEMAP_REGEX.exec(lastComment)[1];\n inputMap = readInputSourceMapFile(\n options.filename,\n options.root,\n inputMapURL,\n );\n } catch (err) {\n debug(\"discarding unknown file input sourcemap\", err);\n }\n } else if (lastComment) {\n debug(\"discarding un-loadable file input sourcemap\");\n }\n }\n }\n\n return new File(options, {\n code,\n ast: ast,\n inputMap,\n });\n}\n\nfunction extractCommentsFromList(\n regex: RegExp,\n comments: t.Comment[],\n lastComment: string | null,\n): [t.Comment[], string | null] {\n if (comments) {\n comments = comments.filter(({ value }) => {\n if (regex.test(value)) {\n lastComment = value;\n return false;\n }\n return true;\n });\n }\n return [comments, lastComment];\n}\n\nfunction extractComments(regex: RegExp, ast: t.Node) {\n let lastComment: string = null;\n traverseFast(ast, node => {\n [node.leadingComments, lastComment] = extractCommentsFromList(\n regex,\n node.leadingComments,\n lastComment,\n );\n [node.innerComments, lastComment] = extractCommentsFromList(\n regex,\n node.innerComments,\n lastComment,\n );\n [node.trailingComments, lastComment] = extractCommentsFromList(\n regex,\n node.trailingComments,\n lastComment,\n );\n });\n return lastComment;\n}\n"],"mappings":";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AAEA,GAAG;IACRM;EACF,CAAC,CAAC;AACJ;AAEA,SAASc,uBAAuBA,CAC9BC,KAAa,EACbC,QAAqB,EACrBZ,WAA0B,EACI;EAC9B,IAAIY,QAAQ,EAAE;IACZA,QAAQ,GAAGA,QAAQ,CAACC,MAAM,CAAC,CAAC;MAAEC;IAAM,CAAC,KAAK;MACxC,IAAIH,KAAK,CAACI,IAAI,CAACD,KAAK,CAAC,EAAE;QACrBd,WAAW,GAAGc,KAAK;QACnB,OAAO,KAAK;MACd;MACA,OAAO,IAAI;IACb,CAAC,CAAC;EACJ;EACA,OAAO,CAACF,QAAQ,EAAEZ,WAAW,CAAC;AAChC;AAEA,SAASC,eAAeA,CAACU,KAAa,EAAErB,GAAW,EAAE;EACnD,IAAIU,WAAmB,GAAG,IAAI;EAC9BnB,YAAY,CAACS,GAAG,EAAE0B,IAAI,IAAI;IACxB,CAACA,IAAI,CAACC,eAAe,EAAEjB,WAAW,CAAC,GAAGU,uBAAuB,CAC3DC,KAAK,EACLK,IAAI,CAACC,eAAe,EACpBjB,WACF,CAAC;IACD,CAACgB,IAAI,CAACE,aAAa,EAAElB,WAAW,CAAC,GAAGU,uBAAuB,CACzDC,KAAK,EACLK,IAAI,CAACE,aAAa,EAClBlB,WACF,CAAC;IACD,CAACgB,IAAI,CAACG,gBAAgB,EAAEnB,WAAW,CAAC,GAAGU,uBAAuB,CAC5DC,KAAK,EACLK,IAAI,CAACG,gBAAgB,EACrBnB,WACF,CAAC;EACH,CAAC,CAAC;EACF,OAAOA,WAAW;AACpB;AAAC","ignoreList":[]}
{
"name": "@babel/core",
"version": "7.29.0",
"version": "7.29.6",
"description": "Babel compiler core.",

@@ -44,13 +44,15 @@ "main": "./lib/index.js",

"./lib/transform-file.js": "./lib/transform-file-browser.js",
"./lib/transformation/read-input-source-map-file.js": "./lib/transformation/read-input-source-map-file-browser.js",
"./src/config/files/index.ts": "./src/config/files/index-browser.ts",
"./src/config/resolve-targets.ts": "./src/config/resolve-targets-browser.ts",
"./src/transform-file.ts": "./src/transform-file-browser.ts"
"./src/transform-file.ts": "./src/transform-file-browser.ts",
"./src/transformation/read-input-source-map-file.ts": "./src/transformation/read-input-source-map-file-browser.ts"
},
"dependencies": {
"@babel/code-frame": "^7.29.0",
"@babel/generator": "^7.29.0",
"@babel/generator": "^7.29.6",
"@babel/helper-compilation-targets": "^7.28.6",
"@babel/helper-module-transforms": "^7.28.6",
"@babel/helpers": "^7.28.6",
"@babel/parser": "^7.29.0",
"@babel/helpers": "^7.29.2",
"@babel/parser": "^7.29.3",
"@babel/template": "^7.28.6",

@@ -71,3 +73,3 @@ "@babel/traverse": "^7.29.0",

"@babel/plugin-transform-modules-commonjs": "^7.28.6",
"@babel/preset-env": "^7.29.0",
"@babel/preset-env": "^7.29.5",
"@babel/preset-typescript": "^7.28.5",

@@ -74,0 +76,0 @@ "@jridgewell/trace-mapping": "^0.3.28",