Socket
Book a DemoInstallSign in
Socket

@babel/core

Package Overview
Dependencies
Maintainers
4
Versions
211
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

to
7.22.1

cjs-proxy.cjs

4

lib/config/cache-contexts.js

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

0 && 0;
0 && 0;
//# sourceMappingURL=cache-contexts.js.map

@@ -11,41 +11,29 @@ "use strict";

exports.makeWeakCacheSync = makeWeakCacheSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../gensync-utils/async");
var _util = require("./util");
const synchronize = gen => {
return _gensync()(gen).sync;
};
function* genTrue() {
return true;
}
function makeWeakCache(handler) {
return makeCachedFunction(WeakMap, handler);
}
function makeWeakCacheSync(handler) {
return synchronize(makeWeakCache(handler));
}
function makeStrongCache(handler) {
return makeCachedFunction(Map, handler);
}
function makeStrongCacheSync(handler) {
return synchronize(makeStrongCache(handler));
}
function makeCachedFunction(CallCache, handler) {

@@ -64,6 +52,4 @@ const callCacheSync = new CallCache();

let value;
if ((0, _util.isIterableIterator)(handlerResult)) {
const gen = handlerResult;
value = yield* (0, _async.onFirstPause)(gen, () => {
value = yield* (0, _async.onFirstPause)(handlerResult, () => {
finishLock = setupAsyncLocks(cache, futureCache, arg);

@@ -74,5 +60,3 @@ });

}
updateFunctionCache(callCache, cache, arg, value);
if (finishLock) {

@@ -82,10 +66,7 @@ futureCache.delete(arg);

}
return value;
};
}
function* getCachedValue(cache, arg, data) {
const cachedValue = cache.get(arg);
if (cachedValue) {

@@ -102,3 +83,2 @@ for (const {

}
return {

@@ -109,13 +89,9 @@ valid: false,

}
function* getCachedValueOrWait(asyncContext, callCache, futureCache, arg, data) {
const cached = yield* getCachedValue(callCache, arg, data);
if (cached.valid) {
return cached;
}
if (asyncContext) {
const cached = yield* getCachedValue(futureCache, arg, data);
if (cached.valid) {

@@ -129,3 +105,2 @@ const value = yield* (0, _async.waitFor)(cached.value.promise);

}
return {

@@ -136,3 +111,2 @@ valid: false,

}
function setupAsyncLocks(config, futureCache, arg) {

@@ -143,3 +117,2 @@ const finishLock = new Lock();

}
function updateFunctionCache(cache, config, arg, value) {

@@ -149,3 +122,2 @@ if (!config.configured()) config.forever();

config.deactivate();
switch (config.mode()) {

@@ -159,3 +131,2 @@ case "forever":

break;
case "invalidate":

@@ -168,3 +139,2 @@ cachedValue = [{

break;
case "valid":

@@ -183,6 +153,4 @@ if (cachedValue) {

}
}
}
class CacheConfigurator {

@@ -199,7 +167,5 @@ constructor(data) {

}
simple() {
return makeSimpleConfigurator(this);
}
mode() {

@@ -211,3 +177,2 @@ if (this._never) return "never";

}
forever() {

@@ -217,11 +182,8 @@ if (!this._active) {

}
if (this._never) {
throw new Error("Caching has already been configured with .never()");
}
this._forever = true;
this._configured = true;
}
never() {

@@ -231,11 +193,8 @@ if (!this._active) {

}
if (this._forever) {
throw new Error("Caching has already been configured with .forever()");
}
this._never = true;
this._configured = true;
}
using(handler) {

@@ -245,24 +204,17 @@ if (!this._active) {

}
if (this._never || this._forever) {
throw new Error("Caching has already been configured with .never or .forever()");
}
this._configured = true;
const key = handler(this._data);
const fn = (0, _async.maybeAsync)(handler, `You appear to be using an async cache handler, but Babel has been called synchronously`);
if ((0, _async.isThenable)(key)) {
return key.then(key => {
this._pairs.push([key, fn]);
return key;
});
}
this._pairs.push([key, fn]);
return key;
}
invalidate(handler) {

@@ -272,3 +224,2 @@ this._invalidate = true;

}
validator() {

@@ -280,17 +231,12 @@ const pairs = this._pairs;

}
return true;
};
}
deactivate() {
this._active = false;
}
configured() {
return this._configured;
}
}
function makeSimpleConfigurator(cache) {

@@ -302,17 +248,10 @@ function cacheFn(val) {

}
return cache.using(() => assertSimpleType(val()));
}
cacheFn.forever = () => cache.forever();
cacheFn.never = () => cache.never();
cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
return cacheFn;
}
function assertSimpleType(value) {

@@ -322,10 +261,7 @@ if ((0, _async.isThenable)(value)) {

}
if (value != null && typeof value !== "string" && typeof value !== "boolean" && typeof value !== "number") {
throw new Error("Cache keys must be either string, boolean, number, null, or undefined.");
}
return value;
}
class Lock {

@@ -340,11 +276,9 @@ constructor() {

}
release(value) {
this.released = true;
this._resolve(value);
}
}
0 && 0;
0 && 0;
//# sourceMappingURL=caching.js.map

@@ -9,37 +9,25 @@ "use strict";

exports.buildRootChain = buildRootChain;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
var _options = require("./validation/options");
var _patternToRegex = require("./pattern-to-regex");
var _printer = require("./printer");
var _rewriteStackTrace = require("../errors/rewrite-stack-trace");
var _configError = require("../errors/config-error");
var _files = require("./files");
var _caching = require("./caching");
var _configDescriptors = require("./config-descriptors");
const debug = _debug()("babel:config:config-chain");
function* buildPresetChain(arg, context) {

@@ -55,3 +43,2 @@ const chain = yield* buildPresetChainWalker(arg, context);

}
const buildPresetChainWalker = makeChainWalker({

@@ -69,3 +56,2 @@ root: preset => loadPresetDescriptors(preset),

const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(preset => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
function* buildRootChain(opts, context) {

@@ -81,3 +67,2 @@ let configReport, babelRcReport;

let configFile;
if (typeof opts.configFile === "string") {

@@ -88,3 +73,2 @@ configFile = yield* (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);

}
let {

@@ -97,3 +81,2 @@ babelrc,

const configFileLogger = new _printer.ConfigPrinter();
if (configFile) {

@@ -104,7 +87,5 @@ const validatedFile = validateConfigFile(configFile);

configReport = yield* configFileLogger.output();
if (babelrc === undefined) {
babelrc = validatedFile.options.babelrc;
}
if (babelrcRoots === undefined) {

@@ -114,13 +95,9 @@ babelrcRootsDirectory = validatedFile.dirname;

}
mergeChain(configFileChain, result);
}
let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
const pkgData = yield* (0, _files.findPackageData)(context.filename);
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {

@@ -131,11 +108,8 @@ ({

} = yield* (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller));
if (ignoreFile) {
fileChain.files.add(ignoreFile.filepath);
}
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
isIgnored = true;
}
if (babelrcFile && !isIgnored) {

@@ -145,3 +119,2 @@ const validatedFile = validateBabelrcFile(babelrcFile);

const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
if (!result) {

@@ -154,3 +127,2 @@ isIgnored = true;

}
if (babelrcFile && isIgnored) {

@@ -161,7 +133,5 @@ fileChain.files.add(babelrcFile.filepath);

}
if (context.showConfig) {
console.log(`Babel configs on "${context.filename}" (ascending priority):\n` + [configReport, babelRcReport, programmaticReport].filter(x => !!x).join("\n\n") + "\n-----End Babel configs-----");
}
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);

@@ -179,25 +149,18 @@ return {

}
function babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory) {
if (typeof babelrcRoots === "boolean") return babelrcRoots;
const absoluteRoot = context.root;
if (babelrcRoots === undefined) {
return pkgData.directories.indexOf(absoluteRoot) !== -1;
}
let babelrcPatterns = babelrcRoots;
if (!Array.isArray(babelrcPatterns)) {
babelrcPatterns = [babelrcPatterns];
}
babelrcPatterns = babelrcPatterns.map(pat => {
return typeof pat === "string" ? _path().resolve(babelrcRootsDirectory, pat) : pat;
});
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
return pkgData.directories.indexOf(absoluteRoot) !== -1;
}
return babelrcPatterns.some(pat => {

@@ -207,3 +170,2 @@ if (typeof pat === "string") {

}
return pkgData.directories.some(directory => {

@@ -214,7 +176,6 @@ return matchPattern(pat, babelrcRootsDirectory, directory, context);

}
const validateConfigFile = (0, _caching.makeWeakCacheSync)(file => ({
filepath: file.filepath,
dirname: file.dirname,
options: (0, _options.validate)("configfile", file.options)
options: (0, _options.validate)("configfile", file.options, file.filepath)
}));

@@ -224,3 +185,3 @@ const validateBabelrcFile = (0, _caching.makeWeakCacheSync)(file => ({

dirname: file.dirname,
options: (0, _options.validate)("babelrcfile", file.options)
options: (0, _options.validate)("babelrcfile", file.options, file.filepath)
}));

@@ -230,3 +191,3 @@ const validateExtendFile = (0, _caching.makeWeakCacheSync)(file => ({

dirname: file.dirname,
options: (0, _options.validate)("extendsfile", file.options)
options: (0, _options.validate)("extendsfile", file.options, file.filepath)
}));

@@ -247,13 +208,9 @@ const loadProgrammaticChain = makeChainWalker({

});
function* loadFileChain(input, context, files, baseLogger) {
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
if (chain) {
chain.files.add(input.filepath);
}
return chain;
}
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));

@@ -263,3 +220,2 @@ const loadFileEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));

const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCacheSync)(file => (0, _caching.makeStrongCacheSync)(index => (0, _caching.makeStrongCacheSync)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
function buildFileLogger(filepath, context, baseLogger) {

@@ -269,3 +225,2 @@ if (!baseLogger) {

}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {

@@ -275,3 +230,2 @@ filepath

}
function buildRootDescriptors({

@@ -283,10 +237,7 @@ dirname,

}
function buildProgrammaticLogger(_, context, baseLogger) {
var _context$caller;
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {

@@ -296,3 +247,2 @@ callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name

}
function buildEnvDescriptors({

@@ -305,3 +255,2 @@ dirname,

}
function buildOverrideDescriptors({

@@ -315,3 +264,2 @@ dirname,

}
function buildOverrideEnvDescriptors({

@@ -326,3 +274,2 @@ dirname,

}
function makeChainWalker({

@@ -335,3 +282,3 @@ root,

}) {
return function* (input, context, files = new Set(), baseLogger) {
return function* chainWalker(input, context, files = new Set(), baseLogger) {
const {

@@ -342,4 +289,3 @@ dirname

const rootOpts = root(input);
if (configIsApplicable(rootOpts, dirname, context)) {
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({

@@ -351,4 +297,3 @@ config: rootOpts,

const envOpts = env(input, context.envName);
if (envOpts && configIsApplicable(envOpts, dirname, context)) {
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({

@@ -360,7 +305,5 @@ config: envOpts,

}
(rootOpts.options.overrides || []).forEach((_, index) => {
const overrideOps = overrides(input, index);
if (configIsApplicable(overrideOps, dirname, context)) {
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
flattenedConfigs.push({

@@ -372,4 +315,3 @@ config: overrideOps,

const overrideEnvOpts = overridesEnv(input, index, context.envName);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context)) {
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({

@@ -384,3 +326,2 @@ config: overrideEnvOpts,

}
if (flattenedConfigs.some(({

@@ -396,6 +337,4 @@ config: {

}
const chain = emptyChain();
const logger = createLogger(input, context, baseLogger);
for (const {

@@ -409,19 +348,14 @@ config,

}
logger(config, index, envName);
yield* mergeChainOpts(chain, config);
}
return chain;
};
}
function* mergeExtendsChain(chain, opts, dirname, context, files, baseLogger) {
if (opts.extends === undefined) return true;
const file = yield* (0, _files.loadConfig)(opts.extends, dirname, context.envName, context.caller);
if (files.has(file)) {
throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n"));
}
files.add(file);

@@ -434,3 +368,2 @@ const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);

}
function mergeChain(target, source) {

@@ -440,10 +373,7 @@ target.options.push(...source.options);

target.presets.push(...source.presets);
for (const file of source.files) {
target.files.add(file);
}
return target;
}
function* mergeChainOpts(target, {

@@ -459,3 +389,2 @@ options,

}
function emptyChain() {

@@ -469,3 +398,2 @@ return {

}
function normalizeOptions(opts) {

@@ -484,3 +412,2 @@ const options = Object.assign({}, opts);

delete options.exclude;
if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {

@@ -490,10 +417,7 @@ options.sourceMaps = options.sourceMap;

}
return options;
}
function dedupDescriptors(items) {
const map = new Map();
const descriptors = [];
for (const item of items) {

@@ -503,3 +427,2 @@ if (typeof item.value === "function") {

let nameMap = map.get(fnKey);
if (!nameMap) {

@@ -509,5 +432,3 @@ nameMap = new Map();

}
let desc = nameMap.get(item.name);
if (!desc) {

@@ -528,3 +449,2 @@ desc = {

}
return descriptors.reduce((acc, desc) => {

@@ -535,14 +455,11 @@ acc.push(desc.value);

}
function configIsApplicable({
options
}, dirname, context) {
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname));
}, dirname, context, configName) {
return (options.test === undefined || configFieldIsApplicable(context, options.test, dirname, configName)) && (options.include === undefined || configFieldIsApplicable(context, options.include, dirname, configName)) && (options.exclude === undefined || !configFieldIsApplicable(context, options.exclude, dirname, configName));
}
function configFieldIsApplicable(context, test, dirname) {
function configFieldIsApplicable(context, test, dirname, configName) {
const patterns = Array.isArray(test) ? test : [test];
return matchesPatterns(context, patterns, dirname);
return matchesPatterns(context, patterns, dirname, configName);
}
function ignoreListReplacer(_key, value) {

@@ -552,43 +469,31 @@ if (value instanceof RegExp) {

}
return value;
}
function shouldIgnore(context, ignore, only, dirname) {
if (ignore && matchesPatterns(context, ignore, dirname)) {
var _context$filename;
const message = `No config is applied to "${(_context$filename = context.filename) != null ? _context$filename : "(unknown)"}" because it matches one of \`ignore: ${JSON.stringify(ignore, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
if (only && !matchesPatterns(context, only, dirname)) {
var _context$filename2;
const message = `No config is applied to "${(_context$filename2 = context.filename) != null ? _context$filename2 : "(unknown)"}" because it fails to match one of \`only: ${JSON.stringify(only, ignoreListReplacer)}\` from "${dirname}"`;
debug(message);
if (context.showConfig) {
console.log(message);
}
return true;
}
return false;
}
function matchesPatterns(context, patterns, dirname) {
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context));
function matchesPatterns(context, patterns, dirname, configName) {
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context, configName));
}
function matchPattern(pattern, dirname, pathToTest, context) {
function matchPattern(pattern, dirname, pathToTest, context, configName) {
if (typeof pattern === "function") {
return !!pattern(pathToTest, {
return !!(0, _rewriteStackTrace.endHiddenCallStack)(pattern)(pathToTest, {
dirname,

@@ -599,14 +504,12 @@ envName: context.envName,

}
if (typeof pathToTest !== "string") {
throw new Error(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`);
throw new _configError.default(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`, configName);
}
if (typeof pattern === "string") {
pattern = (0, _patternToRegex.default)(pattern, dirname);
}
return pattern.test(pathToTest);
}
0 && 0;
0 && 0;
//# sourceMappingURL=config-chain.js.map

@@ -9,29 +9,20 @@ "use strict";

exports.createUncachedDescriptors = createUncachedDescriptors;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _functional = require("../gensync-utils/functional");
var _files = require("./files");
var _item = require("./item");
var _caching = require("./caching");
var _resolveTargets = require("./resolve-targets");
function isEqualDescriptor(a, b) {
return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && (a.file && a.file.request) === (b.file && b.file.request) && (a.file && a.file.resolved) === (b.file && b.file.resolved);
}
function* handlerOf(value) {
return value;
}
function optionsWithResolvedBrowserslistConfigFile(options, dirname) {

@@ -41,6 +32,4 @@ if (typeof options.browserslistConfigFile === "string") {

}
return options;
}
function createCachedDescriptors(dirname, options, alias) {

@@ -58,28 +47,9 @@ const {

}
function createUncachedDescriptors(dirname, options, alias) {
let plugins;
let presets;
return {
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
*plugins() {
if (!plugins) {
plugins = yield* createPluginDescriptors(options.plugins || [], dirname, alias);
}
return plugins;
},
*presets() {
if (!presets) {
presets = yield* createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset);
}
return presets;
}
plugins: (0, _functional.once)(() => createPluginDescriptors(options.plugins || [], dirname, alias)),
presets: (0, _functional.once)(() => createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset))
};
}
const PRESET_DESCRIPTOR_CACHE = new WeakMap();

@@ -102,3 +72,2 @@ const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {

const DEFAULT_OPTIONS = {};
function loadCachedDescriptor(cache, desc) {

@@ -111,3 +80,2 @@ const {

let cacheByOptions = cache.get(value);
if (!cacheByOptions) {

@@ -117,5 +85,3 @@ cacheByOptions = new WeakMap();

}
let possibilities = cacheByOptions.get(options);
if (!possibilities) {

@@ -125,24 +91,17 @@ possibilities = [];

}
if (possibilities.indexOf(desc) === -1) {
const matches = possibilities.filter(possibility => isEqualDescriptor(possibility, desc));
if (matches.length > 0) {
return matches[0];
}
possibilities.push(desc);
}
return desc;
}
function* createPresetDescriptors(items, dirname, alias, passPerPreset) {
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset);
}
function* createPluginDescriptors(items, dirname, alias) {
return yield* createDescriptors("plugin", items, dirname, alias);
}
function* createDescriptors(type, items, dirname, alias, ownPass) {

@@ -157,3 +116,2 @@ const descriptors = yield* _gensync().all(items.map((item, index) => createDescriptor(item, dirname, {

}
function* createDescriptor(pair, dirname, {

@@ -165,11 +123,8 @@ type,

const desc = (0, _item.getItemDescriptor)(pair);
if (desc) {
return desc;
}
let name;
let options;
let value = pair;
if (Array.isArray(value)) {

@@ -182,6 +137,4 @@ if (value.length === 3) {

}
let file = undefined;
let filepath = null;
if (typeof value === "string") {

@@ -191,3 +144,2 @@ if (typeof type !== "string") {

}
const resolver = type === "plugin" ? _files.loadPlugin : _files.loadPreset;

@@ -204,7 +156,5 @@ const request = value;

}
if (!value) {
throw new Error(`Unexpected falsy value: ${String(value)}`);
}
if (typeof value === "object" && value.__esModule) {

@@ -217,11 +167,8 @@ if (value.default) {

}
if (typeof value !== "object" && typeof value !== "function") {
throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`);
}
if (filepath !== null && typeof value === "object" && value) {
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
}
return {

@@ -237,10 +184,7 @@ name,

}
function assertNoDuplicates(items) {
const map = new Map();
for (const item of items) {
if (typeof item.value !== "function") continue;
let nameMap = map.get(item.value);
if (!nameMap) {

@@ -250,3 +194,2 @@ nameMap = new Set();

}
if (nameMap.has(item.name)) {

@@ -256,7 +199,7 @@ const conflicts = items.filter(i => i.value === item.value);

}
nameMap.add(item.name);
}
}
0 && 0;
0 && 0;
//# sourceMappingURL=config-descriptors.js.map

@@ -12,186 +12,52 @@ "use strict";

exports.resolveShowConfigPath = resolveShowConfigPath;
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
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 _json() {
const data = require("json5");
_json = function () {
return data;
};
return data;
}
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _caching = require("../caching");
var _configApi = require("../helpers/config-api");
var _utils = require("./utils");
var _moduleTypes = require("./module-types");
var _patternToRegex = require("../pattern-to-regex");
var _configError = require("../../errors/config-error");
var fs = require("../../gensync-utils/fs");
function _module() {
const data = require("module");
_module = function () {
return data;
};
return data;
}
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace");
const debug = _debug()("babel:config:loading:files:configuration");
const ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json"];
const ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json", "babel.config.cts"];
exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES;
const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs", ".babelrc.mjs", ".babelrc.json"];
const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs", ".babelrc.mjs", ".babelrc.json", ".babelrc.cts"];
const BABELIGNORE_FILENAME = ".babelignore";
function findConfigUpwards(rootDir) {
let dirname = rootDir;
for (;;) {
for (const filename of ROOT_CONFIG_FILENAMES) {
if (_fs().existsSync(_path().join(dirname, filename))) {
return dirname;
}
}
const nextDir = _path().dirname(dirname);
if (dirname === nextDir) break;
dirname = nextDir;
}
return null;
}
function* findRelativeConfig(packageData, envName, caller) {
let config = null;
let ignore = null;
const dirname = _path().dirname(packageData.filepath);
for (const loc of packageData.directories) {
if (!config) {
var _packageData$pkg;
config = yield* loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, ((_packageData$pkg = packageData.pkg) == null ? void 0 : _packageData$pkg.dirname) === loc ? packageToBabelConfig(packageData.pkg) : null);
}
if (!ignore) {
const ignoreLoc = _path().join(loc, BABELIGNORE_FILENAME);
ignore = yield* readIgnoreConfig(ignoreLoc);
if (ignore) {
debug("Found ignore %o from %o.", ignore.filepath, dirname);
}
}
}
return {
config,
ignore
};
}
function findRootConfig(dirname, envName, caller) {
return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
}
function* loadOneConfig(names, dirname, envName, caller, previousConfig = null) {
const configs = yield* _gensync().all(names.map(filename => readConfig(_path().join(dirname, filename), envName, caller)));
const config = configs.reduce((previousConfig, config) => {
if (config && previousConfig) {
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().basename(previousConfig.filepath)}\n` + ` - ${config.filepath}\n` + `from ${dirname}`);
}
return config || previousConfig;
}, previousConfig);
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
return config;
}
function* loadConfig(name, dirname, envName, caller) {
const filepath = (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})(name, {
paths: [dirname]
});
const conf = yield* readConfig(filepath, envName, caller);
if (!conf) {
throw new Error(`Config file ${filepath} contains no configuration data`);
}
debug("Loaded config %o from %o.", name, dirname);
return conf;
}
function readConfig(filepath, envName, caller) {
const ext = _path().extname(filepath);
return ext === ".js" || ext === ".cjs" || ext === ".mjs" ? readConfigJS(filepath, {
envName,
caller
}) : readConfigJSON5(filepath);
}
const LOADING_CONFIGS = new Set();
const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepath, cache) {
const readConfigCode = (0, _caching.makeStrongCache)(function* readConfigCode(filepath, cache) {
if (!_fs().existsSync(filepath)) {

@@ -201,3 +67,2 @@ cache.never();

}
if (LOADING_CONFIGS.has(filepath)) {

@@ -212,32 +77,22 @@ cache.never();

}
let options;
try {
LOADING_CONFIGS.add(filepath);
options = yield* (0, _moduleTypes.default)(filepath, "You appear to be using a native ECMAScript module configuration " + "file, which is only supported when running Babel asynchronously.");
} catch (err) {
err.message = `${filepath}: Error while loading config - ${err.message}`;
throw err;
} finally {
LOADING_CONFIGS.delete(filepath);
}
let assertCache = false;
if (typeof options === "function") {
yield* [];
options = options((0, _configApi.makeConfigAPI)(cache));
options = (0, _rewriteStackTrace.endHiddenCallStack)(options)((0, _configApi.makeConfigAPI)(cache));
assertCache = true;
}
if (!options || typeof options !== "object" || Array.isArray(options)) {
throw new Error(`${filepath}: Configuration should be an exported JavaScript object.`);
throw new _configError.default(`Configuration should be an exported JavaScript object.`, filepath);
}
if (typeof options.then === "function") {
throw new Error(`You appear to be using an async configuration, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously return your config.`);
throw new _configError.default(`You appear to be using an async configuration, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously return your config.`, filepath);
}
if (assertCache && !cache.configured()) throwConfigError();
if (assertCache && !cache.configured()) throwConfigError(filepath);
return {

@@ -252,7 +107,5 @@ filepath,

if (typeof babel === "undefined") return null;
if (typeof babel !== "object" || Array.isArray(babel) || babel === null) {
throw new Error(`${file.filepath}: .babel property must be an object`);
throw new _configError.default(`.babel property must be an object`, file.filepath);
}
return {

@@ -266,20 +119,14 @@ filepath: file.filepath,

let options;
try {
options = _json().parse(content);
} catch (err) {
err.message = `${filepath}: Error while parsing config - ${err.message}`;
throw err;
throw new _configError.default(`Error while parsing config - ${err.message}`, filepath);
}
if (!options) throw new Error(`${filepath}: No config detected`);
if (!options) throw new _configError.default(`No config detected`, filepath);
if (typeof options !== "object") {
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
}
if (Array.isArray(options)) {
throw new Error(`${filepath}: Expected config object but found array`);
throw new _configError.default(`Expected config object but found array`, filepath);
}
delete options["$schema"];

@@ -294,11 +141,8 @@ return {

const ignoreDir = _path().dirname(filepath);
const ignorePatterns = content.split("\n").map(line => line.replace(/#(.*?)$/, "").trim()).filter(line => !!line);
for (const pattern of ignorePatterns) {
if (pattern[0] === "!") {
throw new Error(`Negation of file paths is not supported.`);
throw new _configError.default(`Negation of file paths is not supported.`, filepath);
}
}
return {

@@ -310,23 +154,102 @@ filepath,

});
function findConfigUpwards(rootDir) {
let dirname = rootDir;
for (;;) {
for (const filename of ROOT_CONFIG_FILENAMES) {
if (_fs().existsSync(_path().join(dirname, filename))) {
return dirname;
}
}
const nextDir = _path().dirname(dirname);
if (dirname === nextDir) break;
dirname = nextDir;
}
return null;
}
function* findRelativeConfig(packageData, envName, caller) {
let config = null;
let ignore = null;
const dirname = _path().dirname(packageData.filepath);
for (const loc of packageData.directories) {
if (!config) {
var _packageData$pkg;
config = yield* loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, ((_packageData$pkg = packageData.pkg) == null ? void 0 : _packageData$pkg.dirname) === loc ? packageToBabelConfig(packageData.pkg) : null);
}
if (!ignore) {
const ignoreLoc = _path().join(loc, BABELIGNORE_FILENAME);
ignore = yield* readIgnoreConfig(ignoreLoc);
if (ignore) {
debug("Found ignore %o from %o.", ignore.filepath, dirname);
}
}
}
return {
config,
ignore
};
}
function findRootConfig(dirname, envName, caller) {
return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
}
function* loadOneConfig(names, dirname, envName, caller, previousConfig = null) {
const configs = yield* _gensync().all(names.map(filename => readConfig(_path().join(dirname, filename), envName, caller)));
const config = configs.reduce((previousConfig, config) => {
if (config && previousConfig) {
throw new _configError.default(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().basename(previousConfig.filepath)}\n` + ` - ${config.filepath}\n` + `from ${dirname}`);
}
return config || previousConfig;
}, previousConfig);
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
return config;
}
function* loadConfig(name, dirname, envName, caller) {
const filepath = (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})(name, {
paths: [dirname]
});
const conf = yield* readConfig(filepath, envName, caller);
if (!conf) {
throw new _configError.default(`Config file contains no configuration data`, filepath);
}
debug("Loaded config %o from %o.", name, dirname);
return conf;
}
function readConfig(filepath, envName, caller) {
const ext = _path().extname(filepath);
switch (ext) {
case ".js":
case ".cjs":
case ".mjs":
case ".cts":
return readConfigCode(filepath, {
envName,
caller
});
default:
return readConfigJSON5(filepath);
}
}
function* resolveShowConfigPath(dirname) {
const targetPath = process.env.BABEL_SHOW_CONFIG_FOR;
if (targetPath != null) {
const absolutePath = _path().resolve(dirname, targetPath);
const stats = yield* fs.stat(absolutePath);
if (!stats.isFile()) {
throw new Error(`${absolutePath}: BABEL_SHOW_CONFIG_FOR must refer to a regular file, directories are not supported.`);
}
return absolutePath;
}
return null;
}
function throwConfigError() {
throw new Error(`\
function throwConfigError(filepath) {
throw new _configError.default(`\
Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured

@@ -364,5 +287,6 @@ for various types of caching, using the first param of their handler functions:

return { };
};`);
};`, filepath);
}
0 && 0;
0 && 0;
//# sourceMappingURL=configuration.js.map

@@ -7,38 +7,12 @@ "use strict";

exports.default = resolve;
function _module() {
const data = require("module");
_module = function () {
return data;
};
return data;
}
var _importMetaResolve = require("../../vendor/import-meta-resolve");
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
let import_;
try {
import_ = require("./import").default;
} catch (_unused) {}
const importMetaResolveP = import_ && process.execArgv.includes("--experimental-import-meta-resolve") ? import_("data:text/javascript,export default import.meta.resolve").then(m => m.default || _importMetaResolve.resolve, () => _importMetaResolve.resolve) : Promise.resolve(_importMetaResolve.resolve);
function resolve(_x, _x2) {
return _resolve.apply(this, arguments);
let importMetaResolve;
{
importMetaResolve = _importMetaResolve.resolve;
}
function _resolve() {
_resolve = _asyncToGenerator(function* (specifier, parent) {
return (yield importMetaResolveP)(specifier, parent);
});
return _resolve.apply(this, arguments);
function resolve(specifier, parent) {
return importMetaResolve(specifier, parent);
}
0 && 0;
0 && 0;
//# sourceMappingURL=import-meta-resolve.js.map

@@ -17,7 +17,5 @@ "use strict";

exports.resolveShowConfigPath = resolveShowConfigPath;
function findConfigUpwards(rootDir) {
return null;
}
function* findPackageData(filepath) {

@@ -31,3 +29,2 @@ return {

}
function* findRelativeConfig(pkgData, envName, caller) {

@@ -39,34 +36,27 @@ return {

}
function* findRootConfig(dirname, envName, caller) {
return null;
}
function* loadConfig(name, dirname, envName, caller) {
throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`);
}
function* resolveShowConfigPath(dirname) {
return null;
}
const ROOT_CONFIG_FILENAMES = [];
exports.ROOT_CONFIG_FILENAMES = ROOT_CONFIG_FILENAMES;
function resolvePlugin(name, dirname) {
return null;
}
function resolvePreset(name, dirname) {
return null;
}
function loadPlugin(name, dirname) {
throw new Error(`Cannot load plugin ${name} relative to ${dirname} in a browser`);
}
function loadPreset(name, dirname) {
throw new Error(`Cannot load preset ${name} relative to ${dirname} in a browser`);
}
0 && 0;
0 && 0;
//# sourceMappingURL=index-browser.js.map

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

get: function () {
return plugins.loadPlugin;
return _plugins.loadPlugin;
}

@@ -52,6 +52,17 @@ });

get: function () {
return plugins.loadPreset;
return _plugins.loadPreset;
}
});
exports.resolvePreset = exports.resolvePlugin = void 0;
Object.defineProperty(exports, "resolvePlugin", {
enumerable: true,
get: function () {
return _plugins.resolvePlugin;
}
});
Object.defineProperty(exports, "resolvePreset", {
enumerable: true,
get: function () {
return _plugins.resolvePreset;
}
});
Object.defineProperty(exports, "resolveShowConfigPath", {

@@ -63,28 +74,8 @@ enumerable: true,

});
var _package = require("./package");
var _configuration = require("./configuration");
var plugins = require("./plugins");
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _plugins = require("./plugins");
({});
0 && 0;
const resolvePlugin = _gensync()(plugins.resolvePlugin).sync;
exports.resolvePlugin = resolvePlugin;
const resolvePreset = _gensync()(plugins.resolvePreset).sync;
exports.resolvePreset = resolvePreset;
0 && 0;
//# sourceMappingURL=index.js.map

@@ -6,112 +6,124 @@ "use strict";

});
exports.default = loadCjsOrMjsDefault;
exports.default = loadCodeDefault;
exports.supportsESM = void 0;
var _async = require("../../gensync-utils/async");
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _url() {
const data = require("url");
_url = function () {
return data;
};
return data;
}
function _module() {
const data = require("module");
_module = function () {
return data;
};
return data;
}
function _semver() {
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace");
var _configError = require("../../errors/config-error");
var _transformFile = require("../../transform-file");
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
let import_;
try {
import_ = require("./import").default;
import_ = require("./import.cjs");
} catch (_unused) {}
const supportsESM = _semver().satisfies(process.versions.node, "^12.17 || >=13.2");
exports.supportsESM = supportsESM;
function* loadCjsOrMjsDefault(filepath, asyncError, fallbackToTranspiledModule = false) {
switch (guessJSModuleType(filepath)) {
case "cjs":
return loadCjsDefault(filepath, fallbackToTranspiledModule);
case "unknown":
function* loadCodeDefault(filepath, asyncError) {
switch (_path().extname(filepath)) {
case ".cjs":
{
return loadCjsDefault(filepath, arguments[2]);
}
case ".mjs":
break;
case ".cts":
return loadCtsDefault(filepath);
default:
try {
return loadCjsDefault(filepath, fallbackToTranspiledModule);
{
return loadCjsDefault(filepath, arguments[2]);
}
} catch (e) {
if (e.code !== "ERR_REQUIRE_ESM") throw e;
}
case "mjs":
if (yield* (0, _async.isAsync)()) {
return yield* (0, _async.waitFor)(loadMjsDefault(filepath));
}
if (yield* (0, _async.isAsync)()) {
return yield* (0, _async.waitFor)(loadMjsDefault(filepath));
}
throw new _configError.default(asyncError, filepath);
}
function loadCtsDefault(filepath) {
const ext = ".cts";
const hasTsSupport = !!(require.extensions[".ts"] || require.extensions[".cts"] || require.extensions[".mts"]);
let handler;
if (!hasTsSupport) {
const opts = {
babelrc: false,
configFile: false,
sourceType: "unambiguous",
sourceMaps: "inline",
sourceFileName: _path().basename(filepath),
presets: [[getTSPreset(filepath), Object.assign({
onlyRemoveTypeImports: true,
optimizeConstEnums: true
}, {
allowDeclareFields: true
})]]
};
handler = function (m, filename) {
if (handler && filename.endsWith(ext)) {
try {
return m._compile((0, _transformFile.transformFileSync)(filename, Object.assign({}, opts, {
filename
})).code, filename);
} catch (error) {
if (!hasTsSupport) {
const packageJson = require("@babel/preset-typescript/package.json");
if (_semver().lt(packageJson.version, "7.21.4")) {
console.error("`.cts` configuration file failed to load, please try to update `@babel/preset-typescript`.");
}
}
throw error;
}
}
throw new Error(asyncError);
return require.extensions[".js"](m, filename);
};
require.extensions[ext] = handler;
}
try {
const module = (0, _rewriteStackTrace.endHiddenCallStack)(require)(filepath);
return module != null && module.__esModule ? module.default : module;
} finally {
if (!hasTsSupport) {
if (require.extensions[ext] === handler) delete require.extensions[ext];
handler = undefined;
}
}
}
function guessJSModuleType(filename) {
switch (_path().extname(filename)) {
case ".cjs":
return "cjs";
case ".mjs":
return "mjs";
default:
return "unknown";
function loadCjsDefault(filepath) {
const module = (0, _rewriteStackTrace.endHiddenCallStack)(require)(filepath);
{
return module != null && module.__esModule ? module.default || (arguments[1] ? module : undefined) : module;
}
}
function loadCjsDefault(filepath, fallbackToTranspiledModule) {
const module = require(filepath);
return module != null && module.__esModule ? module.default || (fallbackToTranspiledModule ? module : undefined) : module;
}
function loadMjsDefault(_x) {
return _loadMjsDefault.apply(this, arguments);
}
function _loadMjsDefault() {
_loadMjsDefault = _asyncToGenerator(function* (filepath) {
if (!import_) {
throw new Error("Internal error: Native ECMAScript modules aren't supported" + " by this platform.\n");
throw new _configError.default("Internal error: Native ECMAScript modules aren't supported by this platform.\n", filepath);
}
const module = yield import_((0, _url().pathToFileURL)(filepath));
const module = yield (0, _rewriteStackTrace.endHiddenCallStack)(import_)((0, _url().pathToFileURL)(filepath));
return module.default;

@@ -121,3 +133,25 @@ });

}
function getTSPreset(filepath) {
try {
return require("@babel/preset-typescript");
} catch (error) {
if (error.code !== "MODULE_NOT_FOUND") throw error;
let message = "You appear to be using a .cts file as Babel configuration, but the `@babel/preset-typescript` package was not found: please install it!";
{
if (process.versions.pnp) {
message += `
If you are using Yarn Plug'n'Play, you may also need to add the following configuration to your .yarnrc.yml file:
0 && 0;
packageExtensions:
\t"@babel/core@*":
\t\tpeerDependencies:
\t\t\t"@babel/preset-typescript": "*"
`;
}
}
throw new _configError.default(message, filepath);
}
}
0 && 0;
//# sourceMappingURL=module-types.js.map

@@ -7,17 +7,32 @@ "use strict";

exports.findPackageData = findPackageData;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
var _utils = require("./utils");
var _configError = require("../../errors/config-error");
const PACKAGE_FILENAME = "package.json";
const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => {
let options;
try {
options = JSON.parse(content);
} catch (err) {
throw new _configError.default(`Error while parsing JSON - ${err.message}`, filepath);
}
if (!options) throw new Error(`${filepath}: No config detected`);
if (typeof options !== "object") {
throw new _configError.default(`Config returned typeof ${typeof options}`, filepath);
}
if (Array.isArray(options)) {
throw new _configError.default(`Expected config object but found array`, filepath);
}
return {
filepath,
dirname: _path().dirname(filepath),
options
};
});
function* findPackageData(filepath) {

@@ -27,11 +42,7 @@ let pkg = null;

let isPackage = true;
let dirname = _path().dirname(filepath);
while (!pkg && _path().basename(dirname) !== "node_modules") {
directories.push(dirname);
pkg = yield* readConfigPackage(_path().join(dirname, PACKAGE_FILENAME));
const nextLoc = _path().dirname(dirname);
if (dirname === nextLoc) {

@@ -41,6 +52,4 @@ isPackage = false;

}
dirname = nextLoc;
}
return {

@@ -53,29 +62,4 @@ filepath,

}
0 && 0;
const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => {
let options;
try {
options = JSON.parse(content);
} catch (err) {
err.message = `${filepath}: Error while parsing JSON - ${err.message}`;
throw err;
}
if (!options) throw new Error(`${filepath}: No config detected`);
if (typeof options !== "object") {
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
}
if (Array.isArray(options)) {
throw new Error(`${filepath}: Expected config object but found array`);
}
return {
filepath,
dirname: _path().dirname(filepath),
options
};
});
0 && 0;
//# sourceMappingURL=package.js.map

@@ -8,67 +8,28 @@ "use strict";

exports.loadPreset = loadPreset;
exports.resolvePlugin = resolvePlugin;
exports.resolvePreset = resolvePreset;
exports.resolvePreset = exports.resolvePlugin = void 0;
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../../gensync-utils/async");
var _moduleTypes = require("./module-types");
function _url() {
const data = require("url");
_url = function () {
return data;
};
return data;
}
var _importMetaResolve = require("./import-meta-resolve");
function _module() {
const data = require("module");
_module = function () {
return data;
};
return data;
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
const debug = _debug()("babel:config:loading:files:plugins");
const EXACT_RE = /^module:/;

@@ -82,13 +43,8 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;

const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
function* resolvePlugin(name, dirname) {
return yield* resolveStandardizedName("plugin", name, dirname);
}
function* resolvePreset(name, dirname) {
return yield* resolveStandardizedName("preset", name, dirname);
}
const resolvePlugin = resolveStandardizedName.bind(null, "plugin");
exports.resolvePlugin = resolvePlugin;
const resolvePreset = resolveStandardizedName.bind(null, "preset");
exports.resolvePreset = resolvePreset;
function* loadPlugin(name, dirname) {
const filepath = yield* resolvePlugin(name, dirname);
const filepath = resolvePlugin(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("plugin", filepath);

@@ -101,5 +57,4 @@ debug("Loaded plugin %o from %o.", name, dirname);

}
function* loadPreset(name, dirname) {
const filepath = yield* resolvePreset(name, dirname);
const filepath = resolvePreset(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("preset", filepath);

@@ -112,3 +67,2 @@ debug("Loaded preset %o from %o.", name, dirname);

}
function standardizeName(type, name) {

@@ -119,3 +73,2 @@ if (_path().isAbsolute(name)) return name;

}
function* resolveAlternativesHelper(type, name) {

@@ -129,38 +82,49 @@ const standardizedName = standardizeName(type, name);

if (error.code !== "MODULE_NOT_FOUND") throw error;
if (standardizedName !== name && !(yield name).error) {
error.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
}
if (!(yield standardizeName(type, "@babel/" + name)).error) {
error.message += `\n- Did you mean "@babel/${name}"?`;
}
const oppositeType = type === "preset" ? "plugin" : "preset";
if (!(yield standardizeName(oppositeType, name)).error) {
error.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
}
throw error;
}
function tryRequireResolve(id, {
paths: [dirname]
}) {
function tryRequireResolve(id, dirname) {
try {
if (dirname) {
return {
error: null,
value: (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})(id, {
paths: [dirname]
})
};
} else {
return {
error: null,
value: require.resolve(id)
};
}
} catch (error) {
return {
error,
value: null
};
}
}
function tryImportMetaResolve(id, options) {
try {
return {
error: null,
value: (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "8.9") ? require.resolve : (r, {
paths: [b]
}, M = require("module")) => {
let f = M._findPath(r, M._nodeModulePaths(b).concat(b));
if (f) return f;
f = new Error(`Cannot resolve module '${r}'`);
f.code = "MODULE_NOT_FOUND";
throw f;
})(id, {
paths: [dirname]
})
value: (0, _importMetaResolve.default)(id, options)
};

@@ -174,87 +138,38 @@ } catch (error) {

}
function tryImportMetaResolve(_x, _x2) {
return _tryImportMetaResolve.apply(this, arguments);
}
function _tryImportMetaResolve() {
_tryImportMetaResolve = _asyncToGenerator(function* (id, options) {
try {
return {
error: null,
value: yield (0, _importMetaResolve.default)(id, options)
};
} catch (error) {
return {
error,
value: null
};
}
});
return _tryImportMetaResolve.apply(this, arguments);
}
function resolveStandardizedNameForRequire(type, name, dirname) {
const it = resolveAlternativesHelper(type, name);
let res = it.next();
while (!res.done) {
res = it.next(tryRequireResolve(res.value, {
paths: [dirname]
}));
res = it.next(tryRequireResolve(res.value, dirname));
}
return res.value;
}
function resolveStandardizedNameForImport(_x3, _x4, _x5) {
return _resolveStandardizedNameForImport.apply(this, arguments);
function resolveStandardizedNameForImport(type, name, dirname) {
const parentUrl = (0, _url().pathToFileURL)(_path().join(dirname, "./babel-virtual-resolve-base.js")).href;
const it = resolveAlternativesHelper(type, name);
let res = it.next();
while (!res.done) {
res = it.next(tryImportMetaResolve(res.value, parentUrl));
}
return (0, _url().fileURLToPath)(res.value);
}
function _resolveStandardizedNameForImport() {
_resolveStandardizedNameForImport = _asyncToGenerator(function* (type, name, dirname) {
const parentUrl = (0, _url().pathToFileURL)(_path().join(dirname, "./babel-virtual-resolve-base.js")).href;
const it = resolveAlternativesHelper(type, name);
let res = it.next();
while (!res.done) {
res = it.next(yield tryImportMetaResolve(res.value, parentUrl));
function resolveStandardizedName(type, name, dirname, resolveESM) {
if (!_moduleTypes.supportsESM || !resolveESM) {
return resolveStandardizedNameForRequire(type, name, dirname);
}
try {
return resolveStandardizedNameForImport(type, name, dirname);
} catch (e) {
try {
return resolveStandardizedNameForRequire(type, name, dirname);
} catch (e2) {
if (e.type === "MODULE_NOT_FOUND") throw e;
if (e2.type === "MODULE_NOT_FOUND") throw e2;
throw e;
}
return (0, _url().fileURLToPath)(res.value);
});
return _resolveStandardizedNameForImport.apply(this, arguments);
}
}
const resolveStandardizedName = _gensync()({
sync(type, name, dirname = process.cwd()) {
return resolveStandardizedNameForRequire(type, name, dirname);
},
async(type, name, dirname = process.cwd()) {
return _asyncToGenerator(function* () {
if (!_moduleTypes.supportsESM) {
return resolveStandardizedNameForRequire(type, name, dirname);
}
try {
return yield resolveStandardizedNameForImport(type, name, dirname);
} catch (e) {
try {
return resolveStandardizedNameForRequire(type, name, dirname);
} catch (e2) {
if (e.type === "MODULE_NOT_FOUND") throw e;
if (e2.type === "MODULE_NOT_FOUND") throw e2;
throw e;
}
}
})();
}
});
{
var LOADING_MODULES = new Set();
}
function* requireModule(type, name) {

@@ -266,3 +181,2 @@ {

}
try {

@@ -272,3 +186,5 @@ {

}
return yield* (0, _moduleTypes.default)(name, `You appear to be using a native ECMAScript module ${type}, ` + "which is only supported when running Babel asynchronously.", true);
{
return yield* (0, _moduleTypes.default)(name, `You appear to be using a native ECMAScript module ${type}, ` + "which is only supported when running Babel asynchronously.", true);
}
} catch (err) {

@@ -283,3 +199,4 @@ err.message = `[BABEL]: ${err.message} (While processing: ${name})`;

}
0 && 0;
0 && 0;
//# sourceMappingURL=plugins.js.map

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

0 && 0;
0 && 0;
//# sourceMappingURL=types.js.map

@@ -7,32 +7,22 @@ "use strict";

exports.makeStaticFileCache = makeStaticFileCache;
var _caching = require("../caching");
var fs = require("../../gensync-utils/fs");
function _fs2() {
const data = require("fs");
_fs2 = function () {
return data;
};
return data;
}
function makeStaticFileCache(fn) {
return (0, _caching.makeStrongCache)(function* (filepath, cache) {
const cached = cache.invalidate(() => fileMtime(filepath));
if (cached === null) {
return null;
}
return fn(filepath, yield* fs.readFile(filepath, "utf8"));
});
}
function fileMtime(filepath) {
if (!_fs2().existsSync(filepath)) return null;
try {

@@ -43,6 +33,6 @@ return +_fs2().statSync(filepath).mtime;

}
return null;
}
0 && 0;
0 && 0;
//# sourceMappingURL=utils.js.map

@@ -7,58 +7,35 @@ "use strict";

exports.default = void 0;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../gensync-utils/async");
var _util = require("./util");
var context = require("../index");
var _plugin = require("./plugin");
var _item = require("./item");
var _configChain = require("./config-chain");
var _deepArray = require("./helpers/deep-array");
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
var _caching = require("./caching");
var _options = require("./validation/options");
var _plugins = require("./validation/plugins");
var _configApi = require("./helpers/config-api");
var _partial = require("./partial");
var Context = require("./cache-contexts");
var _configError = require("../errors/config-error");
var _default = _gensync()(function* loadFullConfig(inputOpts) {
var _opts$assumptions;
const result = yield* (0, _partial.default)(inputOpts);
if (!result) {
return null;
}
const {

@@ -69,7 +46,5 @@ options,

} = result;
if (fileHandling === "ignored") {
return null;
}
const optionDefaults = {};

@@ -80,21 +55,15 @@ const {

} = options;
if (!plugins || !presets) {
throw new Error("Assertion failure - plugins and presets exist");
}
const presetContext = Object.assign({}, context, {
targets: options.targets
});
const toDescriptor = item => {
const desc = (0, _item.getItemDescriptor)(item);
if (!desc) {
throw new Error("Assertion failure - must be config item");
}
return desc;
};
const presetsDescriptors = presets.map(toDescriptor);

@@ -107,6 +76,4 @@ const initialPluginsDescriptors = plugins.map(toDescriptor);

const presets = [];
for (let i = 0; i < rawPresets.length; i++) {
const descriptor = rawPresets[i];
if (descriptor.options !== false) {

@@ -119,8 +86,5 @@ try {

}
throw e;
}
externalDependencies.push(preset.externalDependencies);
if (descriptor.ownPass) {

@@ -139,6 +103,4 @@ presets.push({

}
if (presets.length > 0) {
pluginDescriptorsByPass.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pluginDescriptorsPass));
for (const {

@@ -166,10 +128,7 @@ preset,

pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors);
for (const descs of pluginDescriptorsByPass) {
const pass = [];
passes.push(pass);
for (let i = 0; i < descs.length; i++) {
const descriptor = descs[i];
if (descriptor.options !== false) {

@@ -182,6 +141,4 @@ try {

}
throw e;
}
pass.push(plugin);

@@ -204,5 +161,3 @@ externalDependencies.push(plugin.externalDependencies);

});
exports.default = _default;
function enhanceError(context, fn) {

@@ -214,5 +169,5 @@ return function* (arg1, arg2) {

if (!/^\[BABEL\]/.test(e.message)) {
e.message = `[BABEL] ${context.filename || "unknown"}: ${e.message}`;
var _context$filename;
e.message = `[BABEL] ${(_context$filename = context.filename) != null ? _context$filename : "unknown file"}: ${e.message}`;
}
throw e;

@@ -222,3 +177,2 @@ }

}
const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function* ({

@@ -234,7 +188,5 @@ value,

let item = value;
if (typeof value === "function") {
const factory = (0, _async.maybeAsync)(value, `You appear to be using an async plugin/preset, but Babel has been called synchronously`);
const api = Object.assign({}, context, apiFactory(cache, externalDependencies));
try {

@@ -246,11 +198,8 @@ item = yield* factory(api, options, dirname);

}
throw e;
}
}
if (!item || typeof item !== "object") {
throw new Error("Plugin/Preset did not return an object.");
}
if ((0, _async.isThenable)(item)) {

@@ -260,6 +209,4 @@ yield* [];

}
if (externalDependencies.length > 0 && (!cache.configured() || cache.mode() === "forever")) {
let error = `A plugin/preset has external untracked dependencies ` + `(${externalDependencies[0]}), but the cache `;
if (!cache.configured()) {

@@ -270,7 +217,5 @@ error += `has not been configured to be invalidated when the external dependencies change. `;

}
error += `Plugins/presets should configure their cache to be invalidated when the external ` + `dependencies change, for example using \`api.cache.invalidate(() => ` + `statSync(filepath).mtimeMs)\` or \`api.cache.never()\`\n` + `(While processing: ${JSON.stringify(alias)})`;
throw new Error(error);
}
return {

@@ -284,18 +229,4 @@ value: item,

});
const pluginDescriptorLoader = makeDescriptorLoader(_configApi.makePluginAPI);
const presetDescriptorLoader = makeDescriptorLoader(_configApi.makePresetAPI);
function* loadPluginDescriptor(descriptor, context) {
if (descriptor.value instanceof _plugin.default) {
if (descriptor.options) {
throw new Error("Passed options to an existing Plugin instance will not work.");
}
return descriptor.value;
}
return yield* instantiatePlugin(yield* pluginDescriptorLoader(descriptor, context), context);
}
const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({

@@ -310,7 +241,5 @@ value,

const plugin = Object.assign({}, pluginObj);
if (plugin.visitor) {
plugin.visitor = _traverse().default.explode(Object.assign({}, plugin.visitor));
}
if (plugin.inherits) {

@@ -331,3 +260,2 @@ const inheritsDescriptor = {

plugin.visitor = _traverse().default.visitors.merge([inherits.visitor || {}, plugin.visitor || {}]);
if (inherits.externalDependencies.length > 0) {

@@ -341,13 +269,20 @@ if (externalDependencies.length === 0) {

}
return new _plugin.default(plugin, options, alias, externalDependencies);
});
function* loadPluginDescriptor(descriptor, context) {
if (descriptor.value instanceof _plugin.default) {
if (descriptor.options) {
throw new Error("Passed options to an existing Plugin instance will not work.");
}
return descriptor.value;
}
return yield* instantiatePlugin(yield* pluginDescriptorLoader(descriptor, context), context);
}
const needsFilename = val => val && typeof val !== "function";
const validateIfOptionNeedsFilename = (options, descriptor) => {
if (options.test || options.include || options.exclude) {
if (needsFilename(options.test) || needsFilename(options.include) || needsFilename(options.exclude)) {
const formattedPresetName = descriptor.name ? `"${descriptor.name}"` : "/* your preset */";
throw new Error([`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`, `\`\`\``, `babel.transformSync(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`, `\`\`\``, `See https://babeljs.io/docs/en/options#filename for more information.`].join("\n"));
throw new _configError.default([`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`, `\`\`\``, `babel.transformSync(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`, `\`\`\``, `See https://babeljs.io/docs/en/options#filename for more information.`].join("\n"));
}
};
const validatePreset = (preset, context, descriptor) => {

@@ -359,3 +294,2 @@ if (!context.filename) {

validateIfOptionNeedsFilename(options, descriptor);
if (options.overrides) {

@@ -366,12 +300,2 @@ options.overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor));

};
function* loadPresetDescriptor(descriptor, context) {
const preset = instantiatePreset(yield* presetDescriptorLoader(descriptor, context));
validatePreset(preset, context, descriptor);
return {
chain: yield* (0, _configChain.buildPresetChain)(preset, context),
externalDependencies: preset.externalDependencies
};
}
const instantiatePreset = (0, _caching.makeWeakCacheSync)(({

@@ -390,3 +314,10 @@ value,

});
function* loadPresetDescriptor(descriptor, context) {
const preset = instantiatePreset(yield* presetDescriptorLoader(descriptor, context));
validatePreset(preset, context, descriptor);
return {
chain: yield* (0, _configChain.buildPresetChain)(preset, context),
externalDependencies: preset.externalDependencies
};
}
function chain(a, b) {

@@ -401,3 +332,4 @@ const fns = [a, b].filter(Boolean);

}
0 && 0;
0 && 0;
//# sourceMappingURL=full.js.map

@@ -9,27 +9,17 @@ "use strict";

exports.makePresetAPI = makePresetAPI;
function _semver() {
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
var _ = require("../../");
var _caching = require("../caching");
var Context = require("../cache-contexts");
function makeConfigAPI(cache) {
const env = value => cache.using(data => {
if (typeof value === "undefined") return data.envName;
if (typeof value === "function") {
return (0, _caching.assertSimpleType)(value(data.envName));
}
return (Array.isArray(value) ? value : [value]).some(entry => {

@@ -39,9 +29,6 @@ if (typeof entry !== "string") {

}
return entry === data.envName;
});
});
const caller = cb => cache.using(data => (0, _caching.assertSimpleType)(cb(data.caller)));
return {

@@ -56,10 +43,7 @@ version: _.version,

}
function makePresetAPI(cache, externalDependencies) {
const targets = () => JSON.parse(cache.using(data => JSON.stringify(data.targets)));
const addExternalDependency = ref => {
externalDependencies.push(ref);
};
return Object.assign({}, makeConfigAPI(cache), {

@@ -70,6 +54,4 @@ targets,

}
function makePluginAPI(cache, externalDependencies) {
const assumption = name => cache.using(data => data.assumptions[name]);
return Object.assign({}, makePresetAPI(cache, externalDependencies), {

@@ -79,3 +61,2 @@ assumption

}
function assertVersion(range) {

@@ -86,23 +67,17 @@ if (typeof range === "number") {

}
range = `^${range}.0.0-0`;
}
if (typeof range !== "string") {
throw new Error("Expected string or integer value.");
}
;
if (_semver().satisfies(_.version, range)) return;
const limit = Error.stackTraceLimit;
if (typeof limit === "number" && limit < 25) {
Error.stackTraceLimit = 25;
}
const err = new Error(`Requires Babel "${range}", but was loaded with "${_.version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`);
if (typeof limit === "number") {
Error.stackTraceLimit = limit;
}
throw Object.assign(err, {

@@ -114,3 +89,4 @@ code: "BABEL_VERSION_UNSUPPORTED",

}
0 && 0;
0 && 0;
//# sourceMappingURL=config-api.js.map

@@ -8,11 +8,8 @@ "use strict";

exports.flattenToSet = flattenToSet;
function finalize(deepArr) {
return Object.freeze(deepArr);
}
function flattenToSet(arr) {
const result = new Set();
const stack = [arr];
while (stack.length > 0) {

@@ -23,6 +20,6 @@ for (const el of stack.pop()) {

}
return result;
}
0 && 0;
0 && 0;
//# sourceMappingURL=deep-array.js.map

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

exports.getEnv = getEnv;
function getEnv(defaultValue = "development") {
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
}
0 && 0;
0 && 0;
//# sourceMappingURL=environment.js.map

@@ -15,37 +15,33 @@ "use strict";

exports.loadPartialConfigSync = exports.loadPartialConfigAsync = exports.loadPartialConfig = exports.loadOptionsSync = exports.loadOptionsAsync = exports.loadOptions = void 0;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _full = require("./full");
var _partial = require("./partial");
var _item = require("./item");
const loadOptionsRunner = _gensync()(function* (opts) {
var _config$options;
const config = yield* (0, _full.default)(opts);
return (_config$options = config == null ? void 0 : config.options) != null ? _config$options : null;
});
const createConfigItemRunner = _gensync()(_item.createConfigItem);
const maybeErrback = runner => (opts, callback) => {
if (callback === undefined && typeof opts === "function") {
callback = opts;
opts = undefined;
const maybeErrback = runner => (argOrCallback, maybeCallback) => {
let arg;
let callback;
if (maybeCallback === undefined && typeof argOrCallback === "function") {
callback = argOrCallback;
arg = undefined;
} else {
callback = maybeCallback;
arg = argOrCallback;
}
return callback ? runner.errback(opts, callback) : runner.sync(opts);
if (!callback) {
return runner.sync(arg);
}
runner.errback(arg, callback);
};
const loadPartialConfig = maybeErrback(_partial.loadPartialConfig);

@@ -67,8 +63,7 @@ exports.loadPartialConfig = loadPartialConfig;

exports.createConfigItemAsync = createConfigItemAsync;
function createConfigItem(target, options, callback) {
if (callback !== undefined) {
return createConfigItemRunner.errback(target, options, callback);
createConfigItemRunner.errback(target, options, callback);
} else if (typeof options === "function") {
return createConfigItemRunner.errback(target, undefined, callback);
createConfigItemRunner.errback(target, undefined, callback);
} else {

@@ -78,3 +73,4 @@ return createConfigItemRunner.sync(target, options);

}
0 && 0;
0 && 0;
//# sourceMappingURL=index.js.map

@@ -9,19 +9,13 @@ "use strict";

exports.getItemDescriptor = getItemDescriptor;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
var _configDescriptors = require("./config-descriptors");
function createItemFromDescriptor(desc) {
return new ConfigItem(desc);
}
function* createConfigItem(value, {

@@ -37,3 +31,3 @@ dirname = ".",

}
const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
function getItemDescriptor(item) {

@@ -43,8 +37,4 @@ if (item != null && item[CONFIG_ITEM_BRAND]) {

}
return undefined;
}
const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
class ConfigItem {

@@ -76,6 +66,6 @@ constructor(descriptor) {

}
}
Object.freeze(ConfigItem.prototype);
0 && 0;
Object.freeze(ConfigItem.prototype);
0 && 0;
//# sourceMappingURL=item.js.map

@@ -8,43 +8,26 @@ "use strict";

exports.loadPartialConfig = void 0;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _plugin = require("./plugin");
var _util = require("./util");
var _item = require("./item");
var _configChain = require("./config-chain");
var _environment = require("./helpers/environment");
var _options = require("./validation/options");
var _files = require("./files");
var _resolveTargets = require("./resolve-targets");
const _excluded = ["showIgnoredFiles"];
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function resolveRootMode(rootDir, rootMode) {

@@ -54,3 +37,2 @@ switch (rootMode) {

return rootDir;
case "upward-optional":

@@ -61,3 +43,2 @@ {

}
case "upward":

@@ -72,3 +53,2 @@ {

}
default:

@@ -78,3 +58,2 @@ throw new Error(`Assertion failure - unknown rootMode value.`);

}
function* loadPrivatePartialConfig(inputOpts) {

@@ -84,3 +63,2 @@ if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {

}
const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};

@@ -95,5 +73,3 @@ const {

} = args;
const absoluteCwd = _path().resolve(cwd);
const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);

@@ -143,6 +119,4 @@ const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;

}
const loadPartialConfig = _gensync()(function* (opts) {
let showIgnoredFiles = false;
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {

@@ -156,3 +130,2 @@ var _opts = opts;

}
const result = yield* loadPrivatePartialConfig(opts);

@@ -168,7 +141,5 @@ if (!result) return null;

} = result;
if (fileHandling === "ignored" && !showIgnoredFiles) {
return null;
}
(options.plugins || []).forEach(item => {

@@ -181,5 +152,3 @@ if (item.value instanceof _plugin.default) {

});
exports.loadPartialConfig = loadPartialConfig;
class PartialConfig {

@@ -201,10 +170,9 @@ constructor(options, babelrc, ignore, config, fileHandling, files) {

}
hasFilesystemConfig() {
return this.babelrc !== undefined || this.config !== undefined;
}
}
Object.freeze(PartialConfig.prototype);
0 && 0;
Object.freeze(PartialConfig.prototype);
0 && 0;
//# sourceMappingURL=partial.js.map

@@ -7,13 +7,9 @@ "use strict";

exports.default = pathToPattern;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
const sep = `\\${_path().sep}`;

@@ -26,10 +22,7 @@ const endSep = `(?:${sep}|$)`;

const starStarPatLast = `${starPat}*?${starPatLast}?`;
function escapeRegExp(string) {
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&");
}
function pathToPattern(pattern, dirname) {
const parts = _path().resolve(dirname, pattern).split(_path().sep);
return new RegExp(["^", ...parts.map((part, i) => {

@@ -39,11 +32,10 @@ const last = i === parts.length - 1;

if (part === "*") return last ? starPatLast : starPat;
if (part.indexOf("*.") === 0) {
return substitution + escapeRegExp(part.slice(1)) + (last ? endSep : sep);
}
return escapeRegExp(part) + (last ? endSep : sep);
})].join(""));
}
0 && 0;
0 && 0;
//# sourceMappingURL=pattern-to-regex.js.map

@@ -7,5 +7,3 @@ "use strict";

exports.default = void 0;
var _deepArray = require("./helpers/deep-array");
class Plugin {

@@ -32,6 +30,6 @@ constructor(plugin, options, key, externalDependencies = (0, _deepArray.finalize)([])) {

}
}
exports.default = Plugin;
0 && 0;
exports.default = Plugin;
0 && 0;
//# sourceMappingURL=plugin.js.map

@@ -7,13 +7,9 @@ "use strict";

exports.ConfigPrinter = exports.ChainFormatter = void 0;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
const ChainFormatter = {

@@ -27,6 +23,4 @@ Programmatic: 0,

let title = "";
if (type === ChainFormatter.Programmatic) {
title = "programmatic options";
if (callerName) {

@@ -38,20 +32,14 @@ title += " from " + callerName;

}
return title;
},
loc(index, envName) {
let loc = "";
if (index != null) {
loc += `.overrides[${index}]`;
}
if (envName != null) {
loc += `.env["${envName}"]`;
}
return loc;
},
*optionsAndDescriptors(opt) {

@@ -62,23 +50,15 @@ const content = Object.assign({}, opt.options);

const pluginDescriptors = [...(yield* opt.plugins())];
if (pluginDescriptors.length) {
content.plugins = pluginDescriptors.map(d => descriptorToConfig(d));
}
const presetDescriptors = [...(yield* opt.presets())];
if (presetDescriptors.length) {
content.presets = [...presetDescriptors].map(d => descriptorToConfig(d));
}
return JSON.stringify(content, undefined, 2);
}
};
function descriptorToConfig(d) {
var _d$file;
let name = (_d$file = d.file) == null ? void 0 : _d$file.request;
if (name == null) {

@@ -91,7 +71,5 @@ if (typeof d.value === "object") {

}
if (name == null) {
name = "[Unknown]";
}
if (d.options === undefined) {

@@ -105,3 +83,2 @@ return name;

}
class ConfigPrinter {

@@ -111,3 +88,2 @@ constructor() {

}
configure(enabled, type, {

@@ -129,3 +105,2 @@ callerName,

}
static *format(config) {

@@ -138,3 +113,2 @@ let title = Formatter.title(config.type, config.callerName, config.filepath);

}
*output() {

@@ -145,6 +119,6 @@ if (this._stack.length === 0) return "";

}
}
exports.ConfigPrinter = ConfigPrinter;
0 && 0;
exports.ConfigPrinter = ConfigPrinter;
0 && 0;
//# sourceMappingURL=printer.js.map

@@ -8,21 +8,15 @@ "use strict";

exports.resolveTargets = resolveTargets;
function _helperCompilationTargets() {
const data = require("@babel/helper-compilation-targets");
_helperCompilationTargets = function () {
return data;
};
return data;
}
function resolveBrowserslistConfigFile(browserslistConfigFile, configFilePath) {
return undefined;
}
function resolveTargets(options, root) {
const optTargets = options.targets;
let targets;
if (typeof optTargets === "string" || Array.isArray(optTargets)) {

@@ -41,3 +35,2 @@ targets = {

}
return (0, _helperCompilationTargets().default)(targets, {

@@ -48,3 +41,4 @@ ignoreBrowserslistConfig: true,

}
0 && 0;
0 && 0;
//# sourceMappingURL=resolve-targets-browser.js.map

@@ -8,33 +8,23 @@ "use strict";

exports.resolveTargets = resolveTargets;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _helperCompilationTargets() {
const data = require("@babel/helper-compilation-targets");
_helperCompilationTargets = function () {
return data;
};
return data;
}
({});
function resolveBrowserslistConfigFile(browserslistConfigFile, configFileDir) {
return _path().resolve(configFileDir, browserslistConfigFile);
}
function resolveTargets(options, root) {
const optTargets = options.targets;
let targets;
if (typeof optTargets === "string" || Array.isArray(optTargets)) {

@@ -53,3 +43,2 @@ targets = {

}
const {

@@ -60,3 +49,2 @@ browserslistConfigFile

let ignoreBrowserslistConfig = false;
if (typeof browserslistConfigFile === "string") {

@@ -67,3 +55,2 @@ configFile = browserslistConfigFile;

}
return (0, _helperCompilationTargets().default)(targets, {

@@ -76,3 +63,4 @@ ignoreBrowserslistConfig,

}
0 && 0;
0 && 0;
//# sourceMappingURL=resolve-targets.js.map

@@ -8,3 +8,2 @@ "use strict";

exports.mergeOptions = mergeOptions;
function mergeOptions(target, source) {

@@ -22,3 +21,2 @@ for (const k of Object.keys(source)) {

}
function mergeDefaultFields(target, source) {

@@ -30,7 +28,7 @@ for (const k of Object.keys(source)) {

}
function isIterableIterator(value) {
return !!value && typeof value.next === "function" && typeof value[Symbol.iterator] === "function";
}
0 && 0;
0 && 0;
//# sourceMappingURL=util.js.map

@@ -26,15 +26,10 @@ "use strict";

exports.msg = msg;
function _helperCompilationTargets() {
const data = require("@babel/helper-compilation-targets");
_helperCompilationTargets = function () {
return data;
};
return data;
}
var _options = require("./options");
function msg(loc) {

@@ -44,15 +39,10 @@ switch (loc.type) {

return ``;
case "env":
return `${msg(loc.parent)}.env["${loc.name}"]`;
case "overrides":
return `${msg(loc.parent)}.overrides[${loc.index}]`;
case "option":
return `${msg(loc.parent)}.${loc.name}`;
case "access":
return `${msg(loc.parent)}[${JSON.stringify(loc.name)}]`;
default:

@@ -62,3 +52,2 @@ throw new Error(`Assertion failure: Unknown type ${loc.type}`);

}
function access(loc, name) {

@@ -71,3 +60,2 @@ return {

}
function assertRootMode(loc, value) {

@@ -77,6 +65,4 @@ if (value !== undefined && value !== "root" && value !== "upward" && value !== "upward-optional") {

}
return value;
}
function assertSourceMaps(loc, value) {

@@ -86,6 +72,4 @@ if (value !== undefined && typeof value !== "boolean" && value !== "inline" && value !== "both") {

}
return value;
}
function assertCompact(loc, value) {

@@ -95,6 +79,4 @@ if (value !== undefined && typeof value !== "boolean" && value !== "auto") {

}
return value;
}
function assertSourceType(loc, value) {

@@ -104,9 +86,6 @@ if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") {

}
return value;
}
function assertCallerMetadata(loc, value) {
const obj = assertObject(loc, value);
if (obj) {

@@ -116,7 +95,5 @@ if (typeof obj.name !== "string") {

}
for (const prop of Object.keys(obj)) {
const propLoc = access(loc, prop);
const value = obj[prop];
if (value != null && typeof value !== "boolean" && typeof value !== "string" && typeof value !== "number") {

@@ -127,6 +104,4 @@ throw new Error(`${msg(propLoc)} must be null, undefined, a boolean, a string, or a number.`);

}
return value;
}
function assertInputSourceMap(loc, value) {

@@ -136,6 +111,4 @@ if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) {

}
return value;
}
function assertString(loc, value) {

@@ -145,6 +118,4 @@ if (value !== undefined && typeof value !== "string") {

}
return value;
}
function assertFunction(loc, value) {

@@ -154,6 +125,4 @@ if (value !== undefined && typeof value !== "function") {

}
return value;
}
function assertBoolean(loc, value) {

@@ -163,6 +132,4 @@ if (value !== undefined && typeof value !== "boolean") {

}
return value;
}
function assertObject(loc, value) {

@@ -172,6 +139,4 @@ if (value !== undefined && (typeof value !== "object" || Array.isArray(value) || !value)) {

}
return value;
}
function assertArray(loc, value) {

@@ -181,16 +146,11 @@ if (value != null && !Array.isArray(value)) {

}
return value;
}
function assertIgnoreList(loc, value) {
const arr = assertArray(loc, value);
if (arr) {
arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
}
return arr;
}
function assertIgnoreItem(loc, value) {

@@ -200,9 +160,8 @@ if (typeof value !== "string" && typeof value !== "function" && !(value instanceof RegExp)) {

}
return value;
}
function assertConfigApplicableTest(loc, value) {
if (value === undefined) return value;
if (value === undefined) {
return value;
}
if (Array.isArray(value)) {

@@ -217,10 +176,7 @@ value.forEach((item, i) => {

}
return value;
}
function checkValidTest(value) {
return typeof value === "string" || typeof value === "function" || value instanceof RegExp;
}
function assertConfigFileSearch(loc, value) {

@@ -230,9 +186,8 @@ if (value !== undefined && typeof value !== "boolean" && typeof value !== "string") {

}
return value;
}
function assertBabelrcSearch(loc, value) {
if (value === undefined || typeof value === "boolean") return value;
if (value === undefined || typeof value === "boolean") {
return value;
}
if (Array.isArray(value)) {

@@ -247,16 +202,11 @@ value.forEach((item, i) => {

}
return value;
}
function assertPluginList(loc, value) {
const arr = assertArray(loc, value);
if (arr) {
arr.forEach((item, i) => assertPluginItem(access(loc, i), item));
}
return arr;
}
function assertPluginItem(loc, value) {

@@ -267,12 +217,8 @@ if (Array.isArray(value)) {

}
if (value.length > 3) {
throw new Error(`${msg(loc)} may only be a two-tuple or three-tuple`);
}
assertPluginTarget(access(loc, 0), value[0]);
if (value.length > 1) {
const opts = value[1];
if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts) || opts === null)) {

@@ -282,6 +228,4 @@ throw new Error(`${msg(access(loc, 1))} must be an object, false, or undefined`);

}
if (value.length === 3) {
const name = value[2];
if (name !== undefined && typeof name !== "string") {

@@ -294,6 +238,4 @@ throw new Error(`${msg(access(loc, 2))} must be a string, or undefined`);

}
return value;
}
function assertPluginTarget(loc, value) {

@@ -303,13 +245,9 @@ if ((typeof value !== "object" || !value) && typeof value !== "string" && typeof value !== "function") {

}
return value;
}
function assertTargets(loc, value) {
if ((0, _helperCompilationTargets().isBrowsersQueryValid)(value)) return value;
if (typeof value !== "object" || !value || Array.isArray(value)) {
throw new Error(`${msg(loc)} must be a string, an array of strings or an object`);
}
const browsersLoc = access(loc, "browsers");

@@ -319,3 +257,2 @@ const esmodulesLoc = access(loc, "esmodules");

assertBoolean(esmodulesLoc, value.esmodules);
for (const key of Object.keys(value)) {

@@ -329,6 +266,4 @@ const val = value[key];

}
return value;
}
function assertBrowsersList(loc, value) {

@@ -339,3 +274,2 @@ if (value !== undefined && !(0, _helperCompilationTargets().isBrowsersQueryValid)(value)) {

}
function assertBrowserVersion(loc, value) {

@@ -346,29 +280,20 @@ if (typeof value === "number" && Math.round(value) === value) return;

}
function assertAssumptions(loc, value) {
if (value === undefined) return;
if (typeof value !== "object" || value === null) {
throw new Error(`${msg(loc)} must be an object or undefined.`);
}
let root = loc;
do {
root = root.parent;
} while (root.type !== "root");
const inPreset = root.source === "preset";
for (const name of Object.keys(value)) {
const subLoc = access(loc, name);
if (!_options.assumptionsNames.has(name)) {
throw new Error(`${msg(subLoc)} is not a supported assumption.`);
}
if (typeof value[name] !== "boolean") {
throw new Error(`${msg(subLoc)} must be a boolean.`);
}
if (inPreset && value[name] === false) {

@@ -378,6 +303,6 @@ throw new Error(`${msg(subLoc)} cannot be set to 'false' inside presets.`);

}
return value;
}
0 && 0;
0 && 0;
//# sourceMappingURL=option-assertions.js.map

@@ -9,9 +9,5 @@ "use strict";

exports.validate = validate;
var _plugin = require("../plugin");
var _removed = require("./removed");
var _optionAssertions = require("./option-assertions");
var _configError = require("../../errors/config-error");
const ROOT_VALIDATORS = {

@@ -78,17 +74,20 @@ cwd: _optionAssertions.assertString,

}
const knownAssumptions = ["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noIncompleteNsImportDetection", "noNewArrows", "objectRestNoSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"];
const knownAssumptions = ["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noIncompleteNsImportDetection", "noNewArrows", "objectRestNoSymbols", "privateFieldsAsSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"];
const assumptionsNames = new Set(knownAssumptions);
exports.assumptionsNames = assumptionsNames;
function getSource(loc) {
return loc.type === "root" ? loc.source : getSource(loc.parent);
}
function validate(type, opts) {
return validateNested({
type: "root",
source: type
}, opts);
function validate(type, opts, filename) {
try {
return validateNested({
type: "root",
source: type
}, opts);
} catch (error) {
const configError = new _configError.default(error.message, filename);
if (error.code) configError.code = error.code;
throw configError;
}
}
function validateNested(loc, opts) {

@@ -103,11 +102,8 @@ const type = getSource(loc);

};
if (type === "preset" && NONPRESET_VALIDATORS[key]) {
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in preset options`);
}
if (type !== "arguments" && ROOT_VALIDATORS[key]) {
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options`);
}
if (type !== "arguments" && type !== "configfile" && BABELRC_VALIDATORS[key]) {

@@ -117,6 +113,4 @@ if (type === "babelrcfile" || type === "extendsfile") {

}
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options, or babel.config.js/config file options`);
}
const validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || BABELRC_VALIDATORS[key] || ROOT_VALIDATORS[key] || throwUnknownError;

@@ -127,6 +121,4 @@ validator(optLoc, opts[key]);

}
function throwUnknownError(loc) {
const key = loc.name;
if (_removed.default[key]) {

@@ -144,7 +136,5 @@ const {

}
function has(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
function assertNoDuplicateSourcemap(opts) {

@@ -155,3 +145,2 @@ if (has(opts, "sourceMap") && has(opts, "sourceMaps")) {

}
function assertEnvSet(loc, value) {

@@ -161,6 +150,4 @@ if (loc.parent.type === "env") {

}
const parent = loc.parent;
const obj = (0, _optionAssertions.assertObject)(loc, value);
if (obj) {

@@ -178,6 +165,4 @@ for (const envName of Object.keys(obj)) {

}
return obj;
}
function assertOverridesList(loc, value) {

@@ -187,10 +172,7 @@ if (loc.parent.type === "env") {

}
if (loc.parent.type === "overrides") {
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .overrides block`);
}
const parent = loc.parent;
const arr = (0, _optionAssertions.assertArray)(loc, value);
if (arr) {

@@ -209,6 +191,4 @@ for (const [index, item] of arr.entries()) {

}
return arr;
}
function checkNoUnwrappedItemOptionPairs(items, index, type, e) {

@@ -218,3 +198,2 @@ if (index === 0) return;

const thisItem = items[index];
if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") {

@@ -224,3 +203,4 @@ e.message += `\n- Maybe you meant to use\n` + `"${type}s": [\n ["${lastItem.file.request}", ${JSON.stringify(thisItem.value, undefined, 2)}]\n]\n` + `To be a valid ${type}, its name and options should be wrapped in a pair of brackets`;

}
0 && 0;
0 && 0;
//# sourceMappingURL=options.js.map

@@ -7,5 +7,3 @@ "use strict";

exports.validatePluginObject = validatePluginObject;
var _optionAssertions = require("./option-assertions");
const VALIDATORS = {

@@ -21,9 +19,6 @@ name: _optionAssertions.assertString,

};
function assertVisitorMap(loc, value) {
const obj = (0, _optionAssertions.assertObject)(loc, value);
if (obj) {
Object.keys(obj).forEach(prop => assertVisitorHandler(prop, obj[prop]));
if (obj.enter || obj.exit) {

@@ -33,6 +28,4 @@ throw new Error(`${(0, _optionAssertions.msg)(loc)} cannot contain catch-all "enter" or "exit" handlers. Please target individual nodes.`);

}
return obj;
}
function assertVisitorHandler(key, value) {

@@ -48,6 +41,4 @@ if (value && typeof value === "object") {

}
return value;
}
function validatePluginObject(obj) {

@@ -60,3 +51,2 @@ const rootPath = {

const validator = VALIDATORS[key];
if (validator) {

@@ -77,3 +67,4 @@ const optLoc = {

}
0 && 0;
0 && 0;
//# sourceMappingURL=plugins.js.map

@@ -67,2 +67,4 @@ "use strict";

exports.default = _default;
0 && 0;
0 && 0;
//# sourceMappingURL=removed.js.map

@@ -11,19 +11,14 @@ "use strict";

exports.waitFor = exports.onFirstPause = void 0;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
const id = x => x;
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
const runGenerator = _gensync()(function* (item) {
return yield* item;
});
const isAsync = _gensync()({

@@ -33,5 +28,3 @@ sync: () => false,

});
exports.isAsync = isAsync;
function maybeAsync(fn, message) {

@@ -44,18 +37,20 @@ return _gensync()({

},
async(...args) {
return Promise.resolve(fn.apply(this, args));
}
});
}
const withKind = _gensync()({
sync: cb => cb("sync"),
async: cb => cb("async")
async: function () {
var _ref = _asyncToGenerator(function* (cb) {
return cb("async");
});
return function async(_x) {
return _ref.apply(this, arguments);
};
}()
});
function forwardAsync(action, cb) {
const g = _gensync()(action);
return withKind(kind => {

@@ -66,3 +61,2 @@ const adapted = g[kind];

}
const onFirstPause = _gensync()({

@@ -80,3 +74,2 @@ name: "onFirstPause",

});
if (!completed) {

@@ -87,16 +80,20 @@ firstPause();

});
exports.onFirstPause = onFirstPause;
const waitFor = _gensync()({
sync: id,
async: id
sync: x => x,
async: function () {
var _ref2 = _asyncToGenerator(function* (x) {
return x;
});
return function async(_x2) {
return _ref2.apply(this, arguments);
};
}()
});
exports.waitFor = waitFor;
function isThenable(val) {
return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
}
0 && 0;
0 && 0;
//# sourceMappingURL=async.js.map

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

exports.stat = exports.readFile = void 0;
function _fs() {
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
const readFile = _gensync()({

@@ -33,5 +26,3 @@ sync: _fs().readFileSync,

});
exports.readFile = readFile;
const stat = _gensync()({

@@ -41,4 +32,5 @@ sync: _fs().statSync,

});
exports.stat = stat;
0 && 0;
exports.stat = stat;
0 && 0;
//# sourceMappingURL=fs.js.map

@@ -13,4 +13,2 @@ "use strict";

});
exports.OptionManager = void 0;
exports.Plugin = Plugin;
Object.defineProperty(exports, "buildExternalHelpers", {

@@ -185,21 +183,13 @@ enumerable: true,

exports.version = exports.types = void 0;
var _file = require("./transformation/file/file");
var _buildExternalHelpers = require("./tools/build-external-helpers");
var _files = require("./config/files");
var _environment = require("./config/helpers/environment");
function _types() {
const data = require("@babel/types");
_types = function () {
return data;
};
return data;
}
Object.defineProperty((0, exports), "types", {

@@ -211,61 +201,48 @@ enumerable: true,

});
function _parser() {
const data = require("@babel/parser");
_parser = function () {
return data;
};
return data;
}
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
function _template() {
const data = require("@babel/template");
_template = function () {
return data;
};
return data;
}
var _config = require("./config");
var _transform = require("./transform");
var _transformFile = require("./transform-file");
var _transformAst = require("./transform-ast");
var _parse = require("./parse");
const version = "7.18.6";
var thisFile = require("./index");
const version = "7.22.1";
exports.version = version;
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]);
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
class OptionManager {
init(opts) {
return (0, _config.loadOptionsSync)(opts);
;
{
{
exports.OptionManager = class OptionManager {
init(opts) {
return (0, _config.loadOptionsSync)(opts);
}
};
exports.Plugin = function Plugin(alias) {
throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`);
};
}
}
0 && (exports.types = exports.traverse = exports.tokTypes = exports.template = 0);
exports.OptionManager = OptionManager;
function Plugin(alias) {
throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`);
}
0 && (exports.types = exports.traverse = exports.tokTypes = exports.template = 0);
//# sourceMappingURL=index.js.map

@@ -6,30 +6,23 @@ "use strict";

});
exports.parseSync = exports.parseAsync = exports.parse = void 0;
exports.parse = void 0;
exports.parseAsync = parseAsync;
exports.parseSync = parseSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = require("./config");
var _parser = require("./parser");
var _normalizeOpts = require("./transformation/normalize-opts");
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
const parseRunner = _gensync()(function* parse(code, opts) {
const config = yield* (0, _config.default)(opts);
if (config === null) {
return null;
}
return yield* (0, _parser.default)(config.passes, (0, _normalizeOpts.default)(config), code);
});
const parse = function parse(code, opts, callback) {

@@ -40,17 +33,18 @@ if (typeof opts === "function") {

}
if (callback === undefined) {
{
return parseRunner.sync(code, opts);
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(code, opts);
}
}
parseRunner.errback(code, opts, callback);
(0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.errback)(code, opts, callback);
};
exports.parse = parse;
function parseSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(...args);
}
function parseAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.async)(...args);
}
0 && 0;
exports.parse = parse;
const parseSync = parseRunner.sync;
exports.parseSync = parseSync;
const parseAsync = parseRunner.async;
exports.parseAsync = parseAsync;
0 && 0;
//# sourceMappingURL=parse.js.map

@@ -7,25 +7,17 @@ "use strict";

exports.default = parser;
function _parser() {
const data = require("@babel/parser");
_parser = function () {
return data;
};
return data;
}
function _codeFrame() {
const data = require("@babel/code-frame");
_codeFrame = function () {
return data;
};
return data;
}
var _missingPluginHelper = require("./util/missing-plugin-helper");
function* parser(pluginPasses, {

@@ -38,3 +30,2 @@ parserOpts,

const results = [];
for (const plugins of pluginPasses) {

@@ -45,3 +36,2 @@ for (const plugin of plugins) {

} = plugin;
if (parserOverride) {

@@ -53,3 +43,2 @@ const ast = parserOverride(code, parserOpts, _parser().parse);

}
if (results.length === 0) {

@@ -59,10 +48,7 @@ return (0, _parser().parse)(code, parserOpts);

yield* [];
if (typeof results[0].then === "function") {
throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);
}
return results[0];
}
throw new Error("More than one plugin attempted to override parsing.");

@@ -73,3 +59,2 @@ } catch (err) {

}
const {

@@ -79,3 +64,2 @@ loc,

} = err;
if (loc) {

@@ -90,3 +74,2 @@ const codeFrame = (0, _codeFrame().codeFrameColumns)(code, {

});
if (missingPlugin) {

@@ -97,10 +80,9 @@ err.message = `${filename}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame);

}
err.code = "BABEL_PARSE_ERROR";
}
throw err;
}
}
0 && 0;
0 && 0;
//# sourceMappingURL=index.js.map

@@ -14,42 +14,2 @@ "use strict";

},
classProperties: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-proposal-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
}
},
classPrivateProperties: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-proposal-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-class-properties"
}
},
classPrivateMethods: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-proposal-private-methods",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-methods"
}
},
classStaticBlock: {
syntax: {
name: "@babel/plugin-syntax-class-static-block",
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-class-static-block"
},
transform: {
name: "@babel/plugin-proposal-class-static-block",
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-proposal-class-static-block"
}
},
decimal: {

@@ -81,8 +41,2 @@ syntax: {

},
dynamicImport: {
syntax: {
name: "@babel/plugin-syntax-dynamic-import",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-dynamic-import"
}
},
exportDefaultFrom: {

@@ -98,12 +52,2 @@ syntax: {

},
exportNamespaceFrom: {
syntax: {
name: "@babel/plugin-syntax-export-namespace-from",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-namespace-from"
},
transform: {
name: "@babel/plugin-proposal-export-namespace-from",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-namespace-from"
}
},
flow: {

@@ -139,8 +83,2 @@ syntax: {

},
importMeta: {
syntax: {
name: "@babel/plugin-syntax-import-meta",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-meta"
}
},
jsx: {

@@ -156,34 +94,8 @@ syntax: {

},
importAssertions: {
importAttributes: {
syntax: {
name: "@babel/plugin-syntax-import-assertions",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions"
name: "@babel/plugin-syntax-import-attributes",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes"
}
},
moduleStringNames: {
syntax: {
name: "@babel/plugin-syntax-module-string-names",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-module-string-names"
}
},
numericSeparator: {
syntax: {
name: "@babel/plugin-syntax-numeric-separator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-numeric-separator"
},
transform: {
name: "@babel/plugin-proposal-numeric-separator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-numeric-separator"
}
},
optionalChaining: {
syntax: {
name: "@babel/plugin-syntax-optional-chaining",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-chaining"
},
transform: {
name: "@babel/plugin-proposal-optional-chaining",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-optional-chaining"
}
},
pipelineOperator: {

@@ -199,12 +111,2 @@ syntax: {

},
privateIn: {
syntax: {
name: "@babel/plugin-syntax-private-property-in-object",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-private-property-in-object"
},
transform: {
name: "@babel/plugin-proposal-private-property-in-object",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-property-in-object"
}
},
recordAndTuple: {

@@ -216,12 +118,2 @@ syntax: {

},
regexpUnicodeSets: {
syntax: {
name: "@babel/plugin-syntax-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-syntax-unicode-sets-regex/README.md"
},
transform: {
name: "@babel/plugin-proposal-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-proposalunicode-sets-regex/README.md"
}
},
throwExpressions: {

@@ -246,56 +138,172 @@ syntax: {

}
},
asyncGenerators: {
syntax: {
name: "@babel/plugin-syntax-async-generators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-generators"
}
};
{
Object.assign(pluginNameMap, {
asyncGenerators: {
syntax: {
name: "@babel/plugin-syntax-async-generators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-generators"
},
transform: {
name: "@babel/plugin-transform-async-generator-functions",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-async-generator-functions"
}
},
transform: {
name: "@babel/plugin-proposal-async-generator-functions",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-async-generator-functions"
}
},
logicalAssignment: {
syntax: {
name: "@babel/plugin-syntax-logical-assignment-operators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-logical-assignment-operators"
classProperties: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-transform-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-class-properties"
}
},
transform: {
name: "@babel/plugin-proposal-logical-assignment-operators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-logical-assignment-operators"
}
},
nullishCoalescingOperator: {
syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-nullish-coalescing-operator"
classPrivateProperties: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-transform-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-class-properties"
}
},
transform: {
name: "@babel/plugin-proposal-nullish-coalescing-operator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-nullish-coalescing-opearator"
}
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-object-rest-spread"
classPrivateMethods: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-class-properties"
},
transform: {
name: "@babel/plugin-transform-private-methods",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-private-methods"
}
},
transform: {
name: "@babel/plugin-proposal-object-rest-spread",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-object-rest-spread"
}
},
optionalCatchBinding: {
syntax: {
name: "@babel/plugin-syntax-optional-catch-binding",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-catch-binding"
classStaticBlock: {
syntax: {
name: "@babel/plugin-syntax-class-static-block",
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-syntax-class-static-block"
},
transform: {
name: "@babel/plugin-transform-class-static-block",
url: "https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-class-static-block"
}
},
transform: {
name: "@babel/plugin-proposal-optional-catch-binding",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-optional-catch-binding"
dynamicImport: {
syntax: {
name: "@babel/plugin-syntax-dynamic-import",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-dynamic-import"
}
},
exportNamespaceFrom: {
syntax: {
name: "@babel/plugin-syntax-export-namespace-from",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-namespace-from"
},
transform: {
name: "@babel/plugin-transform-export-namespace-from",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-export-namespace-from"
}
},
importAssertions: {
syntax: {
name: "@babel/plugin-syntax-import-assertions",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-assertions"
}
},
importMeta: {
syntax: {
name: "@babel/plugin-syntax-import-meta",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-meta"
}
},
logicalAssignment: {
syntax: {
name: "@babel/plugin-syntax-logical-assignment-operators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-logical-assignment-operators"
},
transform: {
name: "@babel/plugin-transform-logical-assignment-operators",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-logical-assignment-operators"
}
},
moduleStringNames: {
syntax: {
name: "@babel/plugin-syntax-module-string-names",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-module-string-names"
}
},
numericSeparator: {
syntax: {
name: "@babel/plugin-syntax-numeric-separator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-numeric-separator"
},
transform: {
name: "@babel/plugin-transform-numeric-separator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-numeric-separator"
}
},
nullishCoalescingOperator: {
syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-nullish-coalescing-operator"
},
transform: {
name: "@babel/plugin-transform-nullish-coalescing-operator",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-nullish-coalescing-opearator"
}
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-object-rest-spread"
},
transform: {
name: "@babel/plugin-transform-object-rest-spread",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-object-rest-spread"
}
},
optionalCatchBinding: {
syntax: {
name: "@babel/plugin-syntax-optional-catch-binding",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-catch-binding"
},
transform: {
name: "@babel/plugin-transform-optional-catch-binding",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-optional-catch-binding"
}
},
optionalChaining: {
syntax: {
name: "@babel/plugin-syntax-optional-chaining",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-optional-chaining"
},
transform: {
name: "@babel/plugin-transform-optional-chaining",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-optional-chaining"
}
},
privateIn: {
syntax: {
name: "@babel/plugin-syntax-private-property-in-object",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-private-property-in-object"
},
transform: {
name: "@babel/plugin-transform-private-property-in-object",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-transform-private-property-in-object"
}
},
regexpUnicodeSets: {
syntax: {
name: "@babel/plugin-syntax-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-syntax-unicode-sets-regex/README.md"
},
transform: {
name: "@babel/plugin-transform-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-proposalunicode-sets-regex/README.md"
}
}
}
};
pluginNameMap.privateIn.syntax = pluginNameMap.privateIn.transform;
});
}
const getNameURLCombination = ({

@@ -305,7 +313,5 @@ name,

}) => `${name} (${url})`;
function generateMissingPluginMessage(missingPluginName, loc, codeFrame) {
let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame;
const pluginInfo = pluginNameMap[missingPluginName];
if (pluginInfo) {

@@ -316,6 +322,4 @@ const {

} = pluginInfo;
if (syntaxPlugin) {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
if (transformPlugin) {

@@ -331,6 +335,6 @@ const transformPluginInfo = getNameURLCombination(transformPlugin);

}
return helpMessage;
}
0 && 0;
0 && 0;
//# sourceMappingURL=missing-plugin-helper.js.map

@@ -7,45 +7,31 @@ "use strict";

exports.default = _default;
function helpers() {
const data = require("@babel/helpers");
helpers = function () {
return data;
};
return data;
}
function _generator() {
const data = require("@babel/generator");
_generator = function () {
return data;
};
return data;
}
function _template() {
const data = require("@babel/template");
_template = function () {
return data;
};
return data;
}
function _t() {
const data = require("@babel/types");
_t = function () {
return data;
};
return data;
}
var _file = require("../transformation/file/file");
const {

@@ -72,3 +58,2 @@ arrayExpression,

} = _t();
const buildUmdWrapper = replacements => _template().default.statement`

@@ -87,3 +72,2 @@ (function (root, factory) {

`(replacements);
function buildGlobal(allowlist) {

@@ -98,3 +82,2 @@ const namespace = identifier("babelHelpers");

}
function buildModule(allowlist) {

@@ -108,3 +91,2 @@ const body = [];

}
function buildUmd(allowlist) {

@@ -124,3 +106,2 @@ const namespace = identifier("babelHelpers");

}
function buildVar(allowlist) {

@@ -135,3 +116,2 @@ const namespace = identifier("babelHelpers");

}
function buildHelpers(body, namespace, allowlist) {

@@ -141,3 +121,2 @@ const getHelperReference = name => {

};
const refs = {};

@@ -155,3 +134,2 @@ helpers().list.forEach(function (name) {

}
function _default(allowlist, outputType = "global") {

@@ -165,3 +143,2 @@ let tree;

}[outputType];
if (build) {

@@ -172,6 +149,6 @@ tree = build(allowlist);

}
return (0, _generator().default)(tree).code;
}
0 && 0;
0 && 0;
//# sourceMappingURL=build-external-helpers.js.map

@@ -6,18 +6,15 @@ "use strict";

});
exports.transformFromAstSync = exports.transformFromAstAsync = exports.transformFromAst = void 0;
exports.transformFromAst = void 0;
exports.transformFromAstAsync = transformFromAstAsync;
exports.transformFromAstSync = transformFromAstSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = require("./config");
var _transformation = require("./transformation");
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
const transformFromAstRunner = _gensync()(function* (ast, code, opts) {

@@ -29,7 +26,5 @@ const config = yield* (0, _config.default)(opts);

});
const transformFromAst = function transformFromAst(ast, code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {

@@ -42,17 +37,18 @@ callback = optsOrCallback;

}
if (callback === undefined) {
{
return transformFromAstRunner.sync(ast, code, opts);
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(ast, code, opts);
}
}
transformFromAstRunner.errback(ast, code, opts, callback);
(0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.errback)(ast, code, opts, callback);
};
exports.transformFromAst = transformFromAst;
function transformFromAstSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.sync)(...args);
}
function transformFromAstAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformFromAstRunner.async)(...args);
}
0 && 0;
exports.transformFromAst = transformFromAst;
const transformFromAstSync = transformFromAstRunner.sync;
exports.transformFromAstSync = transformFromAstSync;
const transformFromAstAsync = transformFromAstRunner.async;
exports.transformFromAstAsync = transformFromAstAsync;
0 && 0;
//# sourceMappingURL=transform-ast.js.map

@@ -9,3 +9,2 @@ "use strict";

exports.transformFileSync = transformFileSync;
const transformFile = function transformFile(filename, opts, callback) {

@@ -15,16 +14,13 @@ if (typeof opts === "function") {

}
callback(new Error("Transforming files is not supported in browsers"), null);
};
exports.transformFile = transformFile;
function transformFileSync() {
throw new Error("Transforming files is not supported in browsers");
}
function transformFileAsync() {
return Promise.reject(new Error("Transforming files is not supported in browsers"));
}
0 && 0;
0 && 0;
//# sourceMappingURL=transform-file-browser.js.map

@@ -6,22 +6,16 @@ "use strict";

});
exports.transformFileSync = exports.transformFileAsync = exports.transformFile = void 0;
exports.transformFile = transformFile;
exports.transformFileAsync = transformFileAsync;
exports.transformFileSync = transformFileSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = require("./config");
var _transformation = require("./transformation");
var fs = require("./gensync-utils/fs");
({});
const transformFileRunner = _gensync()(function* (filename, opts) {

@@ -36,9 +30,13 @@ const options = Object.assign({}, opts, {

});
function transformFile(...args) {
transformFileRunner.errback(...args);
}
function transformFileSync(...args) {
return transformFileRunner.sync(...args);
}
function transformFileAsync(...args) {
return transformFileRunner.async(...args);
}
0 && 0;
const transformFile = transformFileRunner.errback;
exports.transformFile = transformFile;
const transformFileSync = transformFileRunner.sync;
exports.transformFileSync = transformFileSync;
const transformFileAsync = transformFileRunner.async;
exports.transformFileAsync = transformFileAsync;
0 && 0;
//# sourceMappingURL=transform-file.js.map

@@ -6,18 +6,15 @@ "use strict";

});
exports.transformSync = exports.transformAsync = exports.transform = void 0;
exports.transform = void 0;
exports.transformAsync = transformAsync;
exports.transformSync = transformSync;
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = require("./config");
var _transformation = require("./transformation");
var _rewriteStackTrace = require("./errors/rewrite-stack-trace");
const transformRunner = _gensync()(function* transform(code, opts) {

@@ -28,7 +25,5 @@ const config = yield* (0, _config.default)(opts);

});
const transform = function transform(code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {

@@ -41,17 +36,18 @@ callback = optsOrCallback;

}
if (callback === undefined) {
{
return transformRunner.sync(code, opts);
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts);
}
}
transformRunner.errback(code, opts, callback);
(0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.errback)(code, opts, callback);
};
exports.transform = transform;
function transformSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(...args);
}
function transformAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.async)(...args);
}
0 && 0;
exports.transform = transform;
const transformSync = transformRunner.sync;
exports.transformSync = transformSync;
const transformAsync = transformRunner.async;
exports.transformAsync = transformAsync;
0 && 0;
//# sourceMappingURL=transform.js.map

@@ -7,17 +7,38 @@ "use strict";

exports.default = loadBlockHoistPlugin;
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
var _plugin = require("../config/plugin");
let LOADED_PLUGIN;
const blockHoistPlugin = {
name: "internal.blockHoist",
visitor: {
Block: {
exit({
node
}) {
const {
body
} = node;
let max = Math.pow(2, 30) - 1;
let hasChange = false;
for (let i = 0; i < body.length; i++) {
const n = body[i];
const p = priority(n);
if (p > max) {
hasChange = true;
break;
}
max = p;
}
if (!hasChange) return;
node.body = stableSort(body.slice());
}
}
}
};
function loadBlockHoistPlugin() {

@@ -29,6 +50,4 @@ if (!LOADED_PLUGIN) {

}
return LOADED_PLUGIN;
}
function priority(bodyNode) {

@@ -40,6 +59,4 @@ const priority = bodyNode == null ? void 0 : bodyNode._blockHoist;

}
function stableSort(body) {
const buckets = Object.create(null);
for (let i = 0; i < body.length; i++) {

@@ -51,9 +68,6 @@ const n = body[i];

}
const keys = Object.keys(buckets).map(k => +k).sort((a, b) => b - a);
let index = 0;
for (const key of keys) {
const bucket = buckets[key];
for (const n of bucket) {

@@ -63,38 +77,6 @@ body[index++] = n;

}
return body;
}
0 && 0;
const blockHoistPlugin = {
name: "internal.blockHoist",
visitor: {
Block: {
exit({
node
}) {
const {
body
} = node;
let max = Math.pow(2, 30) - 1;
let hasChange = false;
for (let i = 0; i < body.length; i++) {
const n = body[i];
const p = priority(n);
if (p > max) {
hasChange = true;
break;
}
max = p;
}
if (!hasChange) return;
node.body = stableSort(body.slice());
}
}
}
};
0 && 0;
//# sourceMappingURL=block-hoist-plugin.js.map

@@ -7,63 +7,44 @@ "use strict";

exports.default = void 0;
function helpers() {
const data = require("@babel/helpers");
helpers = function () {
return data;
};
return data;
}
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
function _codeFrame() {
const data = require("@babel/code-frame");
_codeFrame = function () {
return data;
};
return data;
}
function _t() {
const data = require("@babel/types");
_t = function () {
return data;
};
return data;
}
function _helperModuleTransforms() {
const data = require("@babel/helper-module-transforms");
_helperModuleTransforms = function () {
return data;
};
return data;
}
function _semver() {
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
const {

@@ -73,7 +54,5 @@ cloneNode,

} = _t();
const errorVisitor = {
enter(path, state) {
const loc = path.node.loc;
if (loc) {

@@ -84,5 +63,3 @@ state.loc = loc;

}
};
class File {

@@ -123,3 +100,2 @@ constructor(options, {

}
get shebang() {

@@ -131,3 +107,2 @@ const {

}
set shebang(value) {

@@ -140,3 +115,2 @@ if (value) {

}
set(key, val) {

@@ -146,25 +120,18 @@ if (key === "helpersNamespace") {

}
this._map.set(key, val);
}
get(key) {
return this._map.get(key);
}
has(key) {
return this._map.has(key);
}
getModuleName() {
return (0, _helperModuleTransforms().getModuleName)(this.opts, this.opts);
}
addImport() {
throw new Error("This API has been removed. If you're looking for this " + "functionality in Babel 7, you should import the " + "'@babel/helper-module-imports' module and use the functions exposed " + " from that module, such as 'addNamed' or 'addDefault'.");
}
availableHelper(name, versionRange) {
let minVersion;
try {

@@ -176,3 +143,2 @@ minVersion = helpers().minVersion(name);

}
if (typeof versionRange !== "string") return true;

@@ -182,3 +148,2 @@ if (_semver().valid(versionRange)) versionRange = `^${versionRange}`;

}
addHelper(name) {

@@ -188,3 +153,2 @@ const declar = this.declarations[name];

const generator = this.get("helperGenerator");
if (generator) {

@@ -194,11 +158,8 @@ const res = generator(name);

}
helpers().ensure(name, File);
const uid = this.declarations[name] = this.scope.generateUidIdentifier(name);
const dependencies = {};
for (const dep of helpers().getDependencies(name)) {
dependencies[dep] = this.addHelper(dep);
}
const {

@@ -223,10 +184,7 @@ nodes,

}
addTemplateObject() {
throw new Error("This function has been moved into the template literal transform itself.");
}
buildCodeFrameError(node, msg, _Error = SyntaxError) {
let loc = node && (node.loc || node._loc);
if (!loc && node) {

@@ -242,3 +200,2 @@ const state = {

}
if (loc) {

@@ -261,9 +218,8 @@ const {

}
return new _Error(msg);
}
}
exports.default = File;
0 && 0;
exports.default = File;
0 && 0;
//# sourceMappingURL=file.js.map

@@ -7,25 +7,17 @@ "use strict";

exports.default = generateCode;
function _convertSourceMap() {
const data = require("convert-source-map");
_convertSourceMap = function () {
return data;
};
return data;
}
function _generator() {
const data = require("@babel/generator");
_generator = function () {
return data;
};
return data;
}
var _mergeMap = require("./merge-map");
function generateCode(pluginPasses, file) {

@@ -41,4 +33,4 @@ const {

} = opts;
generatorOpts.inputSourceMap = inputMap == null ? void 0 : inputMap.toObject();
const results = [];
for (const plugins of pluginPasses) {

@@ -49,3 +41,2 @@ for (const plugin of plugins) {

} = plugin;
if (generatorOverride) {

@@ -57,5 +48,3 @@ const result = generatorOverride(ast, generatorOpts, code, _generator().default);

}
let result;
if (results.length === 0) {

@@ -65,3 +54,2 @@ result = (0, _generator().default)(ast, generatorOpts, code);

result = results[0];
if (typeof result.then === "function") {

@@ -73,3 +61,2 @@ throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`);

}
let {

@@ -79,19 +66,19 @@ code: outputCode,

} = result;
if (outputMap) {
if (inputMap) {
outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap, generatorOpts.sourceFileName);
} else {
outputMap = result.map;
if (result.__mergedMap) {
outputMap = Object.assign({}, result.map);
} else {
if (outputMap) {
if (inputMap) {
outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap, generatorOpts.sourceFileName);
} else {
outputMap = result.map;
}
}
}
if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") {
outputCode += "\n" + _convertSourceMap().fromObject(outputMap).toComment();
}
if (opts.sourceMaps === "inline") {
outputMap = null;
}
return {

@@ -102,3 +89,4 @@ outputCode,

}
0 && 0;
0 && 0;
//# sourceMappingURL=generate.js.map

@@ -7,17 +7,12 @@ "use strict";

exports.default = mergeSourceMap;
function _remapping() {
const data = require("@ampproject/remapping");
_remapping = function () {
return data;
};
return data;
}
function mergeSourceMap(inputMap, map, sourceFileName) {
const source = sourceFileName.replace(/\\/g, "/");
let found = false;
const result = _remapping()(rootless(map), (s, ctx) => {

@@ -29,13 +24,9 @@ if (s === source && !found) {

}
return null;
});
if (typeof inputMap.sourceRoot === "string") {
result.sourceRoot = inputMap.sourceRoot;
}
return Object.assign({}, result);
}
function rootless(map) {

@@ -46,3 +37,4 @@ return Object.assign({}, map, {

}
0 && 0;
0 && 0;
//# sourceMappingURL=merge-map.js.map

@@ -7,29 +7,18 @@ "use strict";

exports.run = run;
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
var _pluginPass = require("./plugin-pass");
var _blockHoistPlugin = require("./block-hoist-plugin");
var _normalizeOpts = require("./normalize-opts");
var _normalizeFile = require("./normalize-file");
var _generate = require("./file/generate");
var _deepArray = require("../config/helpers/deep-array");
function* run(config, code, ast) {
const file = yield* (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast);
const opts = file.opts;
try {

@@ -39,14 +28,9 @@ yield* transformFile(file, config.passes);

var _opts$filename;
e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown"}: ${e.message}`;
e.message = `${(_opts$filename = opts.filename) != null ? _opts$filename : "unknown file"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_TRANSFORM_ERROR";
}
throw e;
}
let outputCode, outputMap;
try {

@@ -61,12 +45,8 @@ if (opts.code !== false) {

var _opts$filename2;
e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown"}: ${e.message}`;
e.message = `${(_opts$filename2 = opts.filename) != null ? _opts$filename2 : "unknown file"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_GENERATE_ERROR";
}
throw e;
}
return {

@@ -82,3 +62,2 @@ metadata: file.metadata,

}
function* transformFile(file, pluginPasses) {

@@ -89,3 +68,2 @@ for (const pluginPairs of pluginPasses) {

const visitors = [];
for (const plugin of pluginPairs.concat([(0, _blockHoistPlugin.default)()])) {

@@ -97,10 +75,7 @@ const pass = new _pluginPass.default(file, plugin.key, plugin.options);

}
for (const [plugin, pass] of passPairs) {
const fn = plugin.pre;
if (fn) {
const result = fn.call(pass, file);
yield* [];
if (isThenable(result)) {

@@ -111,14 +86,9 @@ throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);

}
const visitor = _traverse().default.visitors.merge(visitors, passes, file.opts.wrapPluginVisitorMethod);
(0, _traverse().default)(file.ast, visitor, file.scope);
for (const [plugin, pass] of passPairs) {
const fn = plugin.post;
if (fn) {
const result = fn.call(pass, file);
yield* [];
if (isThenable(result)) {

@@ -131,7 +101,7 @@ throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`);

}
function isThenable(val) {
return !!val && (typeof val === "object" || typeof val === "function") && !!val.then && typeof val.then === "function";
}
0 && 0;
0 && 0;
//# sourceMappingURL=index.js.map

@@ -7,59 +7,40 @@ "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() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
function _t() {
const data = require("@babel/types");
_t = function () {
return data;
};
return data;
}
function _convertSourceMap() {
const data = require("convert-source-map");
_convertSourceMap = function () {
return data;
};
return data;
}
var _file = require("./file/file");
var _parser = require("../parser");
var _cloneDeep = require("./util/clone-deep");
const {

@@ -69,10 +50,7 @@ file,

} = _t();
const debug = _debug()("babel:transform:file");
const LARGE_INPUT_SOURCEMAP_THRESHOLD = 3000000;
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
function* normalizeFile(pluginPasses, options, code, ast) {
code = `${code || ""}`;
if (ast) {

@@ -84,3 +62,2 @@ if (ast.type === "Program") {

}
if (options.cloneInputAst) {

@@ -92,5 +69,3 @@ ast = (0, _cloneDeep.default)(ast);

}
let inputMap = null;
if (options.inputSourceMap !== false) {

@@ -100,6 +75,4 @@ if (typeof options.inputSourceMap === "object") {

}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {

@@ -113,17 +86,9 @@ try {

}
if (!inputMap) {
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
if (typeof options.filename === "string" && lastComment) {
try {
const match = EXTERNAL_SOURCEMAP_REGEX.exec(lastComment);
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]));
if (inputMapContent.length > LARGE_INPUT_SOURCEMAP_THRESHOLD) {
debug("skip merging input map > 1 MB");
} else {
inputMap = _convertSourceMap().fromJSON(inputMapContent);
}
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]), "utf8");
inputMap = _convertSourceMap().fromJSON(inputMapContent);
} catch (err) {

@@ -137,13 +102,8 @@ debug("discarding unknown file input sourcemap", err);

}
return new _file.default(options, {
code,
ast,
ast: ast,
inputMap
});
}
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+)[ \t]*$/;
function extractCommentsFromList(regex, comments, lastComment) {

@@ -158,10 +118,7 @@ if (comments) {

}
return true;
});
}
return [comments, lastComment];
}
function extractComments(regex, ast) {

@@ -176,3 +133,4 @@ let lastComment = null;

}
0 && 0;
0 && 0;
//# sourceMappingURL=normalize-file.js.map

@@ -7,13 +7,9 @@ "use strict";

exports.default = normalizeOptions;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function normalizeOptions(config) {

@@ -53,3 +49,2 @@ const {

});
for (const plugins of config.passes) {

@@ -62,6 +57,6 @@ for (const plugin of plugins) {

}
return options;
}
0 && 0;
0 && 0;
//# sourceMappingURL=normalize-opts.js.map

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

exports.default = void 0;
class PluginPass {

@@ -23,29 +22,18 @@ constructor(file, key, options) {

}
set(key, val) {
this._map.set(key, val);
}
get(key) {
return this._map.get(key);
}
availableHelper(name, versionRange) {
return this.file.availableHelper(name, versionRange);
}
addHelper(name) {
return this.file.addHelper(name);
}
addImport() {
return this.file.addImport();
}
buildCodeFrameError(node, msg, _Error) {
return this.file.buildCodeFrameError(node, msg, _Error);
}
}
exports.default = PluginPass;

@@ -56,3 +44,8 @@ {

};
PluginPass.prototype.addImport = function addImport() {
this.file.addImport();
};
}
0 && 0;
0 && 0;
//# sourceMappingURL=plugin-pass.js.map

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

exports.default = _default;
function deepClone(value, cache) {

@@ -13,6 +12,5 @@ if (value !== null) {

let cloned;
if (Array.isArray(value)) {
cloned = new Array(value.length);
cache.set(value, cloned);
for (let i = 0; i < value.length; i++) {

@@ -23,4 +21,4 @@ cloned[i] = typeof value[i] !== "object" ? value[i] : deepClone(value[i], cache);

cloned = {};
cache.set(value, cloned);
const keys = Object.keys(value);
for (let i = 0; i < keys.length; i++) {

@@ -31,10 +29,6 @@ const key = keys[i];

}
cache.set(value, cloned);
return cloned;
}
return value;
}
function _default(value) {

@@ -44,3 +38,4 @@ if (typeof value !== "object") return value;

}
0 && 0;
0 && 0;
//# sourceMappingURL=clone-deep.js.map
{
"name": "@babel/core",
"version": "7.18.6",
"version": "7.22.1",
"description": "Babel compiler core.",

@@ -49,32 +49,35 @@ "main": "./lib/index.js",

"dependencies": {
"@ampproject/remapping": "^2.1.0",
"@babel/code-frame": "^7.18.6",
"@babel/generator": "^7.18.6",
"@babel/helper-compilation-targets": "^7.18.6",
"@babel/helper-module-transforms": "^7.18.6",
"@babel/helpers": "^7.18.6",
"@babel/parser": "^7.18.6",
"@babel/template": "^7.18.6",
"@babel/traverse": "^7.18.6",
"@babel/types": "^7.18.6",
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.21.4",
"@babel/generator": "^7.22.0",
"@babel/helper-compilation-targets": "^7.22.1",
"@babel/helper-module-transforms": "^7.22.1",
"@babel/helpers": "^7.22.0",
"@babel/parser": "^7.22.0",
"@babel/template": "^7.21.9",
"@babel/traverse": "^7.22.1",
"@babel/types": "^7.22.0",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
"json5": "^2.2.1",
"json5": "^2.2.2",
"semver": "^6.3.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.18.6",
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-flow-strip-types": "^7.18.6",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@jridgewell/trace-mapping": "^0.3.8",
"@babel/helper-transform-fixture-test-runner": "^7.22.0",
"@babel/plugin-syntax-flow": "^7.21.4",
"@babel/plugin-transform-flow-strip-types": "^7.21.0",
"@babel/plugin-transform-modules-commonjs": "^7.21.5",
"@babel/preset-env": "^7.22.1",
"@babel/preset-typescript": "^7.21.5",
"@jridgewell/trace-mapping": "^0.3.17",
"@types/convert-source-map": "^1.5.1",
"@types/debug": "^4.1.0",
"@types/gensync": "^1.0.0",
"@types/resolve": "^1.3.2",
"@types/semver": "^5.4.0",
"rimraf": "^3.0.0"
"rimraf": "^3.0.0",
"ts-node": "^10.9.1"
},
"type": "commonjs"
}

@@ -6,3 +6,3 @@ type indexBrowserType = typeof import("./index-browser");

// exports of index-browser, since this file may be replaced at bundle time with index-browser.
({} as any as indexBrowserType as indexType);
({}) as any as indexBrowserType as indexType;

@@ -25,8 +25,7 @@ export { findPackageData } from "./package";

} from "./types";
export { loadPlugin, loadPreset } from "./plugins";
import gensync from "gensync";
import * as plugins from "./plugins";
export const resolvePlugin = gensync(plugins.resolvePlugin).sync;
export const resolvePreset = gensync(plugins.resolvePreset).sync;
export {
loadPlugin,
loadPreset,
resolvePlugin,
resolvePreset,
} from "./plugins";

@@ -6,3 +6,3 @@ type browserType = typeof import("./resolve-targets-browser");

// exports of index-browser, since this file may be replaced at bundle time with index-browser.
({} as any as browserType as nodeType);
({}) as any as browserType as nodeType;

@@ -9,0 +9,0 @@ import type { ValidatedOptions } from "./validation/options";

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

import gensync from "gensync";
import gensync, { type Handler } from "gensync";

@@ -15,16 +15,8 @@ import loadConfig from "./config";

// transform-file-browser.
({} as any as transformFileBrowserType as transformFileType);
({}) as any as transformFileBrowserType as transformFileType;
type TransformFile = {
(filename: string, callback: FileResultCallback): void;
(
filename: string,
opts: InputOptions | undefined | null,
callback: FileResultCallback,
): void;
};
const transformFileRunner = gensync<
(filename: string, opts?: InputOptions) => FileResult | null
>(function* (filename, opts: InputOptions) {
const transformFileRunner = gensync(function* (
filename: string,
opts?: InputOptions,
): Handler<FileResult | null> {
const options = { ...opts, filename };

@@ -39,4 +31,27 @@

export const transformFile = transformFileRunner.errback as TransformFile;
export const transformFileSync = transformFileRunner.sync;
export const transformFileAsync = transformFileRunner.async;
// @ts-expect-error TS doesn't detect that this signature is compatible
export function transformFile(
filename: string,
callback: FileResultCallback,
): void;
export function transformFile(
filename: string,
opts: InputOptions | undefined | null,
callback: FileResultCallback,
): void;
export function transformFile(
...args: Parameters<typeof transformFileRunner.errback>
) {
transformFileRunner.errback(...args);
}
export function transformFileSync(
...args: Parameters<typeof transformFileRunner.sync>
) {
return transformFileRunner.sync(...args);
}
export function transformFileAsync(
...args: Parameters<typeof transformFileRunner.async>
) {
return transformFileRunner.async(...args);
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.