Socket
Socket
Sign inDemoInstall

@babel/core

Package Overview
Dependencies
Maintainers
4
Versions
191
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/core - npm Package Compare versions

Comparing version 7.9.0 to 7.23.0

cjs-proxy.cjs

93

lib/config/caching.js

@@ -6,48 +6,34 @@ "use strict";

});
exports.assertSimpleType = assertSimpleType;
exports.makeStrongCache = makeStrongCache;
exports.makeStrongCacheSync = makeStrongCacheSync;
exports.makeWeakCache = makeWeakCache;
exports.makeWeakCacheSync = makeWeakCacheSync;
exports.makeStrongCache = makeStrongCache;
exports.makeStrongCacheSync = makeStrongCacheSync;
exports.assertSimpleType = assertSimpleType;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../gensync-utils/async");
var _util = require("./util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _async = require("../gensync-utils/async.js");
var _util = require("./util.js");
const synchronize = gen => {
return (0, _gensync().default)(gen).sync;
return _gensync()(gen).sync;
};
function* genTrue(data) {
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) {

@@ -66,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);

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

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

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

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

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

}
return {

@@ -111,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) {

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

}
return {

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

}
function setupAsyncLocks(config, futureCache, arg) {

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

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

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

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

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

break;
case "invalidate":

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

break;
case "valid":

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

}
}
}
class CacheConfigurator {

@@ -198,9 +164,8 @@ constructor(data) {

this._pairs = [];
this._data = void 0;
this._data = data;
}
simple() {
return makeSimpleConfigurator(this);
}
mode() {

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

}
forever() {

@@ -218,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() {

@@ -232,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) {

@@ -246,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) {

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

}
validator() {

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

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

@@ -303,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) {

@@ -323,13 +261,12 @@ 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 {
constructor() {
this.released = false;
this.promise = void 0;
this._resolve = void 0;
this.promise = new Promise(resolve => {

@@ -339,9 +276,9 @@ this._resolve = resolve;

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

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

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

@@ -51,12 +39,12 @@ const chain = yield* buildPresetChainWalker(arg, context);

presets: dedupDescriptors(chain.presets),
options: chain.options.map(o => normalizeOptions(o))
options: chain.options.map(o => normalizeOptions(o)),
files: new Set()
};
}
const buildPresetChainWalker = makeChainWalker({
init: arg => arg,
root: preset => loadPresetDescriptors(preset),
env: (preset, envName) => loadPresetEnvDescriptors(preset)(envName),
overrides: (preset, index) => loadPresetOverridesDescriptors(preset)(index),
overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName)
overridesEnv: (preset, index, envName) => loadPresetOverridesEnvDescriptors(preset)(index)(envName),
createLogger: () => () => {}
});

@@ -68,17 +56,17 @@ exports.buildPresetChainWalker = buildPresetChainWalker;

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) {
let configReport, babelRcReport;
const programmaticLogger = new _printer.ConfigPrinter();
const programmaticChain = yield* loadProgrammaticChain({
options: opts,
dirname: context.cwd
}, context);
}, context, undefined, programmaticLogger);
if (!programmaticChain) return null;
const programmaticReport = yield* programmaticLogger.output();
let configFile;
if (typeof opts.configFile === "string") {
configFile = yield* (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
configFile = yield* (0, _index.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
} else if (opts.configFile !== false) {
configFile = yield* (0, _files.findRootConfig)(context.root, context.envName, context.caller);
configFile = yield* (0, _index.findRootConfig)(context.root, context.envName, context.caller);
}
let {

@@ -90,12 +78,11 @@ babelrc,

const configFileChain = emptyChain();
const configFileLogger = new _printer.ConfigPrinter();
if (configFile) {
const validatedFile = validateConfigFile(configFile);
const result = yield* loadFileChain(validatedFile, context);
const result = yield* loadFileChain(validatedFile, context, undefined, configFileLogger);
if (!result) return null;
configReport = yield* configFileLogger.output();
if (babelrc === undefined) {
babelrc = validatedFile.options.babelrc;
}
if (babelrcRoots === undefined) {

@@ -105,56 +92,67 @@ babelrcRootsDirectory = validatedFile.dirname;

}
mergeChain(configFileChain, result);
}
const pkgData = typeof context.filename === "string" ? yield* (0, _files.findPackageData)(context.filename) : null;
let ignoreFile, babelrcFile;
let isIgnored = false;
const fileChain = emptyChain();
if ((babelrc === true || babelrc === undefined) && pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
({
ignore: ignoreFile,
config: babelrcFile
} = yield* (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller));
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
return null;
if ((babelrc === true || babelrc === undefined) && typeof context.filename === "string") {
const pkgData = yield* (0, _index.findPackageData)(context.filename);
if (pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
({
ignore: ignoreFile,
config: babelrcFile
} = yield* (0, _index.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) {
const validatedFile = validateBabelrcFile(babelrcFile);
const babelrcLogger = new _printer.ConfigPrinter();
const result = yield* loadFileChain(validatedFile, context, undefined, babelrcLogger);
if (!result) {
isIgnored = true;
} else {
babelRcReport = yield* babelrcLogger.output();
mergeChain(fileChain, result);
}
}
if (babelrcFile && isIgnored) {
fileChain.files.add(babelrcFile.filepath);
}
}
if (babelrcFile) {
const result = yield* loadFileChain(validateBabelrcFile(babelrcFile), context);
if (!result) return null;
mergeChain(fileChain, result);
}
}
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);
return {
plugins: dedupDescriptors(chain.plugins),
presets: dedupDescriptors(chain.presets),
options: chain.options.map(o => normalizeOptions(o)),
plugins: isIgnored ? [] : dedupDescriptors(chain.plugins),
presets: isIgnored ? [] : dedupDescriptors(chain.presets),
options: isIgnored ? [] : chain.options.map(o => normalizeOptions(o)),
fileHandling: isIgnored ? "ignored" : "transpile",
ignore: ignoreFile || undefined,
babelrc: babelrcFile || undefined,
config: configFile || undefined
config: configFile || undefined,
files: chain.files
};
}
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];
if (!Array.isArray(babelrcPatterns)) {
babelrcPatterns = [babelrcPatterns];
}
babelrcPatterns = babelrcPatterns.map(pat => {
return typeof pat === "string" ? _path().default.resolve(babelrcRootsDirectory, pat) : 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 => {

@@ -164,3 +162,2 @@ if (typeof pat === "string") {

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

@@ -171,7 +168,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)
}));

@@ -181,3 +177,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)
}));

@@ -187,3 +183,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)
}));

@@ -194,10 +190,17 @@ const loadProgrammaticChain = makeChainWalker({

overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index),
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName)
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName),
createLogger: (input, context, baseLogger) => buildProgrammaticLogger(input, context, baseLogger)
});
const loadFileChain = makeChainWalker({
const loadFileChainWalker = makeChainWalker({
root: file => loadFileDescriptors(file),
env: (file, envName) => loadFileEnvDescriptors(file)(envName),
overrides: (file, index) => loadFileOverridesDescriptors(file)(index),
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName)
overridesEnv: (file, index, envName) => loadFileOverridesEnvDescriptors(file)(index)(envName),
createLogger: (file, context, baseLogger) => buildFileLogger(file.filepath, context, baseLogger)
});
function* loadFileChain(input, context, files, baseLogger) {
const chain = yield* loadFileChainWalker(input, context, files, baseLogger);
chain == null ? void 0 : chain.files.add(input.filepath);
return chain;
}
const loadFileDescriptors = (0, _caching.makeWeakCacheSync)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));

@@ -207,3 +210,10 @@ 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) {
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Config, {
filepath
});
}
function buildRootDescriptors({

@@ -215,3 +225,11 @@ dirname,

}
function buildProgrammaticLogger(_, context, baseLogger) {
var _context$caller;
if (!baseLogger) {
return () => {};
}
return baseLogger.configure(context.showConfig, _printer.ChainFormatter.Programmatic, {
callerName: (_context$caller = context.caller) == null ? void 0 : _context$caller.name
});
}
function buildEnvDescriptors({

@@ -221,6 +239,6 @@ dirname,

}, alias, descriptors, envName) {
const opts = options.env && options.env[envName];
var _options$env;
const opts = (_options$env = options.env) == null ? void 0 : _options$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
}
function buildOverrideDescriptors({

@@ -230,7 +248,7 @@ dirname,

}, alias, descriptors, index) {
const opts = options.overrides && options.overrides[index];
var _options$overrides;
const opts = (_options$overrides = options.overrides) == null ? void 0 : _options$overrides[index];
if (!opts) throw new Error("Assertion failure - missing override");
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
}
function buildOverrideEnvDescriptors({

@@ -240,8 +258,8 @@ dirname,

}, alias, descriptors, index, envName) {
const override = options.overrides && options.overrides[index];
var _options$overrides2, _override$env;
const override = (_options$overrides2 = options.overrides) == null ? void 0 : _options$overrides2[index];
if (!override) throw new Error("Assertion failure - missing override");
const opts = override.env && override.env[envName];
const opts = (_override$env = override.env) == null ? void 0 : _override$env[envName];
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
}
function makeChainWalker({

@@ -251,5 +269,6 @@ root,

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

@@ -260,20 +279,31 @@ dirname

const rootOpts = root(input);
if (configIsApplicable(rootOpts, dirname, context)) {
flattenedConfigs.push(rootOpts);
if (configIsApplicable(rootOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: rootOpts,
envName: undefined,
index: undefined
});
const envOpts = env(input, context.envName);
if (envOpts && configIsApplicable(envOpts, dirname, context)) {
flattenedConfigs.push(envOpts);
if (envOpts && configIsApplicable(envOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: envOpts,
envName: context.envName,
index: undefined
});
}
(rootOpts.options.overrides || []).forEach((_, index) => {
const overrideOps = overrides(input, index);
if (configIsApplicable(overrideOps, dirname, context)) {
flattenedConfigs.push(overrideOps);
if (configIsApplicable(overrideOps, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideOps,
index,
envName: undefined
});
const overrideEnvOpts = overridesEnv(input, index, context.envName);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context)) {
flattenedConfigs.push(overrideEnvOpts);
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context, input.filepath)) {
flattenedConfigs.push({
config: overrideEnvOpts,
index,
envName: context.envName
});
}

@@ -283,7 +313,8 @@ }

}
if (flattenedConfigs.some(({
options: {
ignore,
only
config: {
options: {
ignore,
only
}
}

@@ -293,27 +324,26 @@ }) => shouldIgnore(context, ignore, only, dirname))) {

}
const chain = emptyChain();
for (const op of flattenedConfigs) {
if (!(yield* mergeExtendsChain(chain, op.options, dirname, context, files))) {
const logger = createLogger(input, context, baseLogger);
for (const {
config,
index,
envName
} of flattenedConfigs) {
if (!(yield* mergeExtendsChain(chain, config.options, dirname, context, files, baseLogger))) {
return null;
}
mergeChainOpts(chain, op);
logger(config, index, envName);
yield* mergeChainOpts(chain, config);
}
return chain;
};
}
function* mergeExtendsChain(chain, opts, dirname, context, files) {
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);
const file = yield* (0, _index.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);
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files);
const fileChain = yield* loadFileChain(validateExtendFile(file), context, files, baseLogger);
files.delete(file);

@@ -324,3 +354,2 @@ if (!fileChain) return false;

}
function mergeChain(target, source) {

@@ -330,6 +359,8 @@ 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, {
function* mergeChainOpts(target, {
options,

@@ -340,7 +371,6 @@ plugins,

target.options.push(options);
target.plugins.push(...plugins());
target.presets.push(...presets());
target.plugins.push(...(yield* plugins()));
target.presets.push(...(yield* presets()));
return target;
}
function emptyChain() {

@@ -350,6 +380,6 @@ return {

presets: [],
plugins: []
plugins: [],
files: new Set()
};
}
function normalizeOptions(opts) {

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

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

@@ -374,10 +403,7 @@ options.sourceMaps = options.sourceMap;

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

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

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

@@ -393,5 +418,3 @@ nameMap = new Map();

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

@@ -412,3 +435,2 @@ desc = {

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

@@ -419,35 +441,44 @@ 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) {
if (value instanceof RegExp) {
return String(value);
}
return value;
}
function shouldIgnore(context, ignore, only, dirname) {
if (ignore && matchesPatterns(context, ignore, dirname)) {
debug("Ignored %o because it matched one of %O from %o", context.filename, 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)) {
debug("Ignored %o because it failed to match one of %O from %o", context.filename, 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,

@@ -458,12 +489,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;
return pattern.test(pathToTest);
}
//# sourceMappingURL=config-chain.js.map

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

exports.createCachedDescriptors = createCachedDescriptors;
exports.createDescriptor = createDescriptor;
exports.createUncachedDescriptors = createUncachedDescriptors;
exports.createDescriptor = createDescriptor;
var _files = require("./files");
var _item = require("./item");
var _caching = require("./caching");
function _gensync() {
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _functional = require("../gensync-utils/functional.js");
var _index = require("./files/index.js");
var _item = require("./item.js");
var _caching = require("./caching.js");
var _resolveTargets = require("./resolve-targets.js");
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);
var _a$file, _b$file, _a$file2, _b$file2;
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) == null ? void 0 : _a$file.request) === ((_b$file = b.file) == null ? void 0 : _b$file.request) && ((_a$file2 = a.file) == null ? void 0 : _a$file2.resolved) === ((_b$file2 = b.file) == null ? void 0 : _b$file2.resolved);
}
function* handlerOf(value) {
return value;
}
function optionsWithResolvedBrowserslistConfigFile(options, dirname) {
if (typeof options.browserslistConfigFile === "string") {
options.browserslistConfigFile = (0, _resolveTargets.resolveBrowserslistConfigFile)(options.browserslistConfigFile, dirname);
}
return options;
}
function createCachedDescriptors(dirname, options, alias) {

@@ -28,34 +42,21 @@ const {

return {
options,
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => [],
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => []
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]),
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([])
};
}
function createUncachedDescriptors(dirname, options, alias) {
let plugins;
let presets;
return {
options,
plugins: () => {
if (!plugins) {
plugins = createPluginDescriptors(options.plugins || [], dirname, alias);
}
return plugins;
},
presets: () => {
if (!presets) {
presets = createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset);
}
return presets;
}
options: optionsWithResolvedBrowserslistConfigFile(options, dirname),
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();
const createCachedPresetDescriptors = (0, _caching.makeWeakCacheSync)((items, cache) => {
const dirname = cache.using(dir => dir);
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCacheSync)(passPerPreset => createPresetDescriptors(items, dirname, alias, passPerPreset).map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc))));
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCache)(function* (passPerPreset) {
const descriptors = yield* createPresetDescriptors(items, dirname, alias, passPerPreset);
return descriptors.map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc));
}));
});

@@ -65,6 +66,8 @@ const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();

const dirname = cache.using(dir => dir);
return (0, _caching.makeStrongCacheSync)(alias => createPluginDescriptors(items, dirname, alias).map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc)));
return (0, _caching.makeStrongCache)(function* (alias) {
const descriptors = yield* createPluginDescriptors(items, dirname, alias);
return descriptors.map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc));
});
});
const DEFAULT_OPTIONS = {};
function loadCachedDescriptor(cache, desc) {

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

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

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

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

@@ -91,35 +91,27 @@ 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 createDescriptors("preset", items, dirname, alias, passPerPreset);
function* createPresetDescriptors(items, dirname, alias, passPerPreset) {
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset);
}
function createPluginDescriptors(items, dirname, alias) {
return createDescriptors("plugin", items, dirname, alias);
function* createPluginDescriptors(items, dirname, alias) {
return yield* createDescriptors("plugin", items, dirname, alias);
}
function createDescriptors(type, items, dirname, alias, ownPass) {
const descriptors = items.map((item, index) => createDescriptor(item, dirname, {
function* createDescriptors(type, items, dirname, alias, ownPass) {
const descriptors = yield* _gensync().all(items.map((item, index) => createDescriptor(item, dirname, {
type,
alias: `${alias}$${index}`,
ownPass: !!ownPass
}));
})));
assertNoDuplicates(descriptors);
return descriptors;
}
function createDescriptor(pair, dirname, {
function* createDescriptor(pair, dirname, {
type,

@@ -130,11 +122,8 @@ alias,

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

@@ -147,6 +136,4 @@ if (value.length === 3) {

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

@@ -156,4 +143,3 @@ if (typeof type !== "string") {

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

@@ -163,3 +149,3 @@ ({

value
} = resolver(value, dirname));
} = yield* resolver(value, dirname));
file = {

@@ -170,7 +156,5 @@ request,

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

@@ -183,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 {

@@ -203,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) {

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

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

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

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

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

});
exports.ROOT_CONFIG_FILENAMES = void 0;
exports.findConfigUpwards = findConfigUpwards;

@@ -11,105 +12,168 @@ exports.findRelativeConfig = findRelativeConfig;

exports.loadConfig = loadConfig;
exports.ROOT_CONFIG_FILENAMES = void 0;
exports.resolveShowConfigPath = resolveShowConfigPath;
function _debug() {
const data = _interopRequireDefault(require("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 = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _json() {
const data = _interopRequireDefault(require("json5"));
const data = require("json5");
_json = function () {
return data;
};
return data;
}
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _caching = require("../caching");
var _configApi = _interopRequireDefault(require("../helpers/config-api"));
var _utils = require("./utils");
var _moduleTypes = _interopRequireDefault(require("./module-types"));
var _patternToRegex = _interopRequireDefault(require("../pattern-to-regex"));
var fs = _interopRequireWildcard(require("../../gensync-utils/fs"));
var _resolve = _interopRequireDefault(require("../../gensync-utils/resolve"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug().default)("babel:config:loading:files:configuration");
const ROOT_CONFIG_FILENAMES = ["babel.config.js", "babel.config.cjs", "babel.config.mjs", "babel.config.json"];
var _caching = require("../caching.js");
var _configApi = require("../helpers/config-api.js");
var _utils = require("./utils.js");
var _moduleTypes = require("./module-types.js");
var _patternToRegex = require("../pattern-to-regex.js");
var _configError = require("../../errors/config-error.js");
var fs = require("../../gensync-utils/fs.js");
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace.js");
const debug = _debug()("babel:config:loading:files:configuration");
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) {
const runConfig = (0, _caching.makeWeakCache)(function* runConfig(options, cache) {
yield* [];
return {
options: (0, _rewriteStackTrace.endHiddenCallStack)(options)((0, _configApi.makeConfigAPI)(cache)),
cacheNeedsConfiguration: !cache.configured()
};
});
function* readConfigCode(filepath, data) {
if (!_fs().existsSync(filepath)) return null;
let 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.");
let cacheNeedsConfiguration = false;
if (typeof options === "function") {
({
options,
cacheNeedsConfiguration
} = yield* runConfig(options, data));
}
if (!options || typeof options !== "object" || Array.isArray(options)) {
throw new _configError.default(`Configuration should be an exported JavaScript object.`, filepath);
}
if (typeof options.then === "function") {
options.catch == null ? void 0 : options.catch(() => {});
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 (cacheNeedsConfiguration) throwConfigError(filepath);
return buildConfigFileObject(options, filepath);
}
const cfboaf = new WeakMap();
function buildConfigFileObject(options, filepath) {
let configFilesByFilepath = cfboaf.get(options);
if (!configFilesByFilepath) {
cfboaf.set(options, configFilesByFilepath = new Map());
}
let configFile = configFilesByFilepath.get(filepath);
if (!configFile) {
configFile = {
filepath,
dirname: _path().dirname(filepath),
options
};
configFilesByFilepath.set(filepath, configFile);
}
return configFile;
}
const packageToBabelConfig = (0, _caching.makeWeakCacheSync)(file => {
const babel = file.options["babel"];
if (typeof babel === "undefined") return null;
if (typeof babel !== "object" || Array.isArray(babel) || babel === null) {
throw new _configError.default(`.babel property must be an object`, file.filepath);
}
return {
filepath: file.filepath,
dirname: file.dirname,
options: babel
};
});
const readConfigJSON5 = (0, _utils.makeStaticFileCache)((filepath, content) => {
let options;
try {
options = _json().parse(content);
} catch (err) {
throw new _configError.default(`Error while parsing config - ${err.message}`, filepath);
}
if (!options) throw new _configError.default(`No config detected`, filepath);
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);
}
delete options["$schema"];
return {
filepath,
dirname: _path().dirname(filepath),
options
};
});
const readIgnoreConfig = (0, _utils.makeStaticFileCache)((filepath, content) => {
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 _configError.default(`Negation of file paths is not supported.`, filepath);
}
}
return {
filepath,
dirname: _path().dirname(filepath),
ignore: ignorePatterns.map(pattern => (0, _patternToRegex.default)(pattern, ignoreDir))
};
});
function findConfigUpwards(rootDir) {
let dirname = rootDir;
while (true) {
for (;;) {
for (const filename of ROOT_CONFIG_FILENAMES) {
if (yield* fs.exists(_path().default.join(dirname, filename))) {
if (_fs().existsSync(_path().join(dirname, filename))) {
return dirname;
}
}
const nextDir = _path().default.dirname(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().default.dirname(packageData.filepath);
const dirname = _path().dirname(packageData.filepath);
for (const loc of packageData.directories) {
if (!config) {
config = yield* loadOneConfig(RELATIVE_CONFIG_FILENAMES, loc, envName, caller, packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) : null);
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().default.join(loc, BABELIGNORE_FILENAME);
const ignoreLoc = _path().join(loc, BABELIGNORE_FILENAME);
ignore = yield* readIgnoreConfig(ignoreLoc);
if (ignore) {

@@ -120,3 +184,2 @@ debug("Found ignore %o from %o.", ignore.filepath, dirname);

}
return {

@@ -127,159 +190,66 @@ config,

}
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().default.all(names.map(filename => readConfig(_path().default.join(dirname, filename), envName, caller)));
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().default.basename(previousConfig.filepath)}\n` + ` - ${config.filepath}\n` + `from ${dirname}`);
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 = yield* (0, _resolve.default)(name, {
basedir: dirname
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`);
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().default.extname(filepath);
return ext === ".js" || ext === ".cjs" || ext === ".mjs" ? readConfigJS(filepath, {
envName,
caller
}) : readConfigJSON5(filepath);
const ext = _path().extname(filepath);
switch (ext) {
case ".js":
case ".cjs":
case ".mjs":
case ".cts":
return readConfigCode(filepath, {
envName,
caller
});
default:
return readConfigJSON5(filepath);
}
}
const LOADING_CONFIGS = new Set();
const readConfigJS = (0, _caching.makeStrongCache)(function* readConfigJS(filepath, cache) {
if (!fs.exists.sync(filepath)) {
cache.forever();
return null;
}
if (LOADING_CONFIGS.has(filepath)) {
cache.never();
debug("Auto-ignoring usage of config %o.", filepath);
return {
filepath,
dirname: _path().default.dirname(filepath),
options: {}
};
}
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.default)(cache));
assertCache = true;
}
if (!options || typeof options !== "object" || Array.isArray(options)) {
throw new Error(`${filepath}: Configuration should be an exported JavaScript object.`);
}
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.`);
}
if (assertCache && !cache.configured()) throwConfigError();
return {
filepath,
dirname: _path().default.dirname(filepath),
options
};
});
const packageToBabelConfig = (0, _caching.makeWeakCacheSync)(file => {
const babel = file.options["babel"];
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`);
}
return {
filepath: file.filepath,
dirname: file.dirname,
options: babel
};
});
const readConfigJSON5 = (0, _utils.makeStaticFileCache)((filepath, content) => {
let options;
try {
options = _json().default.parse(content);
} catch (err) {
err.message = `${filepath}: Error while parsing config - ${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().default.dirname(filepath),
options
};
});
const readIgnoreConfig = (0, _utils.makeStaticFileCache)((filepath, content) => {
const ignoreDir = _path().default.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.`);
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 {
filepath,
dirname: _path().default.dirname(filepath),
ignore: ignorePatterns.map(pattern => (0, _patternToRegex.default)(pattern, ignoreDir))
};
});
function throwConfigError() {
throw new Error(`\
return null;
}
function throwConfigError(filepath) {
throw new _configError.default(`\
Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured

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

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

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

});
exports.ROOT_CONFIG_FILENAMES = void 0;
exports.findConfigUpwards = findConfigUpwards;

@@ -12,12 +13,10 @@ exports.findPackageData = findPackageData;

exports.loadConfig = loadConfig;
exports.loadPlugin = loadPlugin;
exports.loadPreset = loadPreset;
exports.resolvePlugin = resolvePlugin;
exports.resolvePreset = resolvePreset;
exports.loadPlugin = loadPlugin;
exports.loadPreset = loadPreset;
exports.ROOT_CONFIG_FILENAMES = void 0;
function* findConfigUpwards(rootDir) {
exports.resolveShowConfigPath = resolveShowConfigPath;
function findConfigUpwards(rootDir) {
return null;
}
function* findPackageData(filepath) {

@@ -31,6 +30,4 @@ return {

}
function* findRelativeConfig(pkgData, envName, caller) {
return {
pkg: null,
config: null,

@@ -40,28 +37,27 @@ ignore: null

}
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;
//# sourceMappingURL=index-browser.js.map

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

});
Object.defineProperty(exports, "findPackageData", {
Object.defineProperty(exports, "ROOT_CONFIG_FILENAMES", {
enumerable: true,
get: function () {
return _package.findPackageData;
return _configuration.ROOT_CONFIG_FILENAMES;
}

@@ -19,2 +19,8 @@ });

});
Object.defineProperty(exports, "findPackageData", {
enumerable: true,
get: function () {
return _package.findPackageData;
}
});
Object.defineProperty(exports, "findRelativeConfig", {

@@ -38,8 +44,14 @@ enumerable: true,

});
Object.defineProperty(exports, "ROOT_CONFIG_FILENAMES", {
Object.defineProperty(exports, "loadPlugin", {
enumerable: true,
get: function () {
return _configuration.ROOT_CONFIG_FILENAMES;
return _plugins.loadPlugin;
}
});
Object.defineProperty(exports, "loadPreset", {
enumerable: true,
get: function () {
return _plugins.loadPreset;
}
});
Object.defineProperty(exports, "resolvePlugin", {

@@ -57,21 +69,14 @@ enumerable: true,

});
Object.defineProperty(exports, "loadPlugin", {
Object.defineProperty(exports, "resolveShowConfigPath", {
enumerable: true,
get: function () {
return _plugins.loadPlugin;
return _configuration.resolveShowConfigPath;
}
});
Object.defineProperty(exports, "loadPreset", {
enumerable: true,
get: function () {
return _plugins.loadPreset;
}
});
var _package = require("./package.js");
var _configuration = require("./configuration.js");
var _plugins = require("./plugins.js");
({});
0 && 0;
var _package = require("./package");
var _configuration = require("./configuration");
var _plugins = require("./plugins");
({});
//# sourceMappingURL=index.js.map

@@ -6,92 +6,170 @@ "use strict";

});
exports.default = loadCjsOrMjsDefault;
var _async = require("../../gensync-utils/async");
exports.default = loadCodeDefault;
exports.supportsESM = void 0;
var _async = require("../../gensync-utils/async.js");
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _url() {
const data = require("url");
_url = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _semver() {
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
function _debug() {
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
var _rewriteStackTrace = require("../../errors/rewrite-stack-trace.js");
var _configError = require("../../errors/config-error.js");
var _transformFile = require("../../transform-file.js");
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:module-types");
let import_;
try {
import_ = require("./import").default;
import_ = require("./import.cjs");
} catch (_unused) {}
function* loadCjsOrMjsDefault(filepath, asyncError) {
switch (guessJSModuleType(filepath)) {
case "cjs":
return loadCjsDefault(filepath);
case "unknown":
const supportsESM = _semver().satisfies(process.versions.node, "^12.17 || >=13.2");
exports.supportsESM = supportsESM;
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);
{
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));
}
throw new Error(asyncError);
}
if (yield* (0, _async.isAsync)()) {
return yield* (0, _async.waitFor)(loadMjsDefault(filepath));
}
throw new _configError.default(asyncError, filepath);
}
function guessJSModuleType(filename) {
switch (_path().default.extname(filename)) {
case ".cjs":
return "cjs";
case ".mjs":
return "mjs";
default:
return "unknown";
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;
}
}
return require.extensions[".js"](m, filename);
};
require.extensions[ext] = handler;
}
try {
return loadCjsDefault(filepath);
} finally {
if (!hasTsSupport) {
if (require.extensions[ext] === handler) delete require.extensions[ext];
handler = undefined;
}
}
}
const LOADING_CJS_FILES = new Set();
function loadCjsDefault(filepath) {
const module = require(filepath);
return (module == null ? void 0 : module.__esModule) ? module.default || undefined : module;
if (LOADING_CJS_FILES.has(filepath)) {
debug("Auto-ignoring usage of config %o.", filepath);
return {};
}
let module;
try {
LOADING_CJS_FILES.add(filepath);
module = (0, _rewriteStackTrace.endHiddenCallStack)(require)(filepath);
} finally {
LOADING_CJS_FILES.delete(filepath);
}
{
var _module;
return (_module = module) != null && _module.__esModule ? module.default || (arguments[1] ? 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;
});
return _loadMjsDefault.apply(this, arguments);
}
}
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:
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,19 +7,32 @@ "use strict";

exports.findPackageData = findPackageData;
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
var _utils = require("./utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _utils = require("./utils.js");
var _configError = require("../../errors/config-error.js");
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) {

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

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

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

}
dirname = nextLoc;
}
return {

@@ -55,26 +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 (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().default.dirname(filepath),
options
};
});
//# sourceMappingURL=package.js.map

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

});
exports.resolvePlugin = resolvePlugin;
exports.resolvePreset = resolvePreset;
exports.loadPlugin = loadPlugin;
exports.loadPreset = loadPreset;
exports.resolvePreset = exports.resolvePlugin = void 0;
function _debug() {
const data = _interopRequireDefault(require("debug"));
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
function _resolve() {
const data = _interopRequireDefault(require("resolve"));
_resolve = function () {
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
_path = function () {
var _async = require("../../gensync-utils/async.js");
var _moduleTypes = require("./module-types.js");
function _url() {
const data = require("url");
_url = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug().default)("babel:config:loading:files:plugins");
var _importMetaResolve = require("../../vendor/import-meta-resolve.js");
const debug = _debug()("babel:config:loading:files:plugins");
const EXACT_RE = /^module:/;

@@ -53,19 +43,9 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;

const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
function resolvePlugin(name, dirname) {
return resolveStandardizedName("plugin", name, dirname);
}
function resolvePreset(name, dirname) {
return resolveStandardizedName("preset", name, dirname);
}
function loadPlugin(name, dirname) {
const filepath = resolvePlugin(name, dirname);
if (!filepath) {
throw new Error(`Plugin ${name} not found relative to ${dirname}`);
}
const value = requireModule("plugin", filepath);
const resolvePlugin = resolveStandardizedName.bind(null, "plugin");
exports.resolvePlugin = resolvePlugin;
const resolvePreset = resolveStandardizedName.bind(null, "preset");
exports.resolvePreset = resolvePreset;
function* loadPlugin(name, dirname) {
const filepath = resolvePlugin(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("plugin", filepath);
debug("Loaded plugin %o from %o.", name, dirname);

@@ -77,11 +57,5 @@ return {

}
function loadPreset(name, dirname) {
const filepath = resolvePreset(name, dirname);
if (!filepath) {
throw new Error(`Preset ${name} not found relative to ${dirname}`);
}
const value = requireModule("preset", filepath);
function* loadPreset(name, dirname) {
const filepath = resolvePreset(name, dirname, yield* (0, _async.isAsync)());
const value = yield* requireModule("preset", filepath);
debug("Loaded preset %o from %o.", name, dirname);

@@ -93,81 +67,144 @@ return {

}
function standardizeName(type, name) {
if (_path().default.isAbsolute(name)) return name;
if (_path().isAbsolute(name)) return name;
const isPreset = type === "preset";
return name.replace(isPreset ? BABEL_PRESET_PREFIX_RE : BABEL_PLUGIN_PREFIX_RE, `babel-${type}-`).replace(isPreset ? BABEL_PRESET_ORG_RE : BABEL_PLUGIN_ORG_RE, `$1${type}-`).replace(isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE, `$1babel-${type}-`).replace(OTHER_ORG_DEFAULT_RE, `$1/babel-${type}`).replace(EXACT_RE, "");
}
function resolveStandardizedName(type, name, dirname = process.cwd()) {
function* resolveAlternativesHelper(type, name) {
const standardizedName = standardizeName(type, name);
const {
error,
value
} = yield standardizedName;
if (!error) return value;
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}?`;
}
if (type === "plugin") {
const transformName = standardizedName.replace("-proposal-", "-transform-");
if (transformName !== standardizedName && !(yield transformName).error) {
error.message += `\n- Did you mean "${transformName}"?`;
}
}
error.message += `\n
Make sure that all the Babel plugins and presets you are using
are defined as dependencies or devDependencies in your package.json
file. It's possible that the missing plugin is loaded by a preset
you are using that forgot to add the plugin to its dependencies: you
can workaround this problem by explicitly adding the missing package
to your top-level package.json.
`;
throw error;
}
function tryRequireResolve(id, dirname) {
try {
return _resolve().default.sync(standardizedName, {
basedir: dirname
});
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: (0, _importMetaResolve.resolve)(id, options)
};
} catch (error) {
return {
error,
value: null
};
}
}
function resolveStandardizedNameForRequire(type, name, dirname) {
const it = resolveAlternativesHelper(type, name);
let res = it.next();
while (!res.done) {
res = it.next(tryRequireResolve(res.value, dirname));
}
return res.value;
}
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 resolveStandardizedName(type, name, dirname, resolveESM) {
if (!_moduleTypes.supportsESM || !resolveESM) {
return resolveStandardizedNameForRequire(type, name, dirname);
}
try {
return resolveStandardizedNameForImport(type, name, dirname);
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") throw e;
if (standardizedName !== name) {
let resolvedOriginal = false;
try {
_resolve().default.sync(name, {
basedir: dirname
});
resolvedOriginal = true;
} catch (e2) {}
if (resolvedOriginal) {
e.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
}
}
let resolvedBabel = false;
try {
_resolve().default.sync(standardizeName(type, "@babel/" + name), {
basedir: dirname
});
resolvedBabel = true;
} catch (e2) {}
if (resolvedBabel) {
e.message += `\n- Did you mean "@babel/${name}"?`;
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;
}
let resolvedOppositeType = false;
const oppositeType = type === "preset" ? "plugin" : "preset";
try {
_resolve().default.sync(standardizeName(oppositeType, name), {
basedir: dirname
});
resolvedOppositeType = true;
} catch (e2) {}
if (resolvedOppositeType) {
e.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
}
throw e;
}
}
const LOADING_MODULES = new Set();
function requireModule(type, name) {
if (LOADING_MODULES.has(name)) {
throw new Error(`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` + "and is trying to load itself while compiling itself, leading to a dependency cycle. " + 'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.');
{
var LOADING_MODULES = new Set();
}
function* requireModule(type, name) {
{
if (!(yield* (0, _async.isAsync)()) && LOADING_MODULES.has(name)) {
throw new Error(`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` + "and is trying to load itself while compiling itself, leading to a dependency cycle. " + 'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.');
}
}
try {
LOADING_MODULES.add(name);
return require(name);
{
LOADING_MODULES.add(name);
}
{
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) {
err.message = `[BABEL]: ${err.message} (While processing: ${name})`;
throw err;
} finally {
LOADING_MODULES.delete(name);
{
LOADING_MODULES.delete(name);
}
}
}
}
0 && 0;
//# sourceMappingURL=plugins.js.map

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

exports.makeStaticFileCache = makeStaticFileCache;
var _caching = require("../caching");
var fs = _interopRequireWildcard(require("../../gensync-utils/fs"));
var _caching = require("../caching.js");
var fs = require("../../gensync-utils/fs.js");
function _fs2() {
const data = _interopRequireDefault(require("fs"));
const data = require("fs");
_fs2 = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function makeStaticFileCache(fn) {
return (0, _caching.makeStrongCache)(function* (filepath, cache) {
const cached = cache.invalidate(() => fileMtime(filepath));
if (cached === null) {
cache.forever();
return null;
}
return fn(filepath, (yield* fs.readFile(filepath, "utf8")));
return fn(filepath, yield* fs.readFile(filepath, "utf8"));
});
}
function fileMtime(filepath) {
if (!_fs2().existsSync(filepath)) return null;
try {
return +_fs2().default.statSync(filepath).mtime;
return +_fs2().statSync(filepath).mtime;
} catch (e) {
if (e.code !== "ENOENT" && e.code !== "ENOTDIR") throw e;
}
return null;
}
0 && 0;
return null;
}
//# sourceMappingURL=utils.js.map

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

exports.default = void 0;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _async = require("../gensync-utils/async");
var _util = require("./util");
var context = _interopRequireWildcard(require("../index"));
var _plugin = _interopRequireDefault(require("./plugin"));
var _item = require("./item");
var _configChain = require("./config-chain");
var _async = require("../gensync-utils/async.js");
var _util = require("./util.js");
var context = require("../index.js");
var _plugin = require("./plugin.js");
var _item = require("./item.js");
var _configChain = require("./config-chain.js");
var _deepArray = require("./helpers/deep-array.js");
function _traverse() {
const data = _interopRequireDefault(require("@babel/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 = _interopRequireDefault(require("./helpers/config-api"));
var _partial = _interopRequireDefault(require("./partial"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _gensync().default)(function* loadFullConfig(inputOpts) {
var _caching = require("./caching.js");
var _options = require("./validation/options.js");
var _plugins = require("./validation/plugins.js");
var _configApi = require("./helpers/config-api.js");
var _partial = require("./partial.js");
var _configError = require("../errors/config-error.js");
var _default = _gensync()(function* loadFullConfig(inputOpts) {
var _opts$assumptions;
const result = yield* (0, _partial.default)(inputOpts);
if (!result) {
return null;
}
const {
options,
context
context,
fileHandling
} = result;
if (fileHandling === "ignored") {
return null;
}
const optionDefaults = {};
const passes = [[]];
try {
const {
plugins,
presets
} = options;
if (!plugins || !presets) {
throw new Error("Assertion failure - plugins and presets exist");
const {
plugins,
presets
} = 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");
}
const ignored = yield* function* recurseDescriptors(config, pass) {
const plugins = [];
for (let i = 0; i < config.plugins.length; i++) {
const descriptor = config.plugins[i];
if (descriptor.options !== false) {
try {
plugins.push((yield* loadPluginDescriptor(descriptor, context)));
} catch (e) {
if (i > 0 && e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
(0, _options.checkNoUnwrappedItemOptionPairs)(config.plugins[i - 1], descriptor, "plugin", i, e);
}
throw e;
return desc;
};
const presetsDescriptors = presets.map(toDescriptor);
const initialPluginsDescriptors = plugins.map(toDescriptor);
const pluginDescriptorsByPass = [[]];
const passes = [];
const externalDependencies = [];
const ignored = yield* enhanceError(context, function* recursePresetDescriptors(rawPresets, pluginDescriptorsPass) {
const presets = [];
for (let i = 0; i < rawPresets.length; i++) {
const descriptor = rawPresets[i];
if (descriptor.options !== false) {
try {
var preset = yield* loadPresetDescriptor(descriptor, presetContext);
} catch (e) {
if (e.code === "BABEL_UNKNOWN_OPTION") {
(0, _options.checkNoUnwrappedItemOptionPairs)(rawPresets, i, "preset", e);
}
throw e;
}
externalDependencies.push(preset.externalDependencies);
if (descriptor.ownPass) {
presets.push({
preset: preset.chain,
pass: []
});
} else {
presets.unshift({
preset: preset.chain,
pass: pluginDescriptorsPass
});
}
}
const presets = [];
for (let i = 0; i < config.presets.length; i++) {
const descriptor = config.presets[i];
}
if (presets.length > 0) {
pluginDescriptorsByPass.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pluginDescriptorsPass));
for (const {
preset,
pass
} of presets) {
if (!preset) return true;
pass.push(...preset.plugins);
const ignored = yield* recursePresetDescriptors(preset.presets, pass);
if (ignored) return true;
preset.options.forEach(opts => {
(0, _util.mergeOptions)(optionDefaults, opts);
});
}
}
})(presetsDescriptors, pluginDescriptorsByPass[0]);
if (ignored) return null;
const opts = optionDefaults;
(0, _util.mergeOptions)(opts, options);
const pluginContext = Object.assign({}, presetContext, {
assumptions: (_opts$assumptions = opts.assumptions) != null ? _opts$assumptions : {}
});
yield* enhanceError(context, function* loadPluginDescriptors() {
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) {
try {
presets.push({
preset: yield* loadPresetDescriptor(descriptor, context),
pass: descriptor.ownPass ? [] : pass
});
var plugin = yield* loadPluginDescriptor(descriptor, pluginContext);
} catch (e) {
if (i > 0 && e.code === "BABEL_UNKNOWN_OPTION") {
(0, _options.checkNoUnwrappedItemOptionPairs)(config.presets[i - 1], descriptor, "preset", i, e);
if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
(0, _options.checkNoUnwrappedItemOptionPairs)(descs, i, "plugin", e);
}
throw e;
}
pass.push(plugin);
externalDependencies.push(plugin.externalDependencies);
}
}
if (presets.length > 0) {
passes.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pass));
for (const {
preset,
pass
} of presets) {
if (!preset) return true;
const ignored = yield* recurseDescriptors({
plugins: preset.plugins,
presets: preset.presets
}, pass);
if (ignored) return true;
preset.options.forEach(opts => {
(0, _util.mergeOptions)(optionDefaults, opts);
});
}
}
if (plugins.length > 0) {
pass.unshift(...plugins);
}
}({
plugins: plugins.map(item => {
const desc = (0, _item.getItemDescriptor)(item);
if (!desc) {
throw new Error("Assertion failure - must be config item");
}
return desc;
}),
presets: presets.map(item => {
const desc = (0, _item.getItemDescriptor)(item);
if (!desc) {
throw new Error("Assertion failure - must be config item");
}
return desc;
})
}, passes[0]);
if (ignored) return null;
} catch (e) {
if (!/^\[BABEL\]/.test(e.message)) {
e.message = `[BABEL] ${context.filename || "unknown"}: ${e.message}`;
}
throw e;
}
const opts = optionDefaults;
(0, _util.mergeOptions)(opts, options);
})();
opts.plugins = passes[0];

@@ -181,8 +150,21 @@ opts.presets = passes.slice(1).filter(plugins => plugins.length > 0).map(plugins => ({

options: opts,
passes: passes
passes: passes,
externalDependencies: (0, _deepArray.finalize)(externalDependencies)
};
});
exports.default = _default;
const loadDescriptor = (0, _caching.makeWeakCache)(function* ({
function enhanceError(context, fn) {
return function* (arg1, arg2) {
try {
return yield* fn(arg1, arg2);
} catch (e) {
if (!/^\[BABEL\]/.test(e.message)) {
var _context$filename;
e.message = `[BABEL] ${(_context$filename = context.filename) != null ? _context$filename : "unknown file"}: ${e.message}`;
}
throw e;
}
};
}
const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function* ({
value,

@@ -195,9 +177,9 @@ options,

options = options || {};
const externalDependencies = [];
let item = value;
if (typeof value === "function") {
const api = Object.assign({}, context, {}, (0, _configApi.default)(cache));
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 {
item = value(api, options, dirname);
item = yield* factory(api, options, dirname);
} catch (e) {

@@ -207,16 +189,22 @@ if (alias) {

}
throw e;
}
}
if (!item || typeof item !== "object") {
throw new Error("Plugin/Preset did not return an object.");
}
if (typeof item.then === "function") {
if ((0, _async.isThenable)(item)) {
yield* [];
throw new Error(`You appear to be using an async 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.`);
throw new Error(`You appear to be using a promise as a 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. ` + `As an alternative, you can prefix the promise with "await". ` + `(While processing: ${JSON.stringify(alias)})`);
}
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()) {
error += `has not been configured to be invalidated when the external dependencies change. `;
} else {
error += ` has been configured to never be invalidated. `;
}
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 {

@@ -226,18 +214,8 @@ value: item,

dirname,
alias
alias,
externalDependencies: (0, _deepArray.finalize)(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* loadDescriptor(descriptor, context)), context);
}
const pluginDescriptorLoader = makeDescriptorLoader(_configApi.makePluginAPI);
const presetDescriptorLoader = makeDescriptorLoader(_configApi.makePresetAPI);
const instantiatePlugin = (0, _caching.makeWeakCache)(function* ({

@@ -247,11 +225,10 @@ value,

dirname,
alias
alias,
externalDependencies
}, cache) {
const pluginObj = (0, _plugins.validatePluginObject)(value);
const plugin = Object.assign({}, pluginObj);
if (plugin.visitor) {
plugin.visitor = _traverse().default.explode(Object.assign({}, plugin.visitor));
}
if (plugin.inherits) {

@@ -272,16 +249,31 @@ const inheritsDescriptor = {

plugin.visitor = _traverse().default.visitors.merge([inherits.visitor || {}, plugin.visitor || {}]);
if (inherits.externalDependencies.length > 0) {
if (externalDependencies.length === 0) {
externalDependencies = inherits.externalDependencies;
} else {
externalDependencies = (0, _deepArray.finalize)([externalDependencies, inherits.externalDependencies]);
}
}
}
return new _plugin.default(plugin, options, alias);
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.transform(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) => {
if (!context.filename) {
var _options$overrides;
const {

@@ -291,19 +283,10 @@ options

validateIfOptionNeedsFilename(options, descriptor);
if (options.overrides) {
options.overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor));
}
(_options$overrides = options.overrides) == null ? void 0 : _options$overrides.forEach(overrideOptions => validateIfOptionNeedsFilename(overrideOptions, descriptor));
}
};
function* loadPresetDescriptor(descriptor, context) {
const preset = instantiatePreset((yield* loadDescriptor(descriptor, context)));
validatePreset(preset, context, descriptor);
return yield* (0, _configChain.buildPresetChain)(preset, context);
}
const instantiatePreset = (0, _caching.makeWeakCacheSync)(({
value,
dirname,
alias
alias,
externalDependencies
}) => {

@@ -313,6 +296,14 @@ return {

alias,
dirname
dirname,
externalDependencies
};
});
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) {

@@ -326,2 +317,5 @@ const fns = [a, b].filter(Boolean);

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

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

});
exports.default = makeAPI;
exports.makeConfigAPI = makeConfigAPI;
exports.makePluginAPI = makePluginAPI;
exports.makePresetAPI = makePresetAPI;
function _semver() {
const data = _interopRequireDefault(require("semver"));
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
var _ = require("../../");
var _caching = require("../caching");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function makeAPI(cache) {
var _index = require("../../index.js");
var _caching = require("../caching.js");
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));
}
if (!Array.isArray(value)) value = [value];
return value.some(entry => {
return (Array.isArray(value) ? value : [value]).some(entry => {
if (typeof entry !== "string") {
throw new Error("Unexpected non-string value");
}
return entry === data.envName;
});
});
const caller = cb => cache.using(data => (0, _caching.assertSimpleType)(cb(data.caller)));
return {
version: _.version,
version: _index.version,
cache: cache.simple(),

@@ -51,7 +39,21 @@ env,

caller,
assertVersion,
tokTypes: undefined
assertVersion
};
}
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), {
targets,
addExternalDependency
});
}
function makePluginAPI(cache, externalDependencies) {
const assumption = name => cache.using(data => data.assumptions[name]);
return Object.assign({}, makePresetAPI(cache, externalDependencies), {
assumption
});
}
function assertVersion(range) {

@@ -62,28 +64,25 @@ if (typeof range === "number") {

}
range = `^${range}.0.0-0`;
}
if (typeof range !== "string") {
throw new Error("Expected string or integer value.");
}
if (_semver().default.satisfies(_.version, range)) return;
;
if (_semver().satisfies(_index.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.`);
const err = new Error(`Requires Babel "${range}", but was loaded with "${_index.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, {
code: "BABEL_VERSION_UNSUPPORTED",
version: _.version,
version: _index.version,
range
});
}
}
0 && 0;
//# sourceMappingURL=config-api.js.map

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

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

@@ -6,2 +6,5 @@ "use strict";

});
exports.createConfigItem = createConfigItem;
exports.createConfigItemAsync = createConfigItemAsync;
exports.createConfigItemSync = createConfigItemSync;
Object.defineProperty(exports, "default", {

@@ -13,45 +16,80 @@ enumerable: true,

});
exports.loadOptionsAsync = exports.loadOptionsSync = exports.loadOptions = exports.loadPartialConfigAsync = exports.loadPartialConfigSync = exports.loadPartialConfig = void 0;
exports.loadOptions = loadOptions;
exports.loadOptionsAsync = loadOptionsAsync;
exports.loadOptionsSync = loadOptionsSync;
exports.loadPartialConfig = loadPartialConfig;
exports.loadPartialConfigAsync = loadPartialConfigAsync;
exports.loadPartialConfigSync = loadPartialConfigSync;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _full = _interopRequireDefault(require("./full"));
var _partial = require("./partial");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const loadOptionsRunner = (0, _gensync().default)(function* (opts) {
var _full = require("./full.js");
var _partial = require("./partial.js");
var _item = require("./item.js");
var _rewriteStackTrace = require("../errors/rewrite-stack-trace.js");
const loadPartialConfigRunner = _gensync()(_partial.loadPartialConfig);
function loadPartialConfigAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.async)(...args);
}
function loadPartialConfigSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.sync)(...args);
}
function loadPartialConfig(opts, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(opts, callback);
} else if (typeof opts === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadPartialConfigRunner.errback)(undefined, opts);
} else {
{
return loadPartialConfigSync(opts);
}
}
}
function* loadOptionsImpl(opts) {
var _config$options;
const config = yield* (0, _full.default)(opts);
return config ? config.options : null;
});
const maybeErrback = runner => (opts, callback) => {
if (callback === undefined && typeof opts === "function") {
callback = opts;
opts = undefined;
return (_config$options = config == null ? void 0 : config.options) != null ? _config$options : null;
}
const loadOptionsRunner = _gensync()(loadOptionsImpl);
function loadOptionsAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.async)(...args);
}
function loadOptionsSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.sync)(...args);
}
function loadOptions(opts, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(opts, callback);
} else if (typeof opts === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(loadOptionsRunner.errback)(undefined, opts);
} else {
{
return loadOptionsSync(opts);
}
}
}
const createConfigItemRunner = _gensync()(_item.createConfigItem);
function createConfigItemAsync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.async)(...args);
}
function createConfigItemSync(...args) {
return (0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.sync)(...args);
}
function createConfigItem(target, options, callback) {
if (callback !== undefined) {
(0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, options, callback);
} else if (typeof options === "function") {
(0, _rewriteStackTrace.beginHiddenCallStack)(createConfigItemRunner.errback)(target, undefined, callback);
} else {
{
return createConfigItemSync(target, options);
}
}
}
0 && 0;
return callback ? runner.errback(opts, callback) : runner.sync(opts);
};
const loadPartialConfig = maybeErrback(_partial.loadPartialConfig);
exports.loadPartialConfig = loadPartialConfig;
const loadPartialConfigSync = _partial.loadPartialConfig.sync;
exports.loadPartialConfigSync = loadPartialConfigSync;
const loadPartialConfigAsync = _partial.loadPartialConfig.async;
exports.loadPartialConfigAsync = loadPartialConfigAsync;
const loadOptions = maybeErrback(loadOptionsRunner);
exports.loadOptions = loadOptions;
const loadOptionsSync = loadOptionsRunner.sync;
exports.loadOptionsSync = loadOptionsSync;
const loadOptionsAsync = loadOptionsRunner.async;
exports.loadOptionsAsync = loadOptionsAsync;
//# sourceMappingURL=index.js.map

@@ -6,29 +6,21 @@ "use strict";

});
exports.createConfigItem = createConfigItem;
exports.createItemFromDescriptor = createItemFromDescriptor;
exports.createConfigItem = createConfigItem;
exports.getItemDescriptor = getItemDescriptor;
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
var _configDescriptors = require("./config-descriptors");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _configDescriptors = require("./config-descriptors.js");
function createItemFromDescriptor(desc) {
return new ConfigItem(desc);
}
function createConfigItem(value, {
function* createConfigItem(value, {
dirname = ".",
type
} = {}) {
const descriptor = (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), {
const descriptor = yield* (0, _configDescriptors.createDescriptor)(value, _path().resolve(dirname), {
type,

@@ -39,13 +31,18 @@ alias: "programmatic item"

}
const CONFIG_ITEM_BRAND = Symbol.for("@babel/core@7 - ConfigItem");
function getItemDescriptor(item) {
if (item instanceof ConfigItem) {
if (item != null && item[CONFIG_ITEM_BRAND]) {
return item._descriptor;
}
return undefined;
}
class ConfigItem {
constructor(descriptor) {
this._descriptor = void 0;
this[CONFIG_ITEM_BRAND] = true;
this.value = void 0;
this.options = void 0;
this.dirname = void 0;
this.name = void 0;
this.file = void 0;
this._descriptor = descriptor;

@@ -55,2 +52,5 @@ Object.defineProperty(this, "_descriptor", {

});
Object.defineProperty(this, CONFIG_ITEM_BRAND, {
enumerable: false
});
this.value = this._descriptor.value;

@@ -66,5 +66,6 @@ this.options = this._descriptor.options;

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

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

exports.default = loadPrivatePartialConfig;
exports.loadPartialConfig = void 0;
exports.loadPartialConfig = loadPartialConfig;
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
_gensync = function () {
return data;
};
return data;
}
var _plugin = _interopRequireDefault(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");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function* resolveRootMode(rootDir, rootMode) {
var _plugin = require("./plugin.js");
var _util = require("./util.js");
var _item = require("./item.js");
var _configChain = require("./config-chain.js");
var _environment = require("./helpers/environment.js");
var _options = require("./validation/options.js");
var _index = require("./files/index.js");
var _resolveTargets = require("./resolve-targets.js");
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) {
switch (rootMode) {
case "root":
return rootDir;
case "upward-optional":
{
const upwardRootDir = yield* (0, _files.findConfigUpwards)(rootDir);
const upwardRootDir = (0, _index.findConfigUpwards)(rootDir);
return upwardRootDir === null ? rootDir : upwardRootDir;
}
case "upward":
{
const upwardRootDir = yield* (0, _files.findConfigUpwards)(rootDir);
const upwardRootDir = (0, _index.findConfigUpwards)(rootDir);
if (upwardRootDir !== null) return upwardRootDir;
throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_files.ROOT_CONFIG_FILENAMES.join(", ")}".`), {
throw Object.assign(new Error(`Babel was run with rootMode:"upward" but a root could not ` + `be found when searching upward from "${rootDir}".\n` + `One of the following config files must be in the directory tree: ` + `"${_index.ROOT_CONFIG_FILENAMES.join(", ")}".`), {
code: "BABEL_ROOT_NOT_FOUND",

@@ -66,3 +44,2 @@ dirname: rootDir

}
default:

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

}
function* loadPrivatePartialConfig(inputOpts) {

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

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

@@ -86,41 +61,61 @@ const {

rootMode = "root",
caller
caller,
cloneInputAst = true
} = args;
const absoluteCwd = _path().default.resolve(cwd);
const absoluteRootDir = yield* resolveRootMode(_path().default.resolve(absoluteCwd, rootDir), rootMode);
const absoluteCwd = _path().resolve(cwd);
const absoluteRootDir = resolveRootMode(_path().resolve(absoluteCwd, rootDir), rootMode);
const filename = typeof args.filename === "string" ? _path().resolve(cwd, args.filename) : undefined;
const showConfigPath = yield* (0, _index.resolveShowConfigPath)(absoluteCwd);
const context = {
filename: typeof args.filename === "string" ? _path().default.resolve(cwd, args.filename) : undefined,
filename,
cwd: absoluteCwd,
root: absoluteRootDir,
envName,
caller
caller,
showConfig: showConfigPath === filename
};
const configChain = yield* (0, _configChain.buildRootChain)(args, context);
if (!configChain) return null;
const options = {};
const merged = {
assumptions: {}
};
configChain.options.forEach(opts => {
(0, _util.mergeOptions)(options, opts);
(0, _util.mergeOptions)(merged, opts);
});
options.babelrc = false;
options.configFile = false;
options.passPerPreset = false;
options.envName = context.envName;
options.cwd = context.cwd;
options.root = context.root;
options.filename = typeof context.filename === "string" ? context.filename : undefined;
options.plugins = configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor));
options.presets = configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor));
const options = Object.assign({}, merged, {
targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir),
cloneInputAst,
babelrc: false,
configFile: false,
browserslistConfigFile: false,
passPerPreset: false,
envName: context.envName,
cwd: context.cwd,
root: context.root,
rootMode: "root",
filename: typeof context.filename === "string" ? context.filename : undefined,
plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)),
presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor))
});
return {
options,
context,
fileHandling: configChain.fileHandling,
ignore: configChain.ignore,
babelrc: configChain.babelrc,
config: configChain.config
config: configChain.config,
files: configChain.files
};
}
const loadPartialConfig = (0, _gensync().default)(function* (inputOpts) {
const result = yield* loadPrivatePartialConfig(inputOpts);
function* loadPartialConfig(opts) {
let showIgnoredFiles = false;
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
var _opts = opts;
({
showIgnoredFiles
} = _opts);
opts = _objectWithoutPropertiesLoose(_opts, _excluded);
_opts;
}
const result = yield* loadPrivatePartialConfig(opts);
if (!result) return null;

@@ -131,4 +126,9 @@ const {

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

@@ -139,8 +139,12 @@ if (item.value instanceof _plugin.default) {

});
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined);
});
exports.loadPartialConfig = loadPartialConfig;
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined, fileHandling, files);
}
class PartialConfig {
constructor(options, babelrc, ignore, config) {
constructor(options, babelrc, ignore, config, fileHandling, files) {
this.options = void 0;
this.babelrc = void 0;
this.babelignore = void 0;
this.config = void 0;
this.fileHandling = void 0;
this.files = void 0;
this.options = options;

@@ -150,11 +154,13 @@ this.babelignore = ignore;

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

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

exports.default = pathToPattern;
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _escapeRegExp() {
const data = _interopRequireDefault(require("lodash/escapeRegExp"));
_escapeRegExp = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const sep = `\\${_path().default.sep}`;
const sep = `\\${_path().sep}`;
const endSep = `(?:${sep}|$)`;

@@ -38,6 +22,7 @@ const substitution = `[^${sep}]+`;

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

@@ -47,9 +32,10 @@ const last = i === parts.length - 1;

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

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

exports.default = void 0;
var _deepArray = require("./helpers/deep-array.js");
class Plugin {
constructor(plugin, options, key) {
constructor(plugin, options, key, externalDependencies = (0, _deepArray.finalize)([])) {
this.key = void 0;
this.manipulateOptions = void 0;
this.post = void 0;
this.pre = void 0;
this.visitor = void 0;
this.parserOverride = void 0;
this.generatorOverride = void 0;
this.options = void 0;
this.externalDependencies = void 0;
this.key = plugin.name || key;

@@ -19,6 +28,8 @@ this.manipulateOptions = plugin.manipulateOptions;

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

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

});
exports.isIterableIterator = isIterableIterator;
exports.mergeOptions = mergeOptions;
exports.isIterableIterator = isIterableIterator;
function mergeOptions(target, source) {
for (const k of Object.keys(source)) {
if (k === "parserOpts" && source.parserOpts) {
const parserOpts = source.parserOpts;
const targetObj = target.parserOpts = target.parserOpts || {};
if ((k === "parserOpts" || k === "generatorOpts" || k === "assumptions") && source[k]) {
const parserOpts = source[k];
const targetObj = target[k] || (target[k] = {});
mergeDefaultFields(targetObj, parserOpts);
} else if (k === "generatorOpts" && source.generatorOpts) {
const generatorOpts = source.generatorOpts;
const targetObj = target.generatorOpts = target.generatorOpts || {};
mergeDefaultFields(targetObj, generatorOpts);
} else {

@@ -26,3 +21,2 @@ const val = source[k];

}
function mergeDefaultFields(target, source) {

@@ -34,5 +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;
//# sourceMappingURL=util.js.map

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

});
exports.msg = msg;
exports.access = access;
exports.assertArray = assertArray;
exports.assertAssumptions = assertAssumptions;
exports.assertBabelrcSearch = assertBabelrcSearch;
exports.assertBoolean = assertBoolean;
exports.assertCallerMetadata = assertCallerMetadata;
exports.assertCompact = assertCompact;
exports.assertConfigApplicableTest = assertConfigApplicableTest;
exports.assertConfigFileSearch = assertConfigFileSearch;
exports.assertFunction = assertFunction;
exports.assertIgnoreList = assertIgnoreList;
exports.assertInputSourceMap = assertInputSourceMap;
exports.assertObject = assertObject;
exports.assertPluginList = assertPluginList;
exports.assertRootMode = assertRootMode;
exports.assertSourceMaps = assertSourceMaps;
exports.assertCompact = assertCompact;
exports.assertSourceType = assertSourceType;
exports.assertCallerMetadata = assertCallerMetadata;
exports.assertInputSourceMap = assertInputSourceMap;
exports.assertString = assertString;
exports.assertFunction = assertFunction;
exports.assertBoolean = assertBoolean;
exports.assertObject = assertObject;
exports.assertArray = assertArray;
exports.assertIgnoreList = assertIgnoreList;
exports.assertConfigApplicableTest = assertConfigApplicableTest;
exports.assertConfigFileSearch = assertConfigFileSearch;
exports.assertBabelrcSearch = assertBabelrcSearch;
exports.assertPluginList = assertPluginList;
exports.assertTargets = assertTargets;
exports.msg = msg;
function _helperCompilationTargets() {
const data = require("@babel/helper-compilation-targets");
_helperCompilationTargets = function () {
return data;
};
return data;
}
var _options = require("./options.js");
function msg(loc) {

@@ -30,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:

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

}
function access(loc, name) {

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

}
function assertRootMode(loc, value) {

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

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

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

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

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

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

@@ -90,18 +86,13 @@ if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") {

}
return value;
}
function assertCallerMetadata(loc, value) {
const obj = assertObject(loc, value);
if (obj) {
if (typeof obj["name"] !== "string") {
if (typeof obj.name !== "string") {
throw new Error(`${msg(loc)} set but does not contain "name" property 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") {

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

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

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

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

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

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

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

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

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

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

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

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

@@ -166,16 +145,9 @@ 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));
}
arr == null ? void 0 : arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
return arr;
}
function assertIgnoreItem(loc, value) {

@@ -185,9 +157,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)) {

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

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

@@ -215,9 +183,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)) {

@@ -232,16 +199,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) {

@@ -252,12 +214,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)) {

@@ -267,6 +225,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") {

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

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

@@ -288,4 +242,59 @@ 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");
const esmodulesLoc = access(loc, "esmodules");
assertBrowsersList(browsersLoc, value.browsers);
assertBoolean(esmodulesLoc, value.esmodules);
for (const key of Object.keys(value)) {
const val = value[key];
const subLoc = access(loc, key);
if (key === "esmodules") assertBoolean(subLoc, val);else if (key === "browsers") assertBrowsersList(subLoc, val);else if (!Object.hasOwnProperty.call(_helperCompilationTargets().TargetNames, key)) {
const validTargets = Object.keys(_helperCompilationTargets().TargetNames).join(", ");
throw new Error(`${msg(subLoc)} is not a valid target. Supported targets are ${validTargets}`);
} else assertBrowserVersion(subLoc, val);
}
return value;
}
function assertBrowsersList(loc, value) {
if (value !== undefined && !(0, _helperCompilationTargets().isBrowsersQueryValid)(value)) {
throw new Error(`${msg(loc)} must be undefined, a string or an array of strings`);
}
}
function assertBrowserVersion(loc, value) {
if (typeof value === "number" && Math.round(value) === value) return;
if (typeof value === "string") return;
throw new Error(`${msg(loc)} must be a string or an integer number`);
}
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) {
throw new Error(`${msg(subLoc)} cannot be set to 'false' inside presets.`);
}
}
return value;
}
0 && 0;
return value;
}
//# sourceMappingURL=option-assertions.js.map

@@ -6,13 +6,8 @@ "use strict";

});
exports.assumptionsNames = void 0;
exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs;
exports.validate = validate;
exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs;
var _plugin = _interopRequireDefault(require("../plugin"));
var _removed = _interopRequireDefault(require("./removed"));
var _optionAssertions = require("./option-assertions");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _removed = require("./removed.js");
var _optionAssertions = require("./option-assertions.js");
var _configError = require("../../errors/config-error.js");
const ROOT_VALIDATORS = {

@@ -28,2 +23,3 @@ cwd: _optionAssertions.assertString,

ast: _optionAssertions.assertBoolean,
cloneInputAst: _optionAssertions.assertBoolean,
envName: _optionAssertions.assertString

@@ -38,3 +34,6 @@ };

ignore: _optionAssertions.assertIgnoreList,
only: _optionAssertions.assertIgnoreList
only: _optionAssertions.assertIgnoreList,
targets: _optionAssertions.assertTargets,
browserslistConfigFile: _optionAssertions.assertConfigFileSearch,
browserslistEnv: _optionAssertions.assertString
};

@@ -46,2 +45,3 @@ const COMMON_VALIDATORS = {

passPerPreset: _optionAssertions.assertBoolean,
assumptions: _optionAssertions.assertAssumptions,
env: assertEnvSet,

@@ -66,21 +66,31 @@ overrides: assertOverridesList,

sourceRoot: _optionAssertions.assertString,
getModuleId: _optionAssertions.assertFunction,
moduleRoot: _optionAssertions.assertString,
moduleIds: _optionAssertions.assertBoolean,
moduleId: _optionAssertions.assertString,
parserOpts: _optionAssertions.assertObject,
generatorOpts: _optionAssertions.assertObject
};
{
Object.assign(COMMON_VALIDATORS, {
getModuleId: _optionAssertions.assertFunction,
moduleRoot: _optionAssertions.assertString,
moduleIds: _optionAssertions.assertBoolean,
moduleId: _optionAssertions.assertString
});
}
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) {

@@ -95,11 +105,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]) {

@@ -109,6 +116,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;

@@ -119,6 +124,4 @@ validator(optLoc, opts[key]);

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

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

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

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

}
function assertEnvSet(loc, value) {

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

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

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

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

@@ -179,10 +175,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) {

@@ -201,10 +194,14 @@ for (const [index, item] of arr.entries()) {

}
return arr;
}
function checkNoUnwrappedItemOptionPairs(lastItem, thisItem, type, index, e) {
function checkNoUnwrappedItemOptionPairs(items, index, type, e) {
if (index === 0) return;
const lastItem = items[index - 1];
const thisItem = items[index];
if (lastItem.file && lastItem.options === undefined && typeof thisItem.value === "object") {
e.message += `\n- Maybe you meant to use\n` + `"${type}": [\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`;
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;
//# sourceMappingURL=options.js.map

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

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

@@ -21,17 +19,16 @@ name: _optionAssertions.assertString,

};
function assertVisitorMap(key, value) {
const obj = (0, _optionAssertions.assertObject)(key, value);
function assertVisitorMap(loc, value) {
const obj = (0, _optionAssertions.assertObject)(loc, value);
if (obj) {
Object.keys(obj).forEach(prop => assertVisitorHandler(prop, obj[prop]));
Object.keys(obj).forEach(prop => {
if (prop !== "_exploded" && prop !== "_verified") {
assertVisitorHandler(prop, obj[prop]);
}
});
if (obj.enter || obj.exit) {
throw new Error(`.${key} cannot contain catch-all "enter" or "exit" handlers. Please target individual nodes.`);
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) {

@@ -47,6 +44,3 @@ if (value && typeof value === "object") {

}
return value;
}
function validatePluginObject(obj) {

@@ -59,8 +53,10 @@ const rootPath = {

const validator = VALIDATORS[key];
const optLoc = {
type: "option",
name: key,
parent: rootPath
};
if (validator) validator(optLoc, obj[key]);else {
if (validator) {
const optLoc = {
type: "option",
name: key,
parent: rootPath
};
validator(optLoc, obj[key]);
} else {
const invalidPluginPropertyError = new Error(`.${key} is not a valid Plugin property`);

@@ -72,2 +68,5 @@ invalidPluginPropertyError.code = "BABEL_UNKNOWN_PLUGIN_PROPERTY";

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

@@ -66,2 +66,5 @@ "use strict";

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

@@ -6,25 +6,20 @@ "use strict";

});
exports.maybeAsync = maybeAsync;
exports.forwardAsync = forwardAsync;
exports.isAsync = void 0;
exports.isThenable = isThenable;
exports.waitFor = exports.onFirstPause = exports.isAsync = void 0;
exports.maybeAsync = maybeAsync;
exports.waitFor = exports.onFirstPause = void 0;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const id = x => x;
const runGenerator = (0, _gensync().default)(function* (item) {
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 = (0, _gensync().default)({
const isAsync = _gensync()({
sync: () => false,

@@ -34,5 +29,4 @@ errback: cb => cb(null, true)

exports.isAsync = isAsync;
function maybeAsync(fn, message) {
return (0, _gensync().default)({
return _gensync()({
sync(...args) {

@@ -43,17 +37,20 @@ const result = fn.apply(this, args);

},
async(...args) {
return Promise.resolve(fn.apply(this, args));
}
});
}
const withKind = (0, _gensync().default)({
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 = (0, _gensync().default)(action);
const g = _gensync()(action);
return withKind(kind => {

@@ -64,4 +61,3 @@ const adapted = g[kind];

}
const onFirstPause = (0, _gensync().default)({
const onFirstPause = _gensync()({
name: "onFirstPause",

@@ -78,3 +74,2 @@ arity: 2,

});
if (!completed) {

@@ -86,10 +81,19 @@ firstPause();

exports.onFirstPause = onFirstPause;
const waitFor = (0, _gensync().default)({
sync: id,
async: id
const waitFor = _gensync()({
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;
//# sourceMappingURL=async.js.map

@@ -6,44 +6,29 @@ "use strict";

});
exports.exists = exports.readFile = void 0;
exports.stat = exports.readFile = void 0;
function _fs() {
const data = _interopRequireDefault(require("fs"));
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const readFile = (0, _gensync().default)({
sync: _fs().default.readFileSync,
errback: _fs().default.readFile
const readFile = _gensync()({
sync: _fs().readFileSync,
errback: _fs().readFile
});
exports.readFile = readFile;
const exists = (0, _gensync().default)({
sync(path) {
try {
_fs().default.accessSync(path);
const stat = _gensync()({
sync: _fs().statSync,
errback: _fs().stat
});
exports.stat = stat;
0 && 0;
return true;
} catch (_unused) {
return false;
}
},
errback: (path, cb) => _fs().default.access(path, undefined, err => cb(null, !err))
});
exports.exists = exists;
//# sourceMappingURL=fs.js.map

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

});
exports.Plugin = Plugin;
exports.DEFAULT_EXTENSIONS = void 0;
Object.defineProperty(exports, "File", {

@@ -20,18 +20,18 @@ enumerable: true,

});
Object.defineProperty(exports, "resolvePlugin", {
Object.defineProperty(exports, "createConfigItem", {
enumerable: true,
get: function () {
return _files.resolvePlugin;
return _index2.createConfigItem;
}
});
Object.defineProperty(exports, "resolvePreset", {
Object.defineProperty(exports, "createConfigItemAsync", {
enumerable: true,
get: function () {
return _files.resolvePreset;
return _index2.createConfigItemAsync;
}
});
Object.defineProperty(exports, "version", {
Object.defineProperty(exports, "createConfigItemSync", {
enumerable: true,
get: function () {
return _package.version;
return _index2.createConfigItemSync;
}

@@ -45,30 +45,30 @@ });

});
Object.defineProperty(exports, "tokTypes", {
Object.defineProperty(exports, "loadOptions", {
enumerable: true,
get: function () {
return _parser().tokTypes;
return _index2.loadOptions;
}
});
Object.defineProperty(exports, "traverse", {
Object.defineProperty(exports, "loadOptionsAsync", {
enumerable: true,
get: function () {
return _traverse().default;
return _index2.loadOptionsAsync;
}
});
Object.defineProperty(exports, "template", {
Object.defineProperty(exports, "loadOptionsSync", {
enumerable: true,
get: function () {
return _template().default;
return _index2.loadOptionsSync;
}
});
Object.defineProperty(exports, "createConfigItem", {
Object.defineProperty(exports, "loadPartialConfig", {
enumerable: true,
get: function () {
return _item.createConfigItem;
return _index2.loadPartialConfig;
}
});
Object.defineProperty(exports, "loadPartialConfig", {
Object.defineProperty(exports, "loadPartialConfigAsync", {
enumerable: true,
get: function () {
return _config.loadPartialConfig;
return _index2.loadPartialConfigAsync;
}

@@ -79,41 +79,53 @@ });

get: function () {
return _config.loadPartialConfigSync;
return _index2.loadPartialConfigSync;
}
});
Object.defineProperty(exports, "loadPartialConfigAsync", {
Object.defineProperty(exports, "parse", {
enumerable: true,
get: function () {
return _config.loadPartialConfigAsync;
return _parse.parse;
}
});
Object.defineProperty(exports, "loadOptions", {
Object.defineProperty(exports, "parseAsync", {
enumerable: true,
get: function () {
return _config.loadOptions;
return _parse.parseAsync;
}
});
Object.defineProperty(exports, "loadOptionsSync", {
Object.defineProperty(exports, "parseSync", {
enumerable: true,
get: function () {
return _config.loadOptionsSync;
return _parse.parseSync;
}
});
Object.defineProperty(exports, "loadOptionsAsync", {
Object.defineProperty(exports, "resolvePlugin", {
enumerable: true,
get: function () {
return _config.loadOptionsAsync;
return _index.resolvePlugin;
}
});
Object.defineProperty(exports, "transform", {
Object.defineProperty(exports, "resolvePreset", {
enumerable: true,
get: function () {
return _transform.transform;
return _index.resolvePreset;
}
});
Object.defineProperty(exports, "transformSync", {
Object.defineProperty((0, exports), "template", {
enumerable: true,
get: function () {
return _transform.transformSync;
return _template().default;
}
});
Object.defineProperty((0, exports), "tokTypes", {
enumerable: true,
get: function () {
return _parser().tokTypes;
}
});
Object.defineProperty(exports, "transform", {
enumerable: true,
get: function () {
return _transform.transform;
}
});
Object.defineProperty(exports, "transformAsync", {

@@ -131,12 +143,12 @@ enumerable: true,

});
Object.defineProperty(exports, "transformFileSync", {
Object.defineProperty(exports, "transformFileAsync", {
enumerable: true,
get: function () {
return _transformFile.transformFileSync;
return _transformFile.transformFileAsync;
}
});
Object.defineProperty(exports, "transformFileAsync", {
Object.defineProperty(exports, "transformFileSync", {
enumerable: true,
get: function () {
return _transformFile.transformFileAsync;
return _transformFile.transformFileSync;
}

@@ -150,8 +162,2 @@ });

});
Object.defineProperty(exports, "transformFromAstSync", {
enumerable: true,
get: function () {
return _transformAst.transformFromAstSync;
}
});
Object.defineProperty(exports, "transformFromAstAsync", {

@@ -163,43 +169,33 @@ enumerable: true,

});
Object.defineProperty(exports, "parse", {
Object.defineProperty(exports, "transformFromAstSync", {
enumerable: true,
get: function () {
return _parse.parse;
return _transformAst.transformFromAstSync;
}
});
Object.defineProperty(exports, "parseSync", {
Object.defineProperty(exports, "transformSync", {
enumerable: true,
get: function () {
return _parse.parseSync;
return _transform.transformSync;
}
});
Object.defineProperty(exports, "parseAsync", {
Object.defineProperty((0, exports), "traverse", {
enumerable: true,
get: function () {
return _parse.parseAsync;
return _traverse().default;
}
});
exports.types = exports.OptionManager = exports.DEFAULT_EXTENSIONS = void 0;
var _file = _interopRequireDefault(require("./transformation/file/file"));
var _buildExternalHelpers = _interopRequireDefault(require("./tools/build-external-helpers"));
var _files = require("./config/files");
var _package = require("../package.json");
var _environment = require("./config/helpers/environment");
exports.version = exports.types = void 0;
var _file = require("./transformation/file/file.js");
var _buildExternalHelpers = require("./tools/build-external-helpers.js");
var _index = require("./config/files/index.js");
var _environment = require("./config/helpers/environment.js");
function _types() {
const data = _interopRequireWildcard(require("@babel/types"));
const data = require("@babel/types");
_types = function () {
return data;
};
return data;
}
Object.defineProperty(exports, "types", {
Object.defineProperty((0, exports), "types", {
enumerable: true,

@@ -210,65 +206,47 @@ get: function () {

});
function _parser() {
const data = require("@babel/parser");
_parser = function () {
return data;
};
return data;
}
function _traverse() {
const data = _interopRequireDefault(require("@babel/traverse"));
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
function _template() {
const data = _interopRequireDefault(require("@babel/template"));
const data = require("@babel/template");
_template = function () {
return data;
};
return data;
}
var _item = require("./config/item");
var _config = require("./config");
var _transform = require("./transform");
var _transformFile = require("./transform-file");
var _transformAst = require("./transform-ast");
var _parse = require("./parse");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs"]);
var _index2 = require("./config/index.js");
var _transform = require("./transform.js");
var _transformFile = require("./transform-file.js");
var _transformAst = require("./transform-ast.js");
var _parse = require("./parse.js");
var thisFile = require("./index.js");
;
const version = "7.23.0";
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.loadOptions)(opts);
}
;
{
exports.OptionManager = class OptionManager {
init(opts) {
return (0, _index2.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.`);
}
//# sourceMappingURL=index.js.map

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

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

@@ -42,11 +33,18 @@ if (typeof opts === "function") {

}
if (callback === undefined) return parseRunner.sync(code, opts);
parseRunner.errback(code, opts, callback);
if (callback === undefined) {
{
return (0, _rewriteStackTrace.beginHiddenCallStack)(parseRunner.sync)(code, opts);
}
}
(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;
//# sourceMappingURL=parse.js.map

@@ -7,27 +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 = _interopRequireDefault(require("./util/missing-plugin-helper"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _missingPluginHelper = require("./util/missing-plugin-helper.js");
function* parser(pluginPasses, {

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

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

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

} = plugin;
if (parserOverride) {

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

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

@@ -61,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.");

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

}
const {

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

} = err;
if (loc) {

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

});
if (missingPlugin) {

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

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

@@ -8,20 +8,22 @@ "use strict";

const pluginNameMap = {
classProperties: {
asyncDoExpressions: {
syntax: {
name: "@babel/plugin-syntax-class-properties",
url: "https://git.io/vb4yQ"
},
transform: {
name: "@babel/plugin-proposal-class-properties",
url: "https://git.io/vb4SL"
name: "@babel/plugin-syntax-async-do-expressions",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-async-do-expressions"
}
},
decimal: {
syntax: {
name: "@babel/plugin-syntax-decimal",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decimal"
}
},
decorators: {
syntax: {
name: "@babel/plugin-syntax-decorators",
url: "https://git.io/vb4y9"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-decorators"
},
transform: {
name: "@babel/plugin-proposal-decorators",
url: "https://git.io/vb4ST"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-decorators"
}

@@ -32,43 +34,27 @@ },

name: "@babel/plugin-syntax-do-expressions",
url: "https://git.io/vb4yh"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-do-expressions"
},
transform: {
name: "@babel/plugin-proposal-do-expressions",
url: "https://git.io/vb4S3"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-do-expressions"
}
},
dynamicImport: {
syntax: {
name: "@babel/plugin-syntax-dynamic-import",
url: "https://git.io/vb4Sv"
}
},
exportDefaultFrom: {
syntax: {
name: "@babel/plugin-syntax-export-default-from",
url: "https://git.io/vb4SO"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-export-default-from"
},
transform: {
name: "@babel/plugin-proposal-export-default-from",
url: "https://git.io/vb4yH"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-export-default-from"
}
},
exportNamespaceFrom: {
syntax: {
name: "@babel/plugin-syntax-export-namespace-from",
url: "https://git.io/vb4Sf"
},
transform: {
name: "@babel/plugin-proposal-export-namespace-from",
url: "https://git.io/vb4SG"
}
},
flow: {
syntax: {
name: "@babel/plugin-syntax-flow",
url: "https://git.io/vb4yb"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-flow"
},
transform: {
name: "@babel/plugin-transform-flow-strip-types",
url: "https://git.io/vb49g"
name: "@babel/preset-flow",
url: "https://github.com/babel/babel/tree/main/packages/babel-preset-flow"
}

@@ -79,7 +65,7 @@ },

name: "@babel/plugin-syntax-function-bind",
url: "https://git.io/vb4y7"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-function-bind"
},
transform: {
name: "@babel/plugin-proposal-function-bind",
url: "https://git.io/vb4St"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-function-bind"
}

@@ -90,63 +76,33 @@ },

name: "@babel/plugin-syntax-function-sent",
url: "https://git.io/vb4yN"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-function-sent"
},
transform: {
name: "@babel/plugin-proposal-function-sent",
url: "https://git.io/vb4SZ"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-function-sent"
}
},
importMeta: {
syntax: {
name: "@babel/plugin-syntax-import-meta",
url: "https://git.io/vbKK6"
}
},
jsx: {
syntax: {
name: "@babel/plugin-syntax-jsx",
url: "https://git.io/vb4yA"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx"
},
transform: {
name: "@babel/plugin-transform-react-jsx",
url: "https://git.io/vb4yd"
name: "@babel/preset-react",
url: "https://github.com/babel/babel/tree/main/packages/babel-preset-react"
}
},
logicalAssignment: {
importAttributes: {
syntax: {
name: "@babel/plugin-syntax-logical-assignment-operators",
url: "https://git.io/vAlBp"
},
transform: {
name: "@babel/plugin-proposal-logical-assignment-operators",
url: "https://git.io/vAlRe"
name: "@babel/plugin-syntax-import-attributes",
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes"
}
},
numericSeparator: {
syntax: {
name: "@babel/plugin-syntax-numeric-separator",
url: "https://git.io/vb4Sq"
},
transform: {
name: "@babel/plugin-proposal-numeric-separator",
url: "https://git.io/vb4yS"
}
},
optionalChaining: {
syntax: {
name: "@babel/plugin-syntax-optional-chaining",
url: "https://git.io/vb4Sc"
},
transform: {
name: "@babel/plugin-proposal-optional-chaining",
url: "https://git.io/vb4Sk"
}
},
pipelineOperator: {
syntax: {
name: "@babel/plugin-syntax-pipeline-operator",
url: "https://git.io/vb4yj"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-pipeline-operator"
},
transform: {
name: "@babel/plugin-proposal-pipeline-operator",
url: "https://git.io/vb4SU"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-pipeline-operator"
}

@@ -157,3 +113,3 @@ },

name: "@babel/plugin-syntax-record-and-tuple",
url: "https://git.io/JvKp3"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-record-and-tuple"
}

@@ -164,7 +120,7 @@ },

name: "@babel/plugin-syntax-throw-expressions",
url: "https://git.io/vb4SJ"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-throw-expressions"
},
transform: {
name: "@babel/plugin-proposal-throw-expressions",
url: "https://git.io/vb4yF"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-throw-expressions"
}

@@ -175,51 +131,178 @@ },

name: "@babel/plugin-syntax-typescript",
url: "https://git.io/vb4SC"
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-typescript"
},
transform: {
name: "@babel/plugin-transform-typescript",
url: "https://git.io/vb4Sm"
name: "@babel/preset-typescript",
url: "https://github.com/babel/babel/tree/main/packages/babel-preset-typescript"
}
},
asyncGenerators: {
syntax: {
name: "@babel/plugin-syntax-async-generators",
url: "https://git.io/vb4SY"
}
};
{
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://git.io/vb4yp"
}
},
nullishCoalescingOperator: {
syntax: {
name: "@babel/plugin-syntax-nullish-coalescing-operator",
url: "https://git.io/vb4yx"
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-nullish-coalescing-operator",
url: "https://git.io/vb4Se"
}
},
objectRestSpread: {
syntax: {
name: "@babel/plugin-syntax-object-rest-spread",
url: "https://git.io/vb4y5"
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-object-rest-spread",
url: "https://git.io/vb4Ss"
}
},
optionalCatchBinding: {
syntax: {
name: "@babel/plugin-syntax-optional-catch-binding",
url: "https://git.io/vb4Sn"
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-optional-catch-binding",
url: "https://git.io/vb4SI"
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"
}
},
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"
}
}
}
};
});
}
const getNameURLCombination = ({

@@ -229,7 +312,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) {

@@ -240,9 +321,10 @@ const {

} = pluginInfo;
if (syntaxPlugin) {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
if (transformPlugin) {
const transformPluginInfo = getNameURLCombination(transformPlugin);
helpMessage += `\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` + `to enable transformation.`;
const sectionType = transformPlugin.name.startsWith("@babel/plugin") ? "plugins" : "presets";
helpMessage += `\n\nAdd ${transformPluginInfo} to the '${sectionType}' section of your Babel config to enable transformation.
If you want to leave it as-is, add ${syntaxPluginInfo} to the 'plugins' section to enable parsing.`;
} else {
const syntaxPluginInfo = getNameURLCombination(syntaxPlugin);
helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`;

@@ -252,4 +334,6 @@ }

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

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

exports.default = _default;
function helpers() {
const data = _interopRequireWildcard(require("@babel/helpers"));
const data = require("@babel/helpers");
helpers = function () {
return data;
};
return data;
}
function _generator() {
const data = _interopRequireDefault(require("@babel/generator"));
const data = require("@babel/generator");
_generator = function () {
return data;
};
return data;
}
function _template() {
const data = _interopRequireDefault(require("@babel/template"));
const data = require("@babel/template");
_template = function () {
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
function _t() {
const data = require("@babel/types");
_t = function () {
return data;
};
return data;
}
var _file = _interopRequireDefault(require("../transformation/file/file"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const buildUmdWrapper = replacements => (0, _template().default)`
var _file = require("../transformation/file/file.js");
const {
arrayExpression,
assignmentExpression,
binaryExpression,
blockStatement,
callExpression,
cloneNode,
conditionalExpression,
exportNamedDeclaration,
exportSpecifier,
expressionStatement,
functionExpression,
identifier,
memberExpression,
objectExpression,
program,
stringLiteral,
unaryExpression,
variableDeclaration,
variableDeclarator
} = _t();
const buildUmdWrapper = replacements => _template().default.statement`
(function (root, factory) {

@@ -70,55 +71,49 @@ if (typeof define === "function" && define.amd) {

`(replacements);
function buildGlobal(whitelist) {
const namespace = t().identifier("babelHelpers");
function buildGlobal(allowlist) {
const namespace = identifier("babelHelpers");
const body = [];
const container = t().functionExpression(null, [t().identifier("global")], t().blockStatement(body));
const tree = t().program([t().expressionStatement(t().callExpression(container, [t().conditionalExpression(t().binaryExpression("===", t().unaryExpression("typeof", t().identifier("global")), t().stringLiteral("undefined")), t().identifier("self"), t().identifier("global"))]))]);
body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().assignmentExpression("=", t().memberExpression(t().identifier("global"), namespace), t().objectExpression([])))]));
buildHelpers(body, namespace, whitelist);
const container = functionExpression(null, [identifier("global")], blockStatement(body));
const tree = program([expressionStatement(callExpression(container, [conditionalExpression(binaryExpression("===", unaryExpression("typeof", identifier("global")), stringLiteral("undefined")), identifier("self"), identifier("global"))]))]);
body.push(variableDeclaration("var", [variableDeclarator(namespace, assignmentExpression("=", memberExpression(identifier("global"), namespace), objectExpression([])))]));
buildHelpers(body, namespace, allowlist);
return tree;
}
function buildModule(whitelist) {
function buildModule(allowlist) {
const body = [];
const refs = buildHelpers(body, null, whitelist);
body.unshift(t().exportNamedDeclaration(null, Object.keys(refs).map(name => {
return t().exportSpecifier(t().cloneNode(refs[name]), t().identifier(name));
const refs = buildHelpers(body, null, allowlist);
body.unshift(exportNamedDeclaration(null, Object.keys(refs).map(name => {
return exportSpecifier(cloneNode(refs[name]), identifier(name));
})));
return t().program(body, [], "module");
return program(body, [], "module");
}
function buildUmd(whitelist) {
const namespace = t().identifier("babelHelpers");
function buildUmd(allowlist) {
const namespace = identifier("babelHelpers");
const body = [];
body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().identifier("global"))]));
buildHelpers(body, namespace, whitelist);
return t().program([buildUmdWrapper({
FACTORY_PARAMETERS: t().identifier("global"),
BROWSER_ARGUMENTS: t().assignmentExpression("=", t().memberExpression(t().identifier("root"), namespace), t().objectExpression([])),
COMMON_ARGUMENTS: t().identifier("exports"),
AMD_ARGUMENTS: t().arrayExpression([t().stringLiteral("exports")]),
body.push(variableDeclaration("var", [variableDeclarator(namespace, identifier("global"))]));
buildHelpers(body, namespace, allowlist);
return program([buildUmdWrapper({
FACTORY_PARAMETERS: identifier("global"),
BROWSER_ARGUMENTS: assignmentExpression("=", memberExpression(identifier("root"), namespace), objectExpression([])),
COMMON_ARGUMENTS: identifier("exports"),
AMD_ARGUMENTS: arrayExpression([stringLiteral("exports")]),
FACTORY_BODY: body,
UMD_ROOT: t().identifier("this")
UMD_ROOT: identifier("this")
})]);
}
function buildVar(whitelist) {
const namespace = t().identifier("babelHelpers");
function buildVar(allowlist) {
const namespace = identifier("babelHelpers");
const body = [];
body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().objectExpression([]))]));
const tree = t().program(body);
buildHelpers(body, namespace, whitelist);
body.push(t().expressionStatement(namespace));
body.push(variableDeclaration("var", [variableDeclarator(namespace, objectExpression([]))]));
const tree = program(body);
buildHelpers(body, namespace, allowlist);
body.push(expressionStatement(namespace));
return tree;
}
function buildHelpers(body, namespace, whitelist) {
function buildHelpers(body, namespace, allowlist) {
const getHelperReference = name => {
return namespace ? t().memberExpression(namespace, t().identifier(name)) : t().identifier(`_${name}`);
return namespace ? memberExpression(namespace, identifier(name)) : identifier(`_${name}`);
};
const refs = {};
helpers().list.forEach(function (name) {
if (whitelist && whitelist.indexOf(name) < 0) return;
if (allowlist && allowlist.indexOf(name) < 0) return;
const ref = refs[name] = getHelperReference(name);

@@ -133,4 +128,3 @@ helpers().ensure(name, _file.default);

}
function _default(whitelist, outputType = "global") {
function _default(allowlist, outputType = "global") {
let tree;

@@ -143,10 +137,11 @@ const build = {

}[outputType];
if (build) {
tree = build(whitelist);
tree = build(allowlist);
} else {
throw new Error(`Unsupported output type ${outputType}`);
}
return (0, _generator().default)(tree).code;
}
0 && 0;
return (0, _generator().default)(tree).code;
}
//# sourceMappingURL=build-external-helpers.js.map

@@ -6,44 +6,47 @@ "use strict";

});
exports.transformFromAstAsync = exports.transformFromAstSync = exports.transformFromAst = void 0;
exports.transformFromAst = void 0;
exports.transformFromAstAsync = transformFromAstAsync;
exports.transformFromAstSync = transformFromAstSync;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = _interopRequireDefault(require("./config"));
var _transformation = require("./transformation");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const transformFromAstRunner = (0, _gensync().default)(function* (ast, code, opts) {
const config = yield* (0, _config.default)(opts);
var _index = require("./config/index.js");
var _index2 = require("./transformation/index.js");
var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js");
const transformFromAstRunner = _gensync()(function* (ast, code, opts) {
const config = yield* (0, _index.default)(opts);
if (config === null) return null;
if (!ast) throw new Error("No AST given");
return yield* (0, _transformation.run)(config, code, ast);
return yield* (0, _index2.run)(config, code, ast);
});
const transformFromAst = function transformFromAst(ast, code, opts, callback) {
if (typeof opts === "function") {
callback = opts;
const transformFromAst = function transformFromAst(ast, code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {
callback = optsOrCallback;
opts = undefined;
} else {
opts = optsOrCallback;
callback = maybeCallback;
}
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;
//# sourceMappingURL=transform-ast.js.map

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

});
exports.transformFile = void 0;
exports.transformFileAsync = transformFileAsync;
exports.transformFileSync = transformFileSync;
exports.transformFileAsync = transformFileAsync;
exports.transformFile = void 0;
const transformFile = function transformFile(filename, opts, callback) {

@@ -15,14 +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;
//# sourceMappingURL=transform-file-browser.js.map

@@ -6,50 +6,36 @@ "use strict";

});
exports.transformFileAsync = exports.transformFileSync = exports.transformFile = void 0;
exports.transformFile = transformFile;
exports.transformFileAsync = transformFileAsync;
exports.transformFileSync = transformFileSync;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = _interopRequireDefault(require("./config"));
var _transformation = require("./transformation");
var fs = _interopRequireWildcard(require("./gensync-utils/fs"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _index = require("./config/index.js");
var _index2 = require("./transformation/index.js");
var fs = require("./gensync-utils/fs.js");
({});
const transformFileRunner = (0, _gensync().default)(function* (filename, opts) {
let options;
if (opts == null) {
options = {
filename
};
} else if (opts && typeof opts === "object") {
options = Object.assign({}, opts, {
filename
});
}
const config = yield* (0, _config.default)(options);
const transformFileRunner = _gensync()(function* (filename, opts) {
const options = Object.assign({}, opts, {
filename
});
const config = yield* (0, _index.default)(options);
if (config === null) return null;
const code = yield* fs.readFile(filename, "utf8");
return yield* (0, _transformation.run)(config, code);
return yield* (0, _index2.run)(config, code);
});
const transformFile = transformFileRunner.errback;
exports.transformFile = transformFile;
const transformFileSync = transformFileRunner.sync;
exports.transformFileSync = transformFileSync;
const transformFileAsync = transformFileRunner.async;
exports.transformFileAsync = transformFileAsync;
function transformFile(...args) {
transformFileRunner.errback(...args);
}
function transformFileSync(...args) {
return transformFileRunner.sync(...args);
}
function transformFileAsync(...args) {
return transformFileRunner.async(...args);
}
0 && 0;
//# sourceMappingURL=transform-file.js.map

@@ -6,40 +6,46 @@ "use strict";

});
exports.transformAsync = exports.transformSync = exports.transform = void 0;
exports.transform = void 0;
exports.transformAsync = transformAsync;
exports.transformSync = transformSync;
function _gensync() {
const data = _interopRequireDefault(require("gensync"));
const data = require("gensync");
_gensync = function () {
return data;
};
return data;
}
var _config = _interopRequireDefault(require("./config"));
var _transformation = require("./transformation");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const transformRunner = (0, _gensync().default)(function* transform(code, opts) {
const config = yield* (0, _config.default)(opts);
var _index = require("./config/index.js");
var _index2 = require("./transformation/index.js");
var _rewriteStackTrace = require("./errors/rewrite-stack-trace.js");
const transformRunner = _gensync()(function* transform(code, opts) {
const config = yield* (0, _index.default)(opts);
if (config === null) return null;
return yield* (0, _transformation.run)(config, code);
return yield* (0, _index2.run)(config, code);
});
const transform = function transform(code, opts, callback) {
if (typeof opts === "function") {
callback = opts;
const transform = function transform(code, optsOrCallback, maybeCallback) {
let opts;
let callback;
if (typeof optsOrCallback === "function") {
callback = optsOrCallback;
opts = undefined;
} else {
opts = optsOrCallback;
callback = maybeCallback;
}
if (callback === undefined) return transformRunner.sync(code, opts);
transformRunner.errback(code, opts, callback);
if (callback === undefined) {
{
return (0, _rewriteStackTrace.beginHiddenCallStack)(transformRunner.sync)(code, opts);
}
}
(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;
//# sourceMappingURL=transform.js.map

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

exports.default = loadBlockHoistPlugin;
function _sortBy() {
const data = _interopRequireDefault(require("lodash/sortBy"));
_sortBy = function () {
function _traverse() {
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
var _config = _interopRequireDefault(require("../config"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _plugin = require("../config/plugin.js");
let LOADED_PLUGIN;
function loadBlockHoistPlugin() {
if (!LOADED_PLUGIN) {
const config = _config.default.sync({
babelrc: false,
configFile: false,
plugins: [blockHoistPlugin]
});
LOADED_PLUGIN = config ? config.passes[0][0] : undefined;
if (!LOADED_PLUGIN) throw new Error("Assertion failure");
}
return LOADED_PLUGIN;
}
const blockHoistPlugin = {

@@ -47,24 +24,56 @@ name: "internal.blockHoist",

}) {
const {
body
} = node;
let max = Math.pow(2, 30) - 1;
let hasChange = false;
for (let i = 0; i < node.body.length; i++) {
const bodyNode = node.body[i];
if (bodyNode && bodyNode._blockHoist != null) {
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 = (0, _sortBy().default)(node.body, function (bodyNode) {
let priority = bodyNode && bodyNode._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;
return -1 * priority;
});
node.body = stableSort(body.slice());
}
}
}
};
};
function loadBlockHoistPlugin() {
if (!LOADED_PLUGIN) {
LOADED_PLUGIN = new _plugin.default(Object.assign({}, blockHoistPlugin, {
visitor: _traverse().default.explode(blockHoistPlugin.visitor)
}), {});
}
return LOADED_PLUGIN;
}
function priority(bodyNode) {
const priority = bodyNode == null ? void 0 : bodyNode._blockHoist;
if (priority == null) return 1;
if (priority === true) return 2;
return priority;
}
function stableSort(body) {
const buckets = Object.create(null);
for (let i = 0; i < body.length; i++) {
const n = body[i];
const p = priority(n);
const bucket = buckets[p] || (buckets[p] = []);
bucket.push(n);
}
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) {
body[index++] = n;
}
}
return body;
}
0 && 0;
//# sourceMappingURL=block-hoist-plugin.js.map

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

exports.default = void 0;
function helpers() {
const data = _interopRequireWildcard(require("@babel/helpers"));
const data = require("@babel/helpers");
helpers = function () {
return data;
};
return data;
}
function _traverse() {
const data = _interopRequireWildcard(require("@babel/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 = _interopRequireWildcard(require("@babel/types"));
t = function () {
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 = _interopRequireDefault(require("semver"));
const data = require("semver");
_semver = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const {
cloneNode,
interpreterDirective
} = _t();
const errorVisitor = {
enter(path, state) {
const loc = path.node.loc;
if (loc) {

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

}
};
class File {

@@ -95,8 +71,10 @@ constructor(options, {

this._map = new Map();
this.opts = void 0;
this.declarations = {};
this.path = null;
this.ast = {};
this.path = void 0;
this.ast = void 0;
this.scope = void 0;
this.metadata = {};
this.code = "";
this.inputMap = null;
this.inputMap = void 0;
this.hub = {

@@ -122,3 +100,2 @@ file: this,

}
get shebang() {

@@ -130,6 +107,5 @@ const {

}
set shebang(value) {
if (value) {
this.path.get("interpreter").replaceWith(t().interpreterDirective(value));
this.path.get("interpreter").replaceWith(interpreterDirective(value));
} else {

@@ -139,3 +115,2 @@ this.path.get("interpreter").remove();

}
set(key, val) {

@@ -145,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 {

@@ -175,13 +143,10 @@ minVersion = helpers().minVersion(name);

}
if (typeof versionRange !== "string") return true;
if (_semver().default.valid(versionRange)) versionRange = `^${versionRange}`;
return !_semver().default.intersects(`<${minVersion}`, versionRange) && !_semver().default.intersects(`>=8.0.0`, versionRange);
if (_semver().valid(versionRange)) versionRange = `^${versionRange}`;
return !_semver().intersects(`<${minVersion}`, versionRange) && !_semver().intersects(`>=8.0.0`, versionRange);
}
addHelper(name) {
const declar = this.declarations[name];
if (declar) return t().cloneNode(declar);
if (declar) return cloneNode(declar);
const generator = this.get("helperGenerator");
if (generator) {

@@ -191,11 +156,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 {

@@ -220,10 +182,7 @@ nodes,

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

@@ -239,3 +198,2 @@ const state = {

}
if (loc) {

@@ -258,8 +216,8 @@ const {

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

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

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

@@ -40,4 +30,7 @@ const {

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

@@ -48,5 +41,4 @@ for (const plugin of plugins) {

} = plugin;
if (generatorOverride) {
const result = generatorOverride(ast, opts.generatorOpts, code, _generator().default);
const result = generatorOverride(ast, generatorOpts, code, _generator().default);
if (result !== undefined) results.push(result);

@@ -56,10 +48,7 @@ }

}
let result;
if (results.length === 0) {
result = (0, _generator().default)(ast, opts.generatorOpts, code);
result = (0, _generator().default)(ast, generatorOpts, code);
} else if (results.length === 1) {
result = results[0];
if (typeof result.then === "function") {

@@ -71,20 +60,23 @@ 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 {
code: outputCode,
map: outputMap
decodedMap: outputMap = result.map
} = result;
if (outputMap && inputMap) {
outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap);
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().default.fromObject(outputMap).toComment();
outputCode += "\n" + _convertSourceMap().fromObject(outputMap).toComment();
}
if (opts.sourceMaps === "inline") {
outputMap = null;
}
return {

@@ -94,2 +86,5 @@ outputCode,

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

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

exports.default = mergeSourceMap;
function _sourceMap() {
const data = _interopRequireDefault(require("source-map"));
_sourceMap = function () {
function _remapping() {
const data = require("@ampproject/remapping");
_remapping = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function mergeSourceMap(inputMap, map) {
const input = buildMappingData(inputMap);
const output = buildMappingData(map);
const mergedGenerator = new (_sourceMap().default.SourceMapGenerator)();
for (const {
source
} of input.sources) {
if (typeof source.content === "string") {
mergedGenerator.setSourceContent(source.path, source.content);
function mergeSourceMap(inputMap, map, sourceFileName) {
const source = sourceFileName.replace(/\\/g, "/");
let found = false;
const result = _remapping()(rootless(map), (s, ctx) => {
if (s === source && !found) {
found = true;
ctx.source = "";
return rootless(inputMap);
}
}
if (output.sources.length === 1) {
const defaultSource = output.sources[0];
const insertedMappings = new Map();
eachInputGeneratedRange(input, (generated, original, source) => {
eachOverlappingGeneratedOutputRange(defaultSource, generated, item => {
const key = makeMappingKey(item);
if (insertedMappings.has(key)) return;
insertedMappings.set(key, item);
mergedGenerator.addMapping({
source: source.path,
original: {
line: original.line,
column: original.columnStart
},
generated: {
line: item.line,
column: item.columnStart
},
name: original.name
});
});
});
for (const item of insertedMappings.values()) {
if (item.columnEnd === Infinity) {
continue;
}
const clearItem = {
line: item.line,
columnStart: item.columnEnd
};
const key = makeMappingKey(clearItem);
if (insertedMappings.has(key)) {
continue;
}
mergedGenerator.addMapping({
generated: {
line: clearItem.line,
column: clearItem.columnStart
}
});
}
}
const result = mergedGenerator.toJSON();
if (typeof input.sourceRoot === "string") {
result.sourceRoot = input.sourceRoot;
}
return result;
}
function makeMappingKey(item) {
return `${item.line}/${item.columnStart}`;
}
function eachOverlappingGeneratedOutputRange(outputFile, inputGeneratedRange, callback) {
const overlappingOriginal = filterApplicableOriginalRanges(outputFile, inputGeneratedRange);
for (const {
generated
} of overlappingOriginal) {
for (const item of generated) {
callback(item);
}
}
}
function filterApplicableOriginalRanges({
mappings
}, {
line,
columnStart,
columnEnd
}) {
return filterSortedArray(mappings, ({
original: outOriginal
}) => {
if (line > outOriginal.line) return -1;
if (line < outOriginal.line) return 1;
if (columnStart >= outOriginal.columnEnd) return -1;
if (columnEnd <= outOriginal.columnStart) return 1;
return 0;
return null;
});
}
function eachInputGeneratedRange(map, callback) {
for (const {
source,
mappings
} of map.sources) {
for (const {
original,
generated
} of mappings) {
for (const item of generated) {
callback(item, original, source);
}
}
if (typeof inputMap.sourceRoot === "string") {
result.sourceRoot = inputMap.sourceRoot;
}
return Object.assign({}, result);
}
function buildMappingData(map) {
const consumer = new (_sourceMap().default.SourceMapConsumer)(Object.assign({}, map, {
function rootless(map) {
return Object.assign({}, map, {
sourceRoot: null
}));
const sources = new Map();
const mappings = new Map();
let last = null;
consumer.computeColumnSpans();
consumer.eachMapping(m => {
if (m.originalLine === null) return;
let source = sources.get(m.source);
if (!source) {
source = {
path: m.source,
content: consumer.sourceContentFor(m.source, true)
};
sources.set(m.source, source);
}
let sourceData = mappings.get(source);
if (!sourceData) {
sourceData = {
source,
mappings: []
};
mappings.set(source, sourceData);
}
const obj = {
line: m.originalLine,
columnStart: m.originalColumn,
columnEnd: Infinity,
name: m.name
};
if (last && last.source === source && last.mapping.line === m.originalLine) {
last.mapping.columnEnd = m.originalColumn;
}
last = {
source,
mapping: obj
};
sourceData.mappings.push({
original: obj,
generated: consumer.allGeneratedPositionsFor({
source: m.source,
line: m.originalLine,
column: m.originalColumn
}).map(item => ({
line: item.line,
columnStart: item.column,
columnEnd: item.lastColumn + 1
}))
});
}, null, _sourceMap().default.SourceMapConsumer.ORIGINAL_ORDER);
return {
file: map.file,
sourceRoot: map.sourceRoot,
sources: Array.from(mappings.values())
};
});
}
0 && 0;
function findInsertionLocation(array, callback) {
let left = 0;
let right = array.length;
while (left < right) {
const mid = Math.floor((left + right) / 2);
const item = array[mid];
const result = callback(item);
if (result === 0) {
left = mid;
break;
}
if (result >= 0) {
right = mid;
} else {
left = mid + 1;
}
}
let i = left;
if (i < array.length) {
while (i >= 0 && callback(array[i]) >= 0) {
i--;
}
return i + 1;
}
return i;
}
function filterSortedArray(array, callback) {
const start = findInsertionLocation(array, callback);
const results = [];
for (let i = start; i < array.length && callback(array[i]) === 0; i++) {
results.push(array[i]);
}
return results;
}
//# sourceMappingURL=merge-map.js.map

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

exports.run = run;
function _traverse() {
const data = _interopRequireDefault(require("@babel/traverse"));
const data = require("@babel/traverse");
_traverse = function () {
return data;
};
return data;
}
var _pluginPass = _interopRequireDefault(require("./plugin-pass"));
var _blockHoistPlugin = _interopRequireDefault(require("./block-hoist-plugin"));
var _normalizeOpts = _interopRequireDefault(require("./normalize-opts"));
var _normalizeFile = _interopRequireDefault(require("./normalize-file"));
var _generate = _interopRequireDefault(require("./file/generate"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _pluginPass = require("./plugin-pass.js");
var _blockHoistPlugin = require("./block-hoist-plugin.js");
var _normalizeOpts = require("./normalize-opts.js");
var _normalizeFile = require("./normalize-file.js");
var _generate = require("./file/generate.js");
var _deepArray = require("../config/helpers/deep-array.js");
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 {

@@ -78,6 +58,6 @@ metadata: file.metadata,

map: outputMap === undefined ? null : outputMap,
sourceType: file.ast.program.sourceType
sourceType: file.ast.program.sourceType,
externalDependencies: (0, _deepArray.flattenToSet)(config.externalDependencies)
};
}
function* transformFile(file, pluginPasses) {

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

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

@@ -96,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)) {

@@ -110,14 +86,11 @@ 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);
{
(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)) {

@@ -130,5 +103,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;
//# sourceMappingURL=index.js.map

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

exports.default = normalizeFile;
function _fs() {
const data = _interopRequireDefault(require("fs"));
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _debug() {
const data = _interopRequireDefault(require("debug"));
const data = require("debug");
_debug = function () {
return data;
};
return data;
}
function _cloneDeep() {
const data = _interopRequireDefault(require("lodash/cloneDeep"));
_cloneDeep = function () {
function _t() {
const data = require("@babel/types");
_t = function () {
return data;
};
return data;
}
function t() {
const data = _interopRequireWildcard(require("@babel/types"));
t = function () {
return data;
};
return data;
}
function _convertSourceMap() {
const data = _interopRequireDefault(require("convert-source-map"));
const data = require("convert-source-map");
_convertSourceMap = function () {
return data;
};
return data;
}
var _file = _interopRequireDefault(require("./file/file"));
var _parser = _interopRequireDefault(require("../parser"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const debug = (0, _debug().default)("babel:transform:file");
const LARGE_INPUT_SOURCEMAP_THRESHOLD = 1000000;
var _file = require("./file/file.js");
var _index = require("../parser/index.js");
var _cloneDeep = require("./util/clone-deep.js");
const {
file,
traverseFast
} = _t();
const debug = _debug()("babel:transform:file");
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) {
if (ast.type === "Program") {
ast = t().file(ast, [], []);
ast = file(ast, [], []);
} else if (ast.type !== "File") {
throw new Error("AST root must be a Program or File node");
}
ast = (0, _cloneDeep().default)(ast);
if (options.cloneInputAst) {
ast = (0, _cloneDeep.default)(ast);
}
} else {
ast = yield* (0, _parser.default)(pluginPasses, options, code);
ast = yield* (0, _index.default)(pluginPasses, options, code);
}
let inputMap = null;
if (options.inputSourceMap !== false) {
if (typeof options.inputSourceMap === "object") {
inputMap = _convertSourceMap().default.fromObject(options.inputSourceMap);
inputMap = _convertSourceMap().fromObject(options.inputSourceMap);
}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = _convertSourceMap().default.fromComment(lastComment);
inputMap = _convertSourceMap().fromComment("//" + lastComment);
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
{
debug("discarding unknown inline input sourcemap");
}
}
}
}
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().default.readFileSync(_path().default.resolve(_path().default.dirname(options.filename), match[1]));
if (inputMapContent.length > LARGE_INPUT_SOURCEMAP_THRESHOLD) {
debug("skip merging input map > 1 MB");
} else {
inputMap = _convertSourceMap().default.fromJSON(inputMapContent);
}
const inputMapContent = _fs().readFileSync(_path().resolve(_path().dirname(options.filename), match[1]), "utf8");
inputMap = _convertSourceMap().fromJSON(inputMapContent);
} catch (err) {

@@ -138,13 +99,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) {

@@ -159,13 +115,10 @@ if (comments) {

}
return true;
});
}
return [comments, lastComment];
}
function extractComments(regex, ast) {
let lastComment = null;
t().traverseFast(ast, node => {
traverseFast(ast, node => {
[node.leadingComments, lastComment] = extractCommentsFromList(regex, node.leadingComments, lastComment);

@@ -176,2 +129,5 @@ [node.innerComments, lastComment] = extractCommentsFromList(regex, node.innerComments, lastComment);

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

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

exports.default = normalizeOptions;
function _path() {
const data = _interopRequireDefault(require("path"));
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function normalizeOptions(config) {

@@ -25,9 +19,8 @@ const {

cwd,
filenameRelative = typeof filename === "string" ? _path().default.relative(cwd, filename) : "unknown",
filenameRelative = typeof filename === "string" ? _path().relative(cwd, filename) : "unknown",
sourceType = "module",
inputSourceMap,
sourceMaps = !!inputSourceMap,
moduleRoot,
sourceRoot = moduleRoot,
sourceFileName = _path().default.basename(filenameRelative),
sourceRoot = config.options.moduleRoot,
sourceFileName = _path().basename(filenameRelative),
comments = true,

@@ -39,3 +32,3 @@ compact = "auto"

parserOpts: Object.assign({
sourceType: _path().default.extname(filenameRelative) === ".mjs" ? "module" : sourceType,
sourceType: _path().extname(filenameRelative) === ".mjs" ? "module" : sourceType,
sourceFileName: filename,

@@ -58,3 +51,2 @@ plugins: []

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

@@ -67,4 +59,6 @@ for (const plugin of plugins) {

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

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

exports.default = void 0;
class PluginPass {
constructor(file, key, options) {
this._map = new Map();
this.key = void 0;
this.file = void 0;
this.opts = void 0;
this.cwd = void 0;
this.filename = void 0;
this.key = key;

@@ -18,33 +22,29 @@ this.file = file;

}
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);
}
getModuleName() {
}
exports.default = PluginPass;
{
PluginPass.prototype.getModuleName = function getModuleName() {
return this.file.getModuleName();
}
buildCodeFrameError(node, msg, Error) {
return this.file.buildCodeFrameError(node, msg, Error);
}
};
PluginPass.prototype.addImport = function addImport() {
this.file.addImport();
};
}
0 && 0;
exports.default = PluginPass;
//# sourceMappingURL=plugin-pass.js.map
{
"name": "@babel/core",
"version": "7.9.0",
"version": "7.23.0",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"main": "./lib/index.js",
"author": "The Babel Team (https://babel.dev/team)",
"license": "MIT",

@@ -12,3 +11,9 @@ "publishConfig": {

},
"repository": "https://github.com/babel/babel/tree/master/packages/babel-core",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-core"
},
"homepage": "https://babel.dev/docs/en/next/babel-core",
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen",
"keywords": [

@@ -38,28 +43,42 @@ "6to5",

"./lib/config/files/index.js": "./lib/config/files/index-browser.js",
"./lib/config/resolve-targets.js": "./lib/config/resolve-targets-browser.js",
"./lib/transform-file.js": "./lib/transform-file-browser.js",
"./src/config/files/index.js": "./src/config/files/index-browser.js",
"./src/transform-file.js": "./src/transform-file-browser.js"
"./src/config/files/index.ts": "./src/config/files/index-browser.ts",
"./src/config/resolve-targets.ts": "./src/config/resolve-targets-browser.ts",
"./src/transform-file.ts": "./src/transform-file-browser.ts"
},
"dependencies": {
"@babel/code-frame": "^7.8.3",
"@babel/generator": "^7.9.0",
"@babel/helper-module-transforms": "^7.9.0",
"@babel/helpers": "^7.9.0",
"@babel/parser": "^7.9.0",
"@babel/template": "^7.8.6",
"@babel/traverse": "^7.9.0",
"@babel/types": "^7.9.0",
"convert-source-map": "^1.7.0",
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.22.13",
"@babel/generator": "^7.23.0",
"@babel/helper-compilation-targets": "^7.22.15",
"@babel/helper-module-transforms": "^7.23.0",
"@babel/helpers": "^7.23.0",
"@babel/parser": "^7.23.0",
"@babel/template": "^7.22.15",
"@babel/traverse": "^7.23.0",
"@babel/types": "^7.23.0",
"convert-source-map": "^2.0.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.1",
"json5": "^2.1.2",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
"gensync": "^1.0.0-beta.2",
"json5": "^2.2.3",
"semver": "^6.3.1"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.8.3"
"@babel/helper-transform-fixture-test-runner": "^7.22.19",
"@babel/plugin-syntax-flow": "^7.22.5",
"@babel/plugin-transform-flow-strip-types": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.23.0",
"@jridgewell/trace-mapping": "^0.3.17",
"@types/convert-source-map": "^2.0.0",
"@types/debug": "^4.1.0",
"@types/gensync": "^1.0.0",
"@types/resolve": "^1.3.2",
"@types/semver": "^5.4.0",
"rimraf": "^3.0.0",
"ts-node": "^10.9.1"
},
"gitHead": "8d5e422be27251cfaadf8dd2536b31b4a5024b02"
}
"type": "commonjs"
}

@@ -5,3 +5,3 @@ # @babel/core

See our website [@babel/core](https://babeljs.io/docs/en/next/babel-core.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen) associated with this package.
See our website [@babel/core](https://babeljs.io/docs/babel-core) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20core%22+is%3Aopen) associated with this package.

@@ -8,0 +8,0 @@ ## Install

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc