mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 04:10:04 +02:00
update node modules
This commit is contained in:
130
node_modules/@babel/core/lib/config/caching.js
generated
vendored
130
node_modules/@babel/core/lib/config/caching.js
generated
vendored
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.makeStrongCache = makeStrongCache;
|
||||
exports.makeWeakCache = makeWeakCache;
|
||||
exports.assertSimpleType = assertSimpleType;
|
||||
|
||||
function makeStrongCache(handler) {
|
||||
return makeCachedFunction(new Map(), handler);
|
||||
@@ -16,47 +17,35 @@ function makeWeakCache(handler) {
|
||||
|
||||
function makeCachedFunction(callCache, handler) {
|
||||
return function cachedFunction(arg, data) {
|
||||
var cachedValue = callCache.get(arg);
|
||||
let cachedValue = callCache.get(arg);
|
||||
|
||||
if (cachedValue) {
|
||||
for (var _iterator = cachedValue, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref2 = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref2 = _i.value;
|
||||
}
|
||||
|
||||
var _ref3 = _ref2;
|
||||
var _value = _ref3.value,
|
||||
_valid = _ref3.valid;
|
||||
if (_valid(data)) return _value;
|
||||
for (const _ref of cachedValue) {
|
||||
const {
|
||||
value,
|
||||
valid
|
||||
} = _ref;
|
||||
if (valid(data)) return value;
|
||||
}
|
||||
}
|
||||
|
||||
var cache = new CacheConfigurator(data);
|
||||
var value = handler(arg, cache);
|
||||
const cache = new CacheConfigurator(data);
|
||||
const value = handler(arg, cache);
|
||||
if (!cache.configured()) cache.forever();
|
||||
cache.deactivate();
|
||||
|
||||
switch (cache.mode()) {
|
||||
case "forever":
|
||||
cachedValue = [{
|
||||
value: value,
|
||||
valid: function valid() {
|
||||
return true;
|
||||
}
|
||||
value,
|
||||
valid: () => true
|
||||
}];
|
||||
callCache.set(arg, cachedValue);
|
||||
break;
|
||||
|
||||
case "invalidate":
|
||||
cachedValue = [{
|
||||
value: value,
|
||||
value,
|
||||
valid: cache.validator()
|
||||
}];
|
||||
callCache.set(arg, cachedValue);
|
||||
@@ -65,12 +54,12 @@ function makeCachedFunction(callCache, handler) {
|
||||
case "valid":
|
||||
if (cachedValue) {
|
||||
cachedValue.push({
|
||||
value: value,
|
||||
value,
|
||||
valid: cache.validator()
|
||||
});
|
||||
} else {
|
||||
cachedValue = [{
|
||||
value: value,
|
||||
value,
|
||||
valid: cache.validator()
|
||||
}];
|
||||
callCache.set(arg, cachedValue);
|
||||
@@ -82,8 +71,8 @@ function makeCachedFunction(callCache, handler) {
|
||||
};
|
||||
}
|
||||
|
||||
var CacheConfigurator = function () {
|
||||
function CacheConfigurator(data) {
|
||||
class CacheConfigurator {
|
||||
constructor(data) {
|
||||
this._active = true;
|
||||
this._never = false;
|
||||
this._forever = false;
|
||||
@@ -93,20 +82,18 @@ var CacheConfigurator = function () {
|
||||
this._data = data;
|
||||
}
|
||||
|
||||
var _proto = CacheConfigurator.prototype;
|
||||
|
||||
_proto.simple = function simple() {
|
||||
simple() {
|
||||
return makeSimpleConfigurator(this);
|
||||
};
|
||||
}
|
||||
|
||||
_proto.mode = function mode() {
|
||||
mode() {
|
||||
if (this._never) return "never";
|
||||
if (this._forever) return "forever";
|
||||
if (this._invalidate) return "invalidate";
|
||||
return "valid";
|
||||
};
|
||||
}
|
||||
|
||||
_proto.forever = function forever() {
|
||||
forever() {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
@@ -117,9 +104,9 @@ var CacheConfigurator = function () {
|
||||
|
||||
this._forever = true;
|
||||
this._configured = true;
|
||||
};
|
||||
}
|
||||
|
||||
_proto.never = function never() {
|
||||
never() {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
@@ -130,9 +117,9 @@ var CacheConfigurator = function () {
|
||||
|
||||
this._never = true;
|
||||
this._configured = true;
|
||||
};
|
||||
}
|
||||
|
||||
_proto.using = function using(handler) {
|
||||
using(handler) {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
@@ -142,14 +129,14 @@ var CacheConfigurator = function () {
|
||||
}
|
||||
|
||||
this._configured = true;
|
||||
var key = handler(this._data);
|
||||
const key = handler(this._data);
|
||||
|
||||
this._pairs.push([key, handler]);
|
||||
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
_proto.invalidate = function invalidate(handler) {
|
||||
invalidate(handler) {
|
||||
if (!this._active) {
|
||||
throw new Error("Cannot change caching after evaluation has completed.");
|
||||
}
|
||||
@@ -160,34 +147,27 @@ var CacheConfigurator = function () {
|
||||
|
||||
this._invalidate = true;
|
||||
this._configured = true;
|
||||
var key = handler(this._data);
|
||||
const key = handler(this._data);
|
||||
|
||||
this._pairs.push([key, handler]);
|
||||
|
||||
return key;
|
||||
};
|
||||
}
|
||||
|
||||
_proto.validator = function validator() {
|
||||
var pairs = this._pairs;
|
||||
return function (data) {
|
||||
return pairs.every(function (_ref4) {
|
||||
var key = _ref4[0],
|
||||
fn = _ref4[1];
|
||||
return key === fn(data);
|
||||
});
|
||||
};
|
||||
};
|
||||
validator() {
|
||||
const pairs = this._pairs;
|
||||
return data => pairs.every(([key, fn]) => key === fn(data));
|
||||
}
|
||||
|
||||
_proto.deactivate = function deactivate() {
|
||||
deactivate() {
|
||||
this._active = false;
|
||||
};
|
||||
}
|
||||
|
||||
_proto.configured = function configured() {
|
||||
configured() {
|
||||
return this._configured;
|
||||
};
|
||||
}
|
||||
|
||||
return CacheConfigurator;
|
||||
}();
|
||||
}
|
||||
|
||||
function makeSimpleConfigurator(cache) {
|
||||
function cacheFn(val) {
|
||||
@@ -196,28 +176,24 @@ function makeSimpleConfigurator(cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
return cache.using(val);
|
||||
return cache.using(() => assertSimpleType(val()));
|
||||
}
|
||||
|
||||
cacheFn.forever = function () {
|
||||
return cache.forever();
|
||||
};
|
||||
cacheFn.forever = () => cache.forever();
|
||||
|
||||
cacheFn.never = function () {
|
||||
return cache.never();
|
||||
};
|
||||
cacheFn.never = () => cache.never();
|
||||
|
||||
cacheFn.using = function (cb) {
|
||||
return cache.using(function () {
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
|
||||
|
||||
cacheFn.invalidate = function (cb) {
|
||||
return cache.invalidate(function () {
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
|
||||
|
||||
return cacheFn;
|
||||
}
|
||||
|
||||
function assertSimpleType(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;
|
||||
}
|
549
node_modules/@babel/core/lib/config/config-chain.js
generated
vendored
549
node_modules/@babel/core/lib/config/config-chain.js
generated
vendored
@@ -3,23 +3,14 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.buildPresetChain = buildPresetChain;
|
||||
exports.buildRootChain = buildRootChain;
|
||||
exports.buildPresetChain = void 0;
|
||||
exports.buildPresetChainWalker = void 0;
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _micromatch() {
|
||||
var data = _interopRequireDefault(require("micromatch"));
|
||||
|
||||
_micromatch = function _micromatch() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -27,9 +18,9 @@ function _micromatch() {
|
||||
}
|
||||
|
||||
function _debug() {
|
||||
var data = _interopRequireDefault(require("debug"));
|
||||
const data = _interopRequireDefault(require("debug"));
|
||||
|
||||
_debug = function _debug() {
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -38,6 +29,8 @@ function _debug() {
|
||||
|
||||
var _options = require("./validation/options");
|
||||
|
||||
var _patternToRegex = _interopRequireDefault(require("./pattern-to-regex"));
|
||||
|
||||
var _files = require("./files");
|
||||
|
||||
var _caching = require("./caching");
|
||||
@@ -46,255 +39,223 @@ var _configDescriptors = require("./config-descriptors");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var debug = (0, _debug().default)("babel:config:config-chain");
|
||||
var buildPresetChain = makeChainWalker({
|
||||
init: function init(arg) {
|
||||
return arg;
|
||||
},
|
||||
root: function root(preset) {
|
||||
return loadPresetDescriptors(preset);
|
||||
},
|
||||
env: function env(preset, envName) {
|
||||
return loadPresetEnvDescriptors(preset)(envName);
|
||||
},
|
||||
overrides: function overrides(preset, index) {
|
||||
return loadPresetOverridesDescriptors(preset)(index);
|
||||
},
|
||||
overridesEnv: function overridesEnv(preset, index, envName) {
|
||||
return loadPresetOverridesEnvDescriptors(preset)(index)(envName);
|
||||
}
|
||||
});
|
||||
exports.buildPresetChain = buildPresetChain;
|
||||
var loadPresetDescriptors = (0, _caching.makeWeakCache)(function (preset) {
|
||||
return buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors);
|
||||
});
|
||||
var loadPresetEnvDescriptors = (0, _caching.makeWeakCache)(function (preset) {
|
||||
return (0, _caching.makeStrongCache)(function (envName) {
|
||||
return buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName);
|
||||
});
|
||||
});
|
||||
var loadPresetOverridesDescriptors = (0, _caching.makeWeakCache)(function (preset) {
|
||||
return (0, _caching.makeStrongCache)(function (index) {
|
||||
return buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index);
|
||||
});
|
||||
});
|
||||
var loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCache)(function (preset) {
|
||||
return (0, _caching.makeStrongCache)(function (index) {
|
||||
return (0, _caching.makeStrongCache)(function (envName) {
|
||||
return buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName);
|
||||
});
|
||||
});
|
||||
const debug = (0, _debug().default)("babel:config:config-chain");
|
||||
|
||||
function buildPresetChain(arg, context) {
|
||||
const chain = buildPresetChainWalker(arg, context);
|
||||
if (!chain) return null;
|
||||
return {
|
||||
plugins: dedupDescriptors(chain.plugins),
|
||||
presets: dedupDescriptors(chain.presets),
|
||||
options: chain.options.map(o => normalizeOptions(o))
|
||||
};
|
||||
}
|
||||
|
||||
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)
|
||||
});
|
||||
exports.buildPresetChainWalker = buildPresetChainWalker;
|
||||
const loadPresetDescriptors = (0, _caching.makeWeakCache)(preset => buildRootDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors));
|
||||
const loadPresetEnvDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(envName => buildEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, envName)));
|
||||
const loadPresetOverridesDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(index => buildOverrideDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index)));
|
||||
const loadPresetOverridesEnvDescriptors = (0, _caching.makeWeakCache)(preset => (0, _caching.makeStrongCache)(index => (0, _caching.makeStrongCache)(envName => buildOverrideEnvDescriptors(preset, preset.alias, _configDescriptors.createUncachedDescriptors, index, envName))));
|
||||
|
||||
function buildRootChain(opts, context) {
|
||||
var programmaticChain = loadProgrammaticChain({
|
||||
const programmaticChain = loadProgrammaticChain({
|
||||
options: opts,
|
||||
dirname: context.cwd
|
||||
}, context);
|
||||
if (!programmaticChain) return null;
|
||||
var _opts$root = opts.root,
|
||||
rootDir = _opts$root === void 0 ? "." : _opts$root,
|
||||
_opts$babelrc = opts.babelrc,
|
||||
babelrc = _opts$babelrc === void 0 ? true : _opts$babelrc,
|
||||
babelrcRoots = opts.babelrcRoots,
|
||||
_opts$configFile = opts.configFile,
|
||||
configFileName = _opts$configFile === void 0 ? true : _opts$configFile;
|
||||
let configFile;
|
||||
|
||||
var absoluteRoot = _path().default.resolve(context.cwd, rootDir);
|
||||
|
||||
var configFile;
|
||||
|
||||
if (typeof configFileName === "string") {
|
||||
configFile = (0, _files.loadConfig)(configFileName, context.cwd, context.envName);
|
||||
} else if (configFileName === true) {
|
||||
configFile = (0, _files.findRootConfig)(absoluteRoot, context.envName);
|
||||
if (typeof opts.configFile === "string") {
|
||||
configFile = (0, _files.loadConfig)(opts.configFile, context.cwd, context.envName, context.caller);
|
||||
} else if (opts.configFile !== false) {
|
||||
configFile = (0, _files.findRootConfig)(context.root, context.envName, context.caller);
|
||||
}
|
||||
|
||||
var configFileChain = emptyChain();
|
||||
let {
|
||||
babelrc,
|
||||
babelrcRoots
|
||||
} = opts;
|
||||
let babelrcRootsDirectory = context.cwd;
|
||||
const configFileChain = emptyChain();
|
||||
|
||||
if (configFile) {
|
||||
var result = loadFileChain(configFile, context);
|
||||
const validatedFile = validateConfigFile(configFile);
|
||||
const result = loadFileChain(validatedFile, context);
|
||||
if (!result) return null;
|
||||
|
||||
if (babelrc === undefined) {
|
||||
babelrc = validatedFile.options.babelrc;
|
||||
}
|
||||
|
||||
if (babelrcRoots === undefined) {
|
||||
babelrcRootsDirectory = validatedFile.dirname;
|
||||
babelrcRoots = validatedFile.options.babelrcRoots;
|
||||
}
|
||||
|
||||
mergeChain(configFileChain, result);
|
||||
}
|
||||
|
||||
var pkgData = typeof context.filename === "string" ? (0, _files.findPackageData)(context.filename) : null;
|
||||
var ignoreFile, babelrcFile;
|
||||
var fileChain = emptyChain();
|
||||
const pkgData = typeof context.filename === "string" ? (0, _files.findPackageData)(context.filename) : null;
|
||||
let ignoreFile, babelrcFile;
|
||||
const fileChain = emptyChain();
|
||||
|
||||
if (babelrc && pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, absoluteRoot)) {
|
||||
var _findRelativeConfig = (0, _files.findRelativeConfig)(pkgData, context.envName);
|
||||
|
||||
ignoreFile = _findRelativeConfig.ignore;
|
||||
babelrcFile = _findRelativeConfig.config;
|
||||
if ((babelrc === true || babelrc === undefined) && pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)) {
|
||||
({
|
||||
ignore: ignoreFile,
|
||||
config: babelrcFile
|
||||
} = (0, _files.findRelativeConfig)(pkgData, context.envName, context.caller));
|
||||
|
||||
if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (babelrcFile) {
|
||||
var _result = loadFileChain(babelrcFile, context);
|
||||
|
||||
if (!_result) return null;
|
||||
mergeChain(fileChain, _result);
|
||||
const result = loadFileChain(validateBabelrcFile(babelrcFile), context);
|
||||
if (!result) return null;
|
||||
mergeChain(fileChain, result);
|
||||
}
|
||||
}
|
||||
|
||||
var chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
|
||||
const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain);
|
||||
return {
|
||||
plugins: dedupDescriptors(chain.plugins),
|
||||
presets: dedupDescriptors(chain.presets),
|
||||
options: chain.options.map(function (o) {
|
||||
return normalizeOptions(o);
|
||||
}),
|
||||
options: chain.options.map(o => normalizeOptions(o)),
|
||||
ignore: ignoreFile || undefined,
|
||||
babelrc: babelrcFile || undefined,
|
||||
config: configFile || undefined
|
||||
};
|
||||
}
|
||||
|
||||
function babelrcLoadEnabled(context, pkgData, babelrcRoots, absoluteRoot) {
|
||||
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;
|
||||
}
|
||||
|
||||
var babelrcPatterns = babelrcRoots;
|
||||
let babelrcPatterns = babelrcRoots;
|
||||
if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns];
|
||||
babelrcPatterns = babelrcPatterns.map(function (pat) {
|
||||
return _path().default.resolve(context.cwd, pat);
|
||||
babelrcPatterns = babelrcPatterns.map(pat => {
|
||||
return typeof pat === "string" ? _path().default.resolve(babelrcRootsDirectory, pat) : pat;
|
||||
});
|
||||
|
||||
if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) {
|
||||
return pkgData.directories.indexOf(absoluteRoot) !== -1;
|
||||
}
|
||||
|
||||
return (0, _micromatch().default)(pkgData.directories, babelrcPatterns).length > 0;
|
||||
}
|
||||
return babelrcPatterns.some(pat => {
|
||||
if (typeof pat === "string") {
|
||||
pat = (0, _patternToRegex.default)(pat, babelrcRootsDirectory);
|
||||
}
|
||||
|
||||
var loadProgrammaticChain = makeChainWalker({
|
||||
init: function init(arg) {
|
||||
return arg;
|
||||
},
|
||||
root: function root(input) {
|
||||
return buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors);
|
||||
},
|
||||
env: function env(input, envName) {
|
||||
return buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName);
|
||||
},
|
||||
overrides: function overrides(input, index) {
|
||||
return buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index);
|
||||
},
|
||||
overridesEnv: function overridesEnv(input, index, envName) {
|
||||
return buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName);
|
||||
}
|
||||
});
|
||||
var loadFileChain = makeChainWalker({
|
||||
init: function init(input) {
|
||||
return validateFile(input);
|
||||
},
|
||||
root: function root(file) {
|
||||
return loadFileDescriptors(file);
|
||||
},
|
||||
env: function env(file, envName) {
|
||||
return loadFileEnvDescriptors(file)(envName);
|
||||
},
|
||||
overrides: function overrides(file, index) {
|
||||
return loadFileOverridesDescriptors(file)(index);
|
||||
},
|
||||
overridesEnv: function overridesEnv(file, index, envName) {
|
||||
return loadFileOverridesEnvDescriptors(file)(index)(envName);
|
||||
}
|
||||
});
|
||||
var validateFile = (0, _caching.makeWeakCache)(function (file) {
|
||||
return {
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: (0, _options.validate)("file", file.options)
|
||||
};
|
||||
});
|
||||
var loadFileDescriptors = (0, _caching.makeWeakCache)(function (file) {
|
||||
return buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors);
|
||||
});
|
||||
var loadFileEnvDescriptors = (0, _caching.makeWeakCache)(function (file) {
|
||||
return (0, _caching.makeStrongCache)(function (envName) {
|
||||
return buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName);
|
||||
});
|
||||
});
|
||||
var loadFileOverridesDescriptors = (0, _caching.makeWeakCache)(function (file) {
|
||||
return (0, _caching.makeStrongCache)(function (index) {
|
||||
return buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index);
|
||||
});
|
||||
});
|
||||
var loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCache)(function (file) {
|
||||
return (0, _caching.makeStrongCache)(function (index) {
|
||||
return (0, _caching.makeStrongCache)(function (envName) {
|
||||
return buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName);
|
||||
return pkgData.directories.some(directory => {
|
||||
return matchPattern(pat, babelrcRootsDirectory, directory, context);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function buildRootDescriptors(_ref, alias, descriptors) {
|
||||
var dirname = _ref.dirname,
|
||||
options = _ref.options;
|
||||
const validateConfigFile = (0, _caching.makeWeakCache)(file => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: (0, _options.validate)("configfile", file.options)
|
||||
}));
|
||||
const validateBabelrcFile = (0, _caching.makeWeakCache)(file => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: (0, _options.validate)("babelrcfile", file.options)
|
||||
}));
|
||||
const validateExtendFile = (0, _caching.makeWeakCache)(file => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: (0, _options.validate)("extendsfile", file.options)
|
||||
}));
|
||||
const loadProgrammaticChain = makeChainWalker({
|
||||
root: input => buildRootDescriptors(input, "base", _configDescriptors.createCachedDescriptors),
|
||||
env: (input, envName) => buildEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, envName),
|
||||
overrides: (input, index) => buildOverrideDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index),
|
||||
overridesEnv: (input, index, envName) => buildOverrideEnvDescriptors(input, "base", _configDescriptors.createCachedDescriptors, index, envName)
|
||||
});
|
||||
const loadFileChain = 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)
|
||||
});
|
||||
const loadFileDescriptors = (0, _caching.makeWeakCache)(file => buildRootDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors));
|
||||
const loadFileEnvDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(envName => buildEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, envName)));
|
||||
const loadFileOverridesDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(index => buildOverrideDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index)));
|
||||
const loadFileOverridesEnvDescriptors = (0, _caching.makeWeakCache)(file => (0, _caching.makeStrongCache)(index => (0, _caching.makeStrongCache)(envName => buildOverrideEnvDescriptors(file, file.filepath, _configDescriptors.createUncachedDescriptors, index, envName))));
|
||||
|
||||
function buildRootDescriptors({
|
||||
dirname,
|
||||
options
|
||||
}, alias, descriptors) {
|
||||
return descriptors(dirname, options, alias);
|
||||
}
|
||||
|
||||
function buildEnvDescriptors(_ref2, alias, descriptors, envName) {
|
||||
var dirname = _ref2.dirname,
|
||||
options = _ref2.options;
|
||||
var opts = options.env && options.env[envName];
|
||||
return opts ? descriptors(dirname, opts, alias + ".env[\"" + envName + "\"]") : null;
|
||||
function buildEnvDescriptors({
|
||||
dirname,
|
||||
options
|
||||
}, alias, descriptors, envName) {
|
||||
const opts = options.env && options.env[envName];
|
||||
return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null;
|
||||
}
|
||||
|
||||
function buildOverrideDescriptors(_ref3, alias, descriptors, index) {
|
||||
var dirname = _ref3.dirname,
|
||||
options = _ref3.options;
|
||||
var opts = options.overrides && options.overrides[index];
|
||||
function buildOverrideDescriptors({
|
||||
dirname,
|
||||
options
|
||||
}, alias, descriptors, index) {
|
||||
const opts = options.overrides && options.overrides[index];
|
||||
if (!opts) throw new Error("Assertion failure - missing override");
|
||||
return descriptors(dirname, opts, alias + ".overrides[" + index + "]");
|
||||
return descriptors(dirname, opts, `${alias}.overrides[${index}]`);
|
||||
}
|
||||
|
||||
function buildOverrideEnvDescriptors(_ref4, alias, descriptors, index, envName) {
|
||||
var dirname = _ref4.dirname,
|
||||
options = _ref4.options;
|
||||
var override = options.overrides && options.overrides[index];
|
||||
function buildOverrideEnvDescriptors({
|
||||
dirname,
|
||||
options
|
||||
}, alias, descriptors, index, envName) {
|
||||
const override = options.overrides && options.overrides[index];
|
||||
if (!override) throw new Error("Assertion failure - missing override");
|
||||
var opts = override.env && override.env[envName];
|
||||
return opts ? descriptors(dirname, opts, alias + ".overrides[" + index + "].env[\"" + envName + "\"]") : null;
|
||||
const opts = override.env && override.env[envName];
|
||||
return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null;
|
||||
}
|
||||
|
||||
function makeChainWalker(_ref5) {
|
||||
var init = _ref5.init,
|
||||
root = _ref5.root,
|
||||
env = _ref5.env,
|
||||
overrides = _ref5.overrides,
|
||||
overridesEnv = _ref5.overridesEnv;
|
||||
return function (arg, context, files) {
|
||||
if (files === void 0) {
|
||||
files = new Set();
|
||||
}
|
||||
|
||||
var input = init(arg);
|
||||
var dirname = input.dirname;
|
||||
var flattenedConfigs = [];
|
||||
var rootOpts = root(input);
|
||||
function makeChainWalker({
|
||||
root,
|
||||
env,
|
||||
overrides,
|
||||
overridesEnv
|
||||
}) {
|
||||
return (input, context, files = new Set()) => {
|
||||
const {
|
||||
dirname
|
||||
} = input;
|
||||
const flattenedConfigs = [];
|
||||
const rootOpts = root(input);
|
||||
|
||||
if (configIsApplicable(rootOpts, dirname, context)) {
|
||||
flattenedConfigs.push(rootOpts);
|
||||
var envOpts = env(input, context.envName);
|
||||
const envOpts = env(input, context.envName);
|
||||
|
||||
if (envOpts && configIsApplicable(envOpts, dirname, context)) {
|
||||
flattenedConfigs.push(envOpts);
|
||||
}
|
||||
|
||||
(rootOpts.options.overrides || []).forEach(function (_, index) {
|
||||
var overrideOps = overrides(input, index);
|
||||
(rootOpts.options.overrides || []).forEach((_, index) => {
|
||||
const overrideOps = overrides(input, index);
|
||||
|
||||
if (configIsApplicable(overrideOps, dirname, context)) {
|
||||
flattenedConfigs.push(overrideOps);
|
||||
var overrideEnvOpts = overridesEnv(input, index, context.envName);
|
||||
const overrideEnvOpts = overridesEnv(input, index, context.envName);
|
||||
|
||||
if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context)) {
|
||||
flattenedConfigs.push(overrideEnvOpts);
|
||||
@@ -303,20 +264,18 @@ function makeChainWalker(_ref5) {
|
||||
});
|
||||
}
|
||||
|
||||
if (flattenedConfigs.some(function (_ref6) {
|
||||
var _ref6$options = _ref6.options,
|
||||
ignore = _ref6$options.ignore,
|
||||
only = _ref6$options.only;
|
||||
return shouldIgnore(context, ignore, only, dirname);
|
||||
})) {
|
||||
if (flattenedConfigs.some(({
|
||||
options: {
|
||||
ignore,
|
||||
only
|
||||
}
|
||||
}) => shouldIgnore(context, ignore, only, dirname))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var chain = emptyChain();
|
||||
|
||||
for (var _i = 0; _i < flattenedConfigs.length; _i++) {
|
||||
var op = flattenedConfigs[_i];
|
||||
const chain = emptyChain();
|
||||
|
||||
for (const op of flattenedConfigs) {
|
||||
if (!mergeExtendsChain(chain, op.options, dirname, context, files)) {
|
||||
return null;
|
||||
}
|
||||
@@ -330,16 +289,14 @@ function makeChainWalker(_ref5) {
|
||||
|
||||
function mergeExtendsChain(chain, opts, dirname, context, files) {
|
||||
if (opts.extends === undefined) return true;
|
||||
var file = (0, _files.loadConfig)(opts.extends, dirname, context.envName);
|
||||
const file = (0, _files.loadConfig)(opts.extends, dirname, context.envName, context.caller);
|
||||
|
||||
if (files.has(file)) {
|
||||
throw new Error("Configuration cycle detected loading " + file.filepath + ".\n" + "File already loaded following the config chain:\n" + Array.from(files, function (file) {
|
||||
return " - " + file.filepath;
|
||||
}).join("\n"));
|
||||
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);
|
||||
var fileChain = loadFileChain(file, context, files);
|
||||
const fileChain = loadFileChain(validateExtendFile(file), context, files);
|
||||
files.delete(file);
|
||||
if (!fileChain) return false;
|
||||
mergeChain(chain, fileChain);
|
||||
@@ -347,29 +304,20 @@ function mergeExtendsChain(chain, opts, dirname, context, files) {
|
||||
}
|
||||
|
||||
function mergeChain(target, source) {
|
||||
var _target$options, _target$plugins, _target$presets;
|
||||
|
||||
(_target$options = target.options).push.apply(_target$options, source.options);
|
||||
|
||||
(_target$plugins = target.plugins).push.apply(_target$plugins, source.plugins);
|
||||
|
||||
(_target$presets = target.presets).push.apply(_target$presets, source.presets);
|
||||
|
||||
target.options.push(...source.options);
|
||||
target.plugins.push(...source.plugins);
|
||||
target.presets.push(...source.presets);
|
||||
return target;
|
||||
}
|
||||
|
||||
function mergeChainOpts(target, _ref7) {
|
||||
var _target$plugins2, _target$presets2;
|
||||
|
||||
var options = _ref7.options,
|
||||
plugins = _ref7.plugins,
|
||||
presets = _ref7.presets;
|
||||
function mergeChainOpts(target, {
|
||||
options,
|
||||
plugins,
|
||||
presets
|
||||
}) {
|
||||
target.options.push(options);
|
||||
|
||||
(_target$plugins2 = target.plugins).push.apply(_target$plugins2, plugins());
|
||||
|
||||
(_target$presets2 = target.presets).push.apply(_target$presets2, presets());
|
||||
|
||||
target.plugins.push(...plugins());
|
||||
target.presets.push(...presets());
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -382,16 +330,20 @@ function emptyChain() {
|
||||
}
|
||||
|
||||
function normalizeOptions(opts) {
|
||||
var options = Object.assign({}, opts);
|
||||
const options = Object.assign({}, opts);
|
||||
delete options.extends;
|
||||
delete options.env;
|
||||
delete options.overrides;
|
||||
delete options.plugins;
|
||||
delete options.presets;
|
||||
delete options.passPerPreset;
|
||||
delete options.ignore;
|
||||
delete options.only;
|
||||
delete options.test;
|
||||
delete options.include;
|
||||
delete options.exclude;
|
||||
|
||||
if (options.sourceMap) {
|
||||
if (options.hasOwnProperty("sourceMap")) {
|
||||
options.sourceMaps = options.sourceMap;
|
||||
delete options.sourceMap;
|
||||
}
|
||||
@@ -400,44 +352,27 @@ function normalizeOptions(opts) {
|
||||
}
|
||||
|
||||
function dedupDescriptors(items) {
|
||||
var map = new Map();
|
||||
var descriptors = [];
|
||||
|
||||
for (var _iterator = items, _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref8;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i2 >= _iterator.length) break;
|
||||
_ref8 = _iterator[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator.next();
|
||||
if (_i2.done) break;
|
||||
_ref8 = _i2.value;
|
||||
}
|
||||
|
||||
var item = _ref8;
|
||||
const map = new Map();
|
||||
const descriptors = [];
|
||||
|
||||
for (const item of items) {
|
||||
if (typeof item.value === "function") {
|
||||
var fnKey = item.value;
|
||||
var nameMap = map.get(fnKey);
|
||||
const fnKey = item.value;
|
||||
let nameMap = map.get(fnKey);
|
||||
|
||||
if (!nameMap) {
|
||||
nameMap = new Map();
|
||||
map.set(fnKey, nameMap);
|
||||
}
|
||||
|
||||
var desc = nameMap.get(item.name);
|
||||
let desc = nameMap.get(item.name);
|
||||
|
||||
if (!desc) {
|
||||
desc = {
|
||||
value: null
|
||||
value: item
|
||||
};
|
||||
descriptors.push(desc);
|
||||
if (!item.ownPass) nameMap.set(item.name, desc);
|
||||
}
|
||||
|
||||
if (item.options === false) {
|
||||
desc.value = null;
|
||||
} else {
|
||||
desc.value = item;
|
||||
}
|
||||
@@ -448,111 +383,57 @@ function dedupDescriptors(items) {
|
||||
}
|
||||
}
|
||||
|
||||
return descriptors.reduce(function (acc, desc) {
|
||||
if (desc.value) acc.push(desc.value);
|
||||
return descriptors.reduce((acc, desc) => {
|
||||
acc.push(desc.value);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
function configIsApplicable(_ref9, dirname, context) {
|
||||
var options = _ref9.options;
|
||||
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));
|
||||
}
|
||||
|
||||
function configFieldIsApplicable(context, test, dirname) {
|
||||
if (context.filename === null) {
|
||||
throw new Error("Configuration contains explicit test/include/exclude checks, but no filename was passed to Babel");
|
||||
}
|
||||
|
||||
var ctx = context;
|
||||
var patterns = Array.isArray(test) ? test : [test];
|
||||
return matchesPatterns(ctx, patterns, dirname, false);
|
||||
const patterns = Array.isArray(test) ? test : [test];
|
||||
return matchesPatterns(context, patterns, dirname);
|
||||
}
|
||||
|
||||
function shouldIgnore(context, ignore, only, dirname) {
|
||||
if (ignore) {
|
||||
if (context.filename === null) {
|
||||
throw new Error("Configuration contains ignore checks, but no filename was passed to Babel");
|
||||
}
|
||||
|
||||
var ctx = context;
|
||||
|
||||
if (matchesPatterns(ctx, ignore, dirname)) {
|
||||
debug("Ignored %o because it matched one of %O from %o", context.filename, ignore, dirname);
|
||||
return true;
|
||||
}
|
||||
if (ignore && matchesPatterns(context, ignore, dirname)) {
|
||||
debug("Ignored %o because it matched one of %O from %o", context.filename, ignore, dirname);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (only) {
|
||||
if (context.filename === null) {
|
||||
throw new Error("Configuration contains ignore checks, but no filename was passed to Babel");
|
||||
}
|
||||
|
||||
var _ctx = context;
|
||||
|
||||
if (!matchesPatterns(_ctx, only, dirname)) {
|
||||
debug("Ignored %o because it failed to match one of %O from %o", context.filename, only, dirname);
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function matchesPatterns(context, patterns, dirname, allowNegation) {
|
||||
if (allowNegation === void 0) {
|
||||
allowNegation = true;
|
||||
}
|
||||
function matchesPatterns(context, patterns, dirname) {
|
||||
return patterns.some(pattern => matchPattern(pattern, dirname, context.filename, context));
|
||||
}
|
||||
|
||||
var res = [];
|
||||
var strings = [];
|
||||
var fns = [];
|
||||
patterns.forEach(function (pattern) {
|
||||
if (typeof pattern === "string") strings.push(pattern);else if (typeof pattern === "function") fns.push(pattern);else res.push(pattern);
|
||||
});
|
||||
var filename = context.filename;
|
||||
if (res.some(function (re) {
|
||||
return re.test(context.filename);
|
||||
})) return true;
|
||||
if (fns.some(function (fn) {
|
||||
return fn(filename);
|
||||
})) return true;
|
||||
|
||||
if (strings.length > 0) {
|
||||
var possibleDirs = getPossibleDirs(context);
|
||||
var absolutePatterns = strings.map(function (pattern) {
|
||||
var negate = pattern[0] === "!";
|
||||
|
||||
if (negate && !allowNegation) {
|
||||
throw new Error("Negation of file paths is not supported.");
|
||||
}
|
||||
|
||||
if (negate) pattern = pattern.slice(1);
|
||||
return (negate ? "!" : "") + _path().default.resolve(dirname, pattern);
|
||||
function matchPattern(pattern, dirname, pathToTest, context) {
|
||||
if (typeof pattern === "function") {
|
||||
return !!pattern(pathToTest, {
|
||||
dirname,
|
||||
envName: context.envName,
|
||||
caller: context.caller
|
||||
});
|
||||
|
||||
if ((0, _micromatch().default)(possibleDirs, absolutePatterns, {
|
||||
nocase: true,
|
||||
nonegate: !allowNegation
|
||||
}).length > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var getPossibleDirs = (0, _caching.makeWeakCache)(function (context) {
|
||||
var current = context.filename;
|
||||
if (current === null) return [];
|
||||
var possibleDirs = [current];
|
||||
|
||||
while (true) {
|
||||
var previous = current;
|
||||
current = _path().default.dirname(current);
|
||||
if (previous === current) break;
|
||||
possibleDirs.push(current);
|
||||
if (typeof pathToTest !== "string") {
|
||||
throw new Error(`Configuration contains string/RegExp pattern, but no filename was passed to Babel`);
|
||||
}
|
||||
|
||||
return possibleDirs;
|
||||
});
|
||||
if (typeof pattern === "string") {
|
||||
pattern = (0, _patternToRegex.default)(pattern, dirname);
|
||||
}
|
||||
|
||||
return pattern.test(pathToTest);
|
||||
}
|
213
node_modules/@babel/core/lib/config/config-descriptors.js
generated
vendored
213
node_modules/@babel/core/lib/config/config-descriptors.js
generated
vendored
@@ -13,85 +13,89 @@ var _item = require("./item");
|
||||
|
||||
var _caching = require("./caching");
|
||||
|
||||
function isEqualDescriptor(a, b) {
|
||||
return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && (a.file && a.file.request) === (b.file && b.file.request) && (a.file && a.file.resolved) === (b.file && b.file.resolved);
|
||||
}
|
||||
|
||||
function createCachedDescriptors(dirname, options, alias) {
|
||||
var plugins = options.plugins,
|
||||
presets = options.presets,
|
||||
passPerPreset = options.passPerPreset;
|
||||
const {
|
||||
plugins,
|
||||
presets,
|
||||
passPerPreset
|
||||
} = options;
|
||||
return {
|
||||
options: options,
|
||||
plugins: plugins ? function () {
|
||||
return createCachedPluginDescriptors(plugins, dirname)(alias);
|
||||
} : function () {
|
||||
return [];
|
||||
},
|
||||
presets: presets ? function () {
|
||||
return createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset);
|
||||
} : function () {
|
||||
return [];
|
||||
}
|
||||
options,
|
||||
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => [],
|
||||
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => []
|
||||
};
|
||||
}
|
||||
|
||||
function createUncachedDescriptors(dirname, options, alias) {
|
||||
var plugins;
|
||||
var presets;
|
||||
let plugins;
|
||||
let presets;
|
||||
return {
|
||||
options: options,
|
||||
plugins: function (_plugins) {
|
||||
function plugins() {
|
||||
return _plugins.apply(this, arguments);
|
||||
}
|
||||
|
||||
plugins.toString = function () {
|
||||
return _plugins.toString();
|
||||
};
|
||||
|
||||
return plugins;
|
||||
}(function () {
|
||||
options,
|
||||
plugins: () => {
|
||||
if (!plugins) {
|
||||
plugins = createPluginDescriptors(options.plugins || [], dirname, alias);
|
||||
}
|
||||
|
||||
return plugins;
|
||||
}),
|
||||
presets: function (_presets) {
|
||||
function presets() {
|
||||
return _presets.apply(this, arguments);
|
||||
}
|
||||
|
||||
presets.toString = function () {
|
||||
return _presets.toString();
|
||||
};
|
||||
|
||||
return presets;
|
||||
}(function () {
|
||||
},
|
||||
presets: () => {
|
||||
if (!presets) {
|
||||
presets = createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset);
|
||||
}
|
||||
|
||||
return presets;
|
||||
})
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var createCachedPresetDescriptors = (0, _caching.makeWeakCache)(function (items, cache) {
|
||||
var dirname = cache.using(function (dir) {
|
||||
return dir;
|
||||
});
|
||||
return (0, _caching.makeStrongCache)(function (alias) {
|
||||
return (0, _caching.makeStrongCache)(function (passPerPreset) {
|
||||
return createPresetDescriptors(items, dirname, alias, passPerPreset);
|
||||
});
|
||||
});
|
||||
const PRESET_DESCRIPTOR_CACHE = new WeakMap();
|
||||
const createCachedPresetDescriptors = (0, _caching.makeWeakCache)((items, cache) => {
|
||||
const dirname = cache.using(dir => dir);
|
||||
return (0, _caching.makeStrongCache)(alias => (0, _caching.makeStrongCache)(passPerPreset => createPresetDescriptors(items, dirname, alias, passPerPreset).map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc))));
|
||||
});
|
||||
var createCachedPluginDescriptors = (0, _caching.makeWeakCache)(function (items, cache) {
|
||||
var dirname = cache.using(function (dir) {
|
||||
return dir;
|
||||
});
|
||||
return (0, _caching.makeStrongCache)(function (alias) {
|
||||
return createPluginDescriptors(items, dirname, alias);
|
||||
});
|
||||
const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();
|
||||
const createCachedPluginDescriptors = (0, _caching.makeWeakCache)((items, cache) => {
|
||||
const dirname = cache.using(dir => dir);
|
||||
return (0, _caching.makeStrongCache)(alias => createPluginDescriptors(items, dirname, alias).map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc)));
|
||||
});
|
||||
const DEFAULT_OPTIONS = {};
|
||||
|
||||
function loadCachedDescriptor(cache, desc) {
|
||||
const {
|
||||
value,
|
||||
options = DEFAULT_OPTIONS
|
||||
} = desc;
|
||||
if (options === false) return desc;
|
||||
let cacheByOptions = cache.get(value);
|
||||
|
||||
if (!cacheByOptions) {
|
||||
cacheByOptions = new WeakMap();
|
||||
cache.set(value, cacheByOptions);
|
||||
}
|
||||
|
||||
let possibilities = cacheByOptions.get(options);
|
||||
|
||||
if (!possibilities) {
|
||||
possibilities = [];
|
||||
cacheByOptions.set(options, 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);
|
||||
@@ -102,67 +106,60 @@ function createPluginDescriptors(items, dirname, alias) {
|
||||
}
|
||||
|
||||
function createDescriptors(type, items, dirname, alias, ownPass) {
|
||||
var descriptors = items.map(function (item, index) {
|
||||
return createDescriptor(item, dirname, {
|
||||
type: type,
|
||||
alias: alias + "$" + index,
|
||||
ownPass: !!ownPass
|
||||
});
|
||||
});
|
||||
const descriptors = items.map((item, index) => createDescriptor(item, dirname, {
|
||||
type,
|
||||
alias: `${alias}$${index}`,
|
||||
ownPass: !!ownPass
|
||||
}));
|
||||
assertNoDuplicates(descriptors);
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
function createDescriptor(pair, dirname, _ref) {
|
||||
var type = _ref.type,
|
||||
alias = _ref.alias,
|
||||
ownPass = _ref.ownPass;
|
||||
var desc = (0, _item.getItemDescriptor)(pair);
|
||||
function createDescriptor(pair, dirname, {
|
||||
type,
|
||||
alias,
|
||||
ownPass
|
||||
}) {
|
||||
const desc = (0, _item.getItemDescriptor)(pair);
|
||||
|
||||
if (desc) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
var name;
|
||||
var options;
|
||||
var value = pair;
|
||||
let name;
|
||||
let options;
|
||||
let value = pair;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 3) {
|
||||
var _value = value;
|
||||
value = _value[0];
|
||||
options = _value[1];
|
||||
name = _value[2];
|
||||
[value, options, name] = value;
|
||||
} else {
|
||||
var _value2 = value;
|
||||
value = _value2[0];
|
||||
options = _value2[1];
|
||||
[value, options] = value;
|
||||
}
|
||||
}
|
||||
|
||||
var file = undefined;
|
||||
var filepath = null;
|
||||
let file = undefined;
|
||||
let filepath = null;
|
||||
|
||||
if (typeof value === "string") {
|
||||
if (typeof type !== "string") {
|
||||
throw new Error("To resolve a string-based item, the type of item must be given");
|
||||
}
|
||||
|
||||
var resolver = type === "plugin" ? _files.loadPlugin : _files.loadPreset;
|
||||
var _request = value;
|
||||
|
||||
var _resolver = resolver(value, dirname);
|
||||
|
||||
filepath = _resolver.filepath;
|
||||
value = _resolver.value;
|
||||
const resolver = type === "plugin" ? _files.loadPlugin : _files.loadPreset;
|
||||
const request = value;
|
||||
({
|
||||
filepath,
|
||||
value
|
||||
} = resolver(value, dirname));
|
||||
file = {
|
||||
request: _request,
|
||||
request,
|
||||
resolved: filepath
|
||||
};
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
throw new Error("Unexpected falsy value: " + String(value));
|
||||
throw new Error(`Unexpected falsy value: ${String(value)}`);
|
||||
}
|
||||
|
||||
if (typeof value === "object" && value.__esModule) {
|
||||
@@ -174,42 +171,30 @@ function createDescriptor(pair, dirname, _ref) {
|
||||
}
|
||||
|
||||
if (typeof value !== "object" && typeof value !== "function") {
|
||||
throw new Error("Unsupported format: " + typeof value + ". Expected an object or a 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);
|
||||
throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`);
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
name,
|
||||
alias: filepath || alias,
|
||||
value: value,
|
||||
options: options,
|
||||
dirname: dirname,
|
||||
ownPass: ownPass,
|
||||
file: file
|
||||
value,
|
||||
options,
|
||||
dirname,
|
||||
ownPass,
|
||||
file
|
||||
};
|
||||
}
|
||||
|
||||
function assertNoDuplicates(items) {
|
||||
var map = new Map();
|
||||
const map = new Map();
|
||||
|
||||
for (var _iterator = items, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref2 = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref2 = _i.value;
|
||||
}
|
||||
|
||||
var item = _ref2;
|
||||
for (const item of items) {
|
||||
if (typeof item.value !== "function") continue;
|
||||
var nameMap = map.get(item.value);
|
||||
let nameMap = map.get(item.value);
|
||||
|
||||
if (!nameMap) {
|
||||
nameMap = new Set();
|
||||
@@ -217,7 +202,7 @@ function assertNoDuplicates(items) {
|
||||
}
|
||||
|
||||
if (nameMap.has(item.name)) {
|
||||
throw new Error(["Duplicate plugin/preset detected.", "If you'd like to use two separate instances of a plugin,", "they neen separate names, e.g.", "", " plugins: [", " ['some-plugin', {}],", " ['some-plugin', {}, 'some unique name'],", " ]"].join("\n"));
|
||||
throw new Error([`Duplicate plugin/preset detected.`, `If you'd like to use two separate instances of a plugin,`, `they need separate names, e.g.`, ``, ` plugins: [`, ` ['some-plugin', {}],`, ` ['some-plugin', {}, 'some unique name'],`, ` ]`].join("\n"));
|
||||
}
|
||||
|
||||
nameMap.add(item.name);
|
||||
|
212
node_modules/@babel/core/lib/config/files/configuration.js
generated
vendored
212
node_modules/@babel/core/lib/config/files/configuration.js
generated
vendored
@@ -3,14 +3,15 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findConfigUpwards = findConfigUpwards;
|
||||
exports.findRelativeConfig = findRelativeConfig;
|
||||
exports.findRootConfig = findRootConfig;
|
||||
exports.loadConfig = loadConfig;
|
||||
|
||||
function _debug() {
|
||||
var data = _interopRequireDefault(require("debug"));
|
||||
const data = _interopRequireDefault(require("debug"));
|
||||
|
||||
_debug = function _debug() {
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -18,9 +19,9 @@ function _debug() {
|
||||
}
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -28,9 +29,9 @@ function _path() {
|
||||
}
|
||||
|
||||
function _fs() {
|
||||
var data = _interopRequireDefault(require("fs"));
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function _fs() {
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -38,9 +39,9 @@ function _fs() {
|
||||
}
|
||||
|
||||
function _json() {
|
||||
var data = _interopRequireDefault(require("json5"));
|
||||
const data = _interopRequireDefault(require("json5"));
|
||||
|
||||
_json = function _json() {
|
||||
_json = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -48,9 +49,9 @@ function _json() {
|
||||
}
|
||||
|
||||
function _resolve() {
|
||||
var data = _interopRequireDefault(require("resolve"));
|
||||
const data = _interopRequireDefault(require("resolve"));
|
||||
|
||||
_resolve = function _resolve() {
|
||||
_resolve = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -63,49 +64,57 @@ var _configApi = _interopRequireDefault(require("../helpers/config-api"));
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
var _patternToRegex = _interopRequireDefault(require("../pattern-to-regex"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var debug = (0, _debug().default)("babel:config:loading:files:configuration");
|
||||
var BABEL_CONFIG_JS_FILENAME = "babel.config.js";
|
||||
var BABELRC_FILENAME = ".babelrc";
|
||||
var BABELRC_JS_FILENAME = ".babelrc.js";
|
||||
var BABELIGNORE_FILENAME = ".babelignore";
|
||||
const debug = (0, _debug().default)("babel:config:loading:files:configuration");
|
||||
const BABEL_CONFIG_JS_FILENAME = "babel.config.js";
|
||||
const BABELRC_FILENAME = ".babelrc";
|
||||
const BABELRC_JS_FILENAME = ".babelrc.js";
|
||||
const BABELIGNORE_FILENAME = ".babelignore";
|
||||
|
||||
function findRelativeConfig(packageData, envName) {
|
||||
var config = null;
|
||||
var ignore = null;
|
||||
function findConfigUpwards(rootDir) {
|
||||
let dirname = rootDir;
|
||||
|
||||
var dirname = _path().default.dirname(packageData.filepath);
|
||||
|
||||
var _loop = function _loop() {
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) return "break";
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) return "break";
|
||||
_ref = _i.value;
|
||||
while (true) {
|
||||
if (_fs().default.existsSync(_path().default.join(dirname, BABEL_CONFIG_JS_FILENAME))) {
|
||||
return dirname;
|
||||
}
|
||||
|
||||
var loc = _ref;
|
||||
const nextDir = _path().default.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);
|
||||
|
||||
for (const loc of packageData.directories) {
|
||||
if (!config) {
|
||||
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce(function (previousConfig, name) {
|
||||
var filepath = _path().default.join(loc, name);
|
||||
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce((previousConfig, name) => {
|
||||
const filepath = _path().default.join(loc, name);
|
||||
|
||||
var config = readConfig(filepath, envName);
|
||||
const config = readConfig(filepath, envName, caller);
|
||||
|
||||
if (config && previousConfig) {
|
||||
throw new Error("Multiple configuration files found. Please remove one:\n" + (" - " + _path().default.basename(previousConfig.filepath) + "\n") + (" - " + name + "\n") + ("from " + loc));
|
||||
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().default.basename(previousConfig.filepath)}\n` + ` - ${name}\n` + `from ${loc}`);
|
||||
}
|
||||
|
||||
return config || previousConfig;
|
||||
}, null);
|
||||
var pkgConfig = packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) : null;
|
||||
const pkgConfig = packageData.pkg && packageData.pkg.dirname === loc ? packageToBabelConfig(packageData.pkg) : null;
|
||||
|
||||
if (pkgConfig) {
|
||||
if (config) {
|
||||
throw new Error("Multiple configuration files found. Please remove one:\n" + (" - " + _path().default.basename(pkgConfig.filepath) + "#babel\n") + (" - " + _path().default.basename(config.filepath) + "\n") + ("from " + loc));
|
||||
throw new Error(`Multiple configuration files found. Please remove one:\n` + ` - ${_path().default.basename(pkgConfig.filepath)}#babel\n` + ` - ${_path().default.basename(config.filepath)}\n` + `from ${loc}`);
|
||||
}
|
||||
|
||||
config = pkgConfig;
|
||||
@@ -117,7 +126,7 @@ function findRelativeConfig(packageData, envName) {
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
var ignoreLoc = _path().default.join(loc, BABELIGNORE_FILENAME);
|
||||
const ignoreLoc = _path().default.join(loc, BABELIGNORE_FILENAME);
|
||||
|
||||
ignore = readIgnoreConfig(ignoreLoc);
|
||||
|
||||
@@ -125,26 +134,18 @@ function findRelativeConfig(packageData, envName) {
|
||||
debug("Found ignore %o from %o.", ignore.filepath, dirname);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (var _iterator = packageData.directories, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
var _ret = _loop();
|
||||
|
||||
if (_ret === "break") break;
|
||||
}
|
||||
|
||||
return {
|
||||
config: config,
|
||||
ignore: ignore
|
||||
config,
|
||||
ignore
|
||||
};
|
||||
}
|
||||
|
||||
function findRootConfig(dirname, envName) {
|
||||
var filepath = _path().default.resolve(dirname, BABEL_CONFIG_JS_FILENAME);
|
||||
function findRootConfig(dirname, envName, caller) {
|
||||
const filepath = _path().default.resolve(dirname, BABEL_CONFIG_JS_FILENAME);
|
||||
|
||||
var conf = readConfig(filepath, envName);
|
||||
const conf = readConfig(filepath, envName, caller);
|
||||
|
||||
if (conf) {
|
||||
debug("Found root config %o in $o.", BABEL_CONFIG_JS_FILENAME, dirname);
|
||||
@@ -153,29 +154,30 @@ function findRootConfig(dirname, envName) {
|
||||
return conf;
|
||||
}
|
||||
|
||||
function loadConfig(name, dirname, envName) {
|
||||
var filepath = _resolve().default.sync(name, {
|
||||
function loadConfig(name, dirname, envName, caller) {
|
||||
const filepath = _resolve().default.sync(name, {
|
||||
basedir: dirname
|
||||
});
|
||||
|
||||
var conf = readConfig(filepath, envName);
|
||||
const conf = readConfig(filepath, envName, caller);
|
||||
|
||||
if (!conf) {
|
||||
throw new Error("Config file " + filepath + " contains no configuration data");
|
||||
throw new Error(`Config file ${filepath} contains no configuration data`);
|
||||
}
|
||||
|
||||
debug("Loaded config %o from $o.", name, dirname);
|
||||
return conf;
|
||||
}
|
||||
|
||||
function readConfig(filepath, envName) {
|
||||
function readConfig(filepath, envName, caller) {
|
||||
return _path().default.extname(filepath) === ".js" ? readConfigJS(filepath, {
|
||||
envName: envName
|
||||
envName,
|
||||
caller
|
||||
}) : readConfigJSON5(filepath);
|
||||
}
|
||||
|
||||
var LOADING_CONFIGS = new Set();
|
||||
var readConfigJS = (0, _caching.makeStrongCache)(function (filepath, cache) {
|
||||
const LOADING_CONFIGS = new Set();
|
||||
const readConfigJS = (0, _caching.makeStrongCache)((filepath, cache) => {
|
||||
if (!_fs().default.existsSync(filepath)) {
|
||||
cache.forever();
|
||||
return null;
|
||||
@@ -185,22 +187,22 @@ var readConfigJS = (0, _caching.makeStrongCache)(function (filepath, cache) {
|
||||
cache.never();
|
||||
debug("Auto-ignoring usage of config %o.", filepath);
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
dirname: _path().default.dirname(filepath),
|
||||
options: {}
|
||||
};
|
||||
}
|
||||
|
||||
var options;
|
||||
let options;
|
||||
|
||||
try {
|
||||
LOADING_CONFIGS.add(filepath);
|
||||
|
||||
var configModule = require(filepath);
|
||||
const configModule = require(filepath);
|
||||
|
||||
options = configModule && configModule.__esModule ? configModule.default || undefined : configModule;
|
||||
} catch (err) {
|
||||
err.message = filepath + ": Error while loading config - " + err.message;
|
||||
err.message = `${filepath}: Error while loading config - ${err.message}`;
|
||||
throw err;
|
||||
} finally {
|
||||
LOADING_CONFIGS.delete(filepath);
|
||||
@@ -212,25 +214,25 @@ var readConfigJS = (0, _caching.makeStrongCache)(function (filepath, cache) {
|
||||
}
|
||||
|
||||
if (!options || typeof options !== "object" || Array.isArray(options)) {
|
||||
throw new Error(filepath + ": Configuration should be an exported JavaScript object.");
|
||||
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.");
|
||||
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.`);
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
dirname: _path().default.dirname(filepath),
|
||||
options: options
|
||||
options
|
||||
};
|
||||
});
|
||||
var packageToBabelConfig = (0, _caching.makeWeakCache)(function (file) {
|
||||
if (typeof file.options.babel === "undefined") return null;
|
||||
var babel = file.options.babel;
|
||||
const packageToBabelConfig = (0, _caching.makeWeakCache)(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");
|
||||
throw new Error(`${file.filepath}: .babel property must be an object`);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -239,45 +241,83 @@ var packageToBabelConfig = (0, _caching.makeWeakCache)(function (file) {
|
||||
options: babel
|
||||
};
|
||||
});
|
||||
var readConfigJSON5 = (0, _utils.makeStaticFileCache)(function (filepath, content) {
|
||||
var options;
|
||||
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;
|
||||
err.message = `${filepath}: Error while parsing config - ${err.message}`;
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!options) throw new Error(filepath + ": No config detected");
|
||||
if (!options) throw new Error(`${filepath}: No config detected`);
|
||||
|
||||
if (typeof options !== "object") {
|
||||
throw new Error(filepath + ": Config returned typeof " + typeof options);
|
||||
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
throw new Error(filepath + ": Expected config object but found array");
|
||||
throw new Error(`${filepath}: Expected config object but found array`);
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
dirname: _path().default.dirname(filepath),
|
||||
options: options
|
||||
options
|
||||
};
|
||||
});
|
||||
var readIgnoreConfig = (0, _utils.makeStaticFileCache)(function (filepath, content) {
|
||||
var ignore = content.split("\n").map(function (line) {
|
||||
return line.replace(/#(.*?)$/, "").trim();
|
||||
}).filter(function (line) {
|
||||
return !!line;
|
||||
});
|
||||
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.`);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
dirname: _path().default.dirname(filepath),
|
||||
ignore: ignore
|
||||
ignore: ignorePatterns.map(pattern => (0, _patternToRegex.default)(pattern, ignoreDir))
|
||||
};
|
||||
});
|
||||
|
||||
function throwConfigError() {
|
||||
throw new Error("Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured\nfor various types of caching, using the first param of their handler functions:\n\nmodule.exports = function(api) {\n // The API exposes the following:\n\n // Cache the returned value forever and don't call this function again.\n api.cache(true);\n\n // Don't cache at all. Not recommended because it will be very slow.\n api.cache(false);\n\n // Cached based on the value of some function. If this function returns a value different from\n // a previously-encountered value, the plugins will re-evaluate.\n var env = api.cache(() => process.env.NODE_ENV);\n\n // If testing for a specific env, we recommend specifics to avoid instantiating a plugin for\n // any possible NODE_ENV value that might come up during plugin execution.\n var isProd = api.cache(() => process.env.NODE_ENV === \"production\");\n\n // .cache(fn) will perform a linear search though instances to find the matching plugin based\n // based on previous instantiated plugins. If you want to recreate the plugin and discard the\n // previous instance whenever something changes, you may use:\n var isProd = api.cache.invalidate(() => process.env.NODE_ENV === \"production\");\n\n // Note, we also expose the following more-verbose versions of the above examples:\n api.cache.forever(); // api.cache(true)\n api.cache.never(); // api.cache(false)\n api.cache.using(fn); // api.cache(fn)\n\n // Return the value that will be cached.\n return { };\n};");
|
||||
throw new Error(`\
|
||||
Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured
|
||||
for various types of caching, using the first param of their handler functions:
|
||||
|
||||
module.exports = function(api) {
|
||||
// The API exposes the following:
|
||||
|
||||
// Cache the returned value forever and don't call this function again.
|
||||
api.cache(true);
|
||||
|
||||
// Don't cache at all. Not recommended because it will be very slow.
|
||||
api.cache(false);
|
||||
|
||||
// Cached based on the value of some function. If this function returns a value different from
|
||||
// a previously-encountered value, the plugins will re-evaluate.
|
||||
var env = api.cache(() => process.env.NODE_ENV);
|
||||
|
||||
// If testing for a specific env, we recommend specifics to avoid instantiating a plugin for
|
||||
// any possible NODE_ENV value that might come up during plugin execution.
|
||||
var isProd = api.cache(() => process.env.NODE_ENV === "production");
|
||||
|
||||
// .cache(fn) will perform a linear search though instances to find the matching plugin based
|
||||
// based on previous instantiated plugins. If you want to recreate the plugin and discard the
|
||||
// previous instance whenever something changes, you may use:
|
||||
var isProd = api.cache.invalidate(() => process.env.NODE_ENV === "production");
|
||||
|
||||
// Note, we also expose the following more-verbose versions of the above examples:
|
||||
api.cache.forever(); // api.cache(true)
|
||||
api.cache.never(); // api.cache(false)
|
||||
api.cache.using(fn); // api.cache(fn)
|
||||
|
||||
// Return the value that will be cached.
|
||||
return { };
|
||||
};`);
|
||||
}
|
19
node_modules/@babel/core/lib/config/files/index-browser.js
generated
vendored
19
node_modules/@babel/core/lib/config/files/index-browser.js
generated
vendored
@@ -3,6 +3,7 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.findConfigUpwards = findConfigUpwards;
|
||||
exports.findPackageData = findPackageData;
|
||||
exports.findRelativeConfig = findRelativeConfig;
|
||||
exports.findRootConfig = findRootConfig;
|
||||
@@ -12,16 +13,20 @@ exports.resolvePreset = resolvePreset;
|
||||
exports.loadPlugin = loadPlugin;
|
||||
exports.loadPreset = loadPreset;
|
||||
|
||||
function findConfigUpwards(rootDir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function findPackageData(filepath) {
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
directories: [],
|
||||
pkg: null,
|
||||
isPackage: false
|
||||
};
|
||||
}
|
||||
|
||||
function findRelativeConfig(pkgData, envName) {
|
||||
function findRelativeConfig(pkgData, envName, caller) {
|
||||
return {
|
||||
pkg: null,
|
||||
config: null,
|
||||
@@ -29,12 +34,12 @@ function findRelativeConfig(pkgData, envName) {
|
||||
};
|
||||
}
|
||||
|
||||
function findRootConfig(dirname, envName) {
|
||||
function findRootConfig(dirname, envName, caller) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function loadConfig(name, dirname, envName) {
|
||||
throw new Error("Cannot load " + name + " relative to " + dirname + " in a browser");
|
||||
function loadConfig(name, dirname, envName, caller) {
|
||||
throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`);
|
||||
}
|
||||
|
||||
function resolvePlugin(name, dirname) {
|
||||
@@ -46,9 +51,9 @@ function resolvePreset(name, dirname) {
|
||||
}
|
||||
|
||||
function loadPlugin(name, dirname) {
|
||||
throw new Error("Cannot load plugin " + name + " relative to " + dirname + " in a browser");
|
||||
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");
|
||||
throw new Error(`Cannot load preset ${name} relative to ${dirname} in a browser`);
|
||||
}
|
22
node_modules/@babel/core/lib/config/files/index.js
generated
vendored
22
node_modules/@babel/core/lib/config/files/index.js
generated
vendored
@@ -5,49 +5,55 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
Object.defineProperty(exports, "findPackageData", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _package.findPackageData;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "findConfigUpwards", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _configuration.findConfigUpwards;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "findRelativeConfig", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _configuration.findRelativeConfig;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "findRootConfig", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _configuration.findRootConfig;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadConfig", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _configuration.loadConfig;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "resolvePlugin", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _plugins.resolvePlugin;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "resolvePreset", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _plugins.resolvePreset;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPlugin", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _plugins.loadPlugin;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPreset", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _plugins.loadPreset;
|
||||
}
|
||||
});
|
||||
|
38
node_modules/@babel/core/lib/config/files/package.js
generated
vendored
38
node_modules/@babel/core/lib/config/files/package.js
generated
vendored
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.findPackageData = findPackageData;
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -19,20 +19,20 @@ var _utils = require("./utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var PACKAGE_FILENAME = "package.json";
|
||||
const PACKAGE_FILENAME = "package.json";
|
||||
|
||||
function findPackageData(filepath) {
|
||||
var pkg = null;
|
||||
var directories = [];
|
||||
var isPackage = true;
|
||||
let pkg = null;
|
||||
const directories = [];
|
||||
let isPackage = true;
|
||||
|
||||
var dirname = _path().default.dirname(filepath);
|
||||
let dirname = _path().default.dirname(filepath);
|
||||
|
||||
while (!pkg && _path().default.basename(dirname) !== "node_modules") {
|
||||
directories.push(dirname);
|
||||
pkg = readConfigPackage(_path().default.join(dirname, PACKAGE_FILENAME));
|
||||
|
||||
var nextLoc = _path().default.dirname(dirname);
|
||||
const nextLoc = _path().default.dirname(dirname);
|
||||
|
||||
if (dirname === nextLoc) {
|
||||
isPackage = false;
|
||||
@@ -43,34 +43,34 @@ function findPackageData(filepath) {
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: filepath,
|
||||
directories: directories,
|
||||
pkg: pkg,
|
||||
isPackage: isPackage
|
||||
filepath,
|
||||
directories,
|
||||
pkg,
|
||||
isPackage
|
||||
};
|
||||
}
|
||||
|
||||
var readConfigPackage = (0, _utils.makeStaticFileCache)(function (filepath, content) {
|
||||
var options;
|
||||
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;
|
||||
err.message = `${filepath}: Error while parsing JSON - ${err.message}`;
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (typeof options !== "object") {
|
||||
throw new Error(filepath + ": Config returned typeof " + typeof options);
|
||||
throw new Error(`${filepath}: Config returned typeof ${typeof options}`);
|
||||
}
|
||||
|
||||
if (Array.isArray(options)) {
|
||||
throw new Error(filepath + ": Expected config object but found array");
|
||||
throw new Error(`${filepath}: Expected config object but found array`);
|
||||
}
|
||||
|
||||
return {
|
||||
filepath: filepath,
|
||||
filepath,
|
||||
dirname: _path().default.dirname(filepath),
|
||||
options: options
|
||||
options
|
||||
};
|
||||
});
|
79
node_modules/@babel/core/lib/config/files/plugins.js
generated
vendored
79
node_modules/@babel/core/lib/config/files/plugins.js
generated
vendored
@@ -9,9 +9,9 @@ exports.loadPlugin = loadPlugin;
|
||||
exports.loadPreset = loadPreset;
|
||||
|
||||
function _debug() {
|
||||
var data = _interopRequireDefault(require("debug"));
|
||||
const data = _interopRequireDefault(require("debug"));
|
||||
|
||||
_debug = function _debug() {
|
||||
_debug = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ function _debug() {
|
||||
}
|
||||
|
||||
function _resolve() {
|
||||
var data = _interopRequireDefault(require("resolve"));
|
||||
const data = _interopRequireDefault(require("resolve"));
|
||||
|
||||
_resolve = function _resolve() {
|
||||
_resolve = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -29,9 +29,9 @@ function _resolve() {
|
||||
}
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -40,14 +40,15 @@ function _path() {
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var debug = (0, _debug().default)("babel:config:loading:files:plugins");
|
||||
var EXACT_RE = /^module:/;
|
||||
var BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
||||
var BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||
var BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
||||
var BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||
var OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin-|[^/]+\/)/;
|
||||
var OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset-|[^/]+\/)/;
|
||||
const debug = (0, _debug().default)("babel:config:loading:files:plugins");
|
||||
const EXACT_RE = /^module:/;
|
||||
const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
||||
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
||||
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
||||
|
||||
function resolvePlugin(name, dirname) {
|
||||
return resolveStandardizedName("plugin", name, dirname);
|
||||
@@ -58,47 +59,43 @@ function resolvePreset(name, dirname) {
|
||||
}
|
||||
|
||||
function loadPlugin(name, dirname) {
|
||||
var filepath = resolvePlugin(name, dirname);
|
||||
const filepath = resolvePlugin(name, dirname);
|
||||
|
||||
if (!filepath) {
|
||||
throw new Error("Plugin " + name + " not found relative to " + dirname);
|
||||
throw new Error(`Plugin ${name} not found relative to ${dirname}`);
|
||||
}
|
||||
|
||||
var value = requireModule("plugin", filepath);
|
||||
const value = requireModule("plugin", filepath);
|
||||
debug("Loaded plugin %o from %o.", name, dirname);
|
||||
return {
|
||||
filepath: filepath,
|
||||
value: value
|
||||
filepath,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function loadPreset(name, dirname) {
|
||||
var filepath = resolvePreset(name, dirname);
|
||||
const filepath = resolvePreset(name, dirname);
|
||||
|
||||
if (!filepath) {
|
||||
throw new Error("Preset " + name + " not found relative to " + dirname);
|
||||
throw new Error(`Preset ${name} not found relative to ${dirname}`);
|
||||
}
|
||||
|
||||
var value = requireModule("preset", filepath);
|
||||
const value = requireModule("preset", filepath);
|
||||
debug("Loaded preset %o from %o.", name, dirname);
|
||||
return {
|
||||
filepath: filepath,
|
||||
value: value
|
||||
filepath,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
function standardizeName(type, name) {
|
||||
if (_path().default.isAbsolute(name)) return name;
|
||||
var 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(EXACT_RE, "");
|
||||
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) {
|
||||
if (dirname === void 0) {
|
||||
dirname = process.cwd();
|
||||
}
|
||||
|
||||
var standardizedName = standardizeName(type, name);
|
||||
function resolveStandardizedName(type, name, dirname = process.cwd()) {
|
||||
const standardizedName = standardizeName(type, name);
|
||||
|
||||
try {
|
||||
return _resolve().default.sync(standardizedName, {
|
||||
@@ -108,7 +105,7 @@ function resolveStandardizedName(type, name, dirname) {
|
||||
if (e.code !== "MODULE_NOT_FOUND") throw e;
|
||||
|
||||
if (standardizedName !== name) {
|
||||
var resolvedOriginal = false;
|
||||
let resolvedOriginal = false;
|
||||
|
||||
try {
|
||||
_resolve().default.sync(name, {
|
||||
@@ -119,11 +116,11 @@ function resolveStandardizedName(type, name, dirname) {
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOriginal) {
|
||||
e.message += "\n- If you want to resolve \"" + name + "\", use \"module:" + name + "\"";
|
||||
e.message += `\n- If you want to resolve "${name}", use "module:${name}"`;
|
||||
}
|
||||
}
|
||||
|
||||
var resolvedBabel = false;
|
||||
let resolvedBabel = false;
|
||||
|
||||
try {
|
||||
_resolve().default.sync(standardizeName(type, "@babel/" + name), {
|
||||
@@ -134,11 +131,11 @@ function resolveStandardizedName(type, name, dirname) {
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedBabel) {
|
||||
e.message += "\n- Did you mean \"@babel/" + name + "\"?";
|
||||
e.message += `\n- Did you mean "@babel/${name}"?`;
|
||||
}
|
||||
|
||||
var resolvedOppositeType = false;
|
||||
var oppositeType = type === "preset" ? "plugin" : "preset";
|
||||
let resolvedOppositeType = false;
|
||||
const oppositeType = type === "preset" ? "plugin" : "preset";
|
||||
|
||||
try {
|
||||
_resolve().default.sync(standardizeName(oppositeType, name), {
|
||||
@@ -149,18 +146,18 @@ function resolveStandardizedName(type, name, dirname) {
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOppositeType) {
|
||||
e.message += "\n- Did you accidentally pass a " + type + " as a " + oppositeType + "?";
|
||||
e.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
var LOADING_MODULES = new Set();
|
||||
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.');
|
||||
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 {
|
||||
|
1
node_modules/@babel/core/lib/config/files/types.js
generated
vendored
1
node_modules/@babel/core/lib/config/files/types.js
generated
vendored
@@ -1 +0,0 @@
|
||||
"use strict";
|
10
node_modules/@babel/core/lib/config/files/utils.js
generated
vendored
10
node_modules/@babel/core/lib/config/files/utils.js
generated
vendored
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.makeStaticFileCache = makeStaticFileCache;
|
||||
|
||||
function _fs() {
|
||||
var data = _interopRequireDefault(require("fs"));
|
||||
const data = _interopRequireDefault(require("fs"));
|
||||
|
||||
_fs = function _fs() {
|
||||
_fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -20,10 +20,8 @@ var _caching = require("../caching");
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function makeStaticFileCache(fn) {
|
||||
return (0, _caching.makeStrongCache)(function (filepath, cache) {
|
||||
if (cache.invalidate(function () {
|
||||
return fileMtime(filepath);
|
||||
}) === null) {
|
||||
return (0, _caching.makeStrongCache)((filepath, cache) => {
|
||||
if (cache.invalidate(() => fileMtime(filepath)) === null) {
|
||||
cache.forever();
|
||||
return null;
|
||||
}
|
||||
|
199
node_modules/@babel/core/lib/config/full.js
generated
vendored
199
node_modules/@babel/core/lib/config/full.js
generated
vendored
@@ -16,9 +16,9 @@ var _item = require("./item");
|
||||
var _configChain = require("./config-chain");
|
||||
|
||||
function _traverse() {
|
||||
var data = _interopRequireDefault(require("@babel/traverse"));
|
||||
const data = _interopRequireDefault(require("@babel/traverse"));
|
||||
|
||||
_traverse = function _traverse() {
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -40,78 +40,74 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function loadFullConfig(inputOpts) {
|
||||
var result = (0, _partial.default)(inputOpts);
|
||||
const result = (0, _partial.default)(inputOpts);
|
||||
|
||||
if (!result) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var options = result.options,
|
||||
context = result.context;
|
||||
var optionDefaults = {};
|
||||
var passes = [[]];
|
||||
const {
|
||||
options,
|
||||
context
|
||||
} = result;
|
||||
const optionDefaults = {};
|
||||
const passes = [[]];
|
||||
|
||||
try {
|
||||
var plugins = options.plugins,
|
||||
presets = options.presets;
|
||||
const {
|
||||
plugins,
|
||||
presets
|
||||
} = options;
|
||||
|
||||
if (!plugins || !presets) {
|
||||
throw new Error("Assertion failure - plugins and presets exist");
|
||||
}
|
||||
|
||||
var ignored = function recurseDescriptors(config, pass) {
|
||||
var plugins = config.plugins.map(function (descriptor) {
|
||||
return loadPluginDescriptor(descriptor, context);
|
||||
});
|
||||
var presets = config.presets.map(function (descriptor) {
|
||||
return {
|
||||
preset: loadPresetDescriptor(descriptor, context),
|
||||
pass: descriptor.ownPass ? [] : pass
|
||||
};
|
||||
});
|
||||
const ignored = function recurseDescriptors(config, pass) {
|
||||
const plugins = config.plugins.reduce((acc, descriptor) => {
|
||||
if (descriptor.options !== false) {
|
||||
acc.push(loadPluginDescriptor(descriptor, context));
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
const presets = config.presets.reduce((acc, descriptor) => {
|
||||
if (descriptor.options !== false) {
|
||||
acc.push({
|
||||
preset: loadPresetDescriptor(descriptor, context),
|
||||
pass: descriptor.ownPass ? [] : pass
|
||||
});
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
if (presets.length > 0) {
|
||||
passes.splice.apply(passes, [1, 0].concat(presets.map(function (o) {
|
||||
return o.pass;
|
||||
}).filter(function (p) {
|
||||
return p !== pass;
|
||||
})));
|
||||
passes.splice(1, 0, ...presets.map(o => o.pass).filter(p => p !== pass));
|
||||
|
||||
for (var _iterator = presets, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref2;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref2 = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref2 = _i.value;
|
||||
}
|
||||
|
||||
var _ref3 = _ref2;
|
||||
var preset = _ref3.preset,
|
||||
_pass = _ref3.pass;
|
||||
for (const _ref of presets) {
|
||||
const {
|
||||
preset,
|
||||
pass
|
||||
} = _ref;
|
||||
if (!preset) return true;
|
||||
|
||||
var _ignored = recurseDescriptors({
|
||||
const ignored = recurseDescriptors({
|
||||
plugins: preset.plugins,
|
||||
presets: preset.presets
|
||||
}, _pass);
|
||||
|
||||
if (_ignored) return true;
|
||||
preset.options.forEach(function (opts) {
|
||||
}, pass);
|
||||
if (ignored) return true;
|
||||
preset.options.forEach(opts => {
|
||||
(0, _util.mergeOptions)(optionDefaults, opts);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugins.length > 0) {
|
||||
pass.unshift.apply(pass, plugins);
|
||||
pass.unshift(...plugins);
|
||||
}
|
||||
}({
|
||||
plugins: plugins.map(function (item) {
|
||||
var desc = (0, _item.getItemDescriptor)(item);
|
||||
plugins: plugins.map(item => {
|
||||
const desc = (0, _item.getItemDescriptor)(item);
|
||||
|
||||
if (!desc) {
|
||||
throw new Error("Assertion failure - must be config item");
|
||||
@@ -119,8 +115,8 @@ function loadFullConfig(inputOpts) {
|
||||
|
||||
return desc;
|
||||
}),
|
||||
presets: presets.map(function (item) {
|
||||
var desc = (0, _item.getItemDescriptor)(item);
|
||||
presets: presets.map(item => {
|
||||
const desc = (0, _item.getItemDescriptor)(item);
|
||||
|
||||
if (!desc) {
|
||||
throw new Error("Assertion failure - must be config item");
|
||||
@@ -133,22 +129,18 @@ function loadFullConfig(inputOpts) {
|
||||
if (ignored) return null;
|
||||
} catch (e) {
|
||||
if (!/^\[BABEL\]/.test(e.message)) {
|
||||
e.message = "[BABEL] " + (context.filename || "unknown") + ": " + e.message;
|
||||
e.message = `[BABEL] ${context.filename || "unknown"}: ${e.message}`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
var opts = optionDefaults;
|
||||
const opts = optionDefaults;
|
||||
(0, _util.mergeOptions)(opts, options);
|
||||
opts.plugins = passes[0];
|
||||
opts.presets = passes.slice(1).filter(function (plugins) {
|
||||
return plugins.length > 0;
|
||||
}).map(function (plugins) {
|
||||
return {
|
||||
plugins: plugins
|
||||
};
|
||||
});
|
||||
opts.presets = passes.slice(1).filter(plugins => plugins.length > 0).map(plugins => ({
|
||||
plugins
|
||||
}));
|
||||
opts.passPerPreset = opts.presets.length > 0;
|
||||
return {
|
||||
options: opts,
|
||||
@@ -156,23 +148,24 @@ function loadFullConfig(inputOpts) {
|
||||
};
|
||||
}
|
||||
|
||||
var loadDescriptor = (0, _caching.makeWeakCache)(function (_ref4, cache) {
|
||||
var value = _ref4.value,
|
||||
options = _ref4.options,
|
||||
dirname = _ref4.dirname,
|
||||
alias = _ref4.alias;
|
||||
const loadDescriptor = (0, _caching.makeWeakCache)(({
|
||||
value,
|
||||
options,
|
||||
dirname,
|
||||
alias
|
||||
}, cache) => {
|
||||
if (options === false) throw new Error("Assertion failure");
|
||||
options = options || {};
|
||||
var item = value;
|
||||
let item = value;
|
||||
|
||||
if (typeof value === "function") {
|
||||
var api = Object.assign({}, context, (0, _configApi.default)(cache));
|
||||
const api = Object.assign({}, context, (0, _configApi.default)(cache));
|
||||
|
||||
try {
|
||||
item = value(api, options, dirname);
|
||||
} catch (e) {
|
||||
if (alias) {
|
||||
e.message += " (While processing: " + JSON.stringify(alias) + ")";
|
||||
e.message += ` (While processing: ${JSON.stringify(alias)})`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
@@ -184,14 +177,14 @@ var loadDescriptor = (0, _caching.makeWeakCache)(function (_ref4, cache) {
|
||||
}
|
||||
|
||||
if (typeof item.then === "function") {
|
||||
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 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.`);
|
||||
}
|
||||
|
||||
return {
|
||||
value: item,
|
||||
options: options,
|
||||
dirname: dirname,
|
||||
alias: alias
|
||||
options,
|
||||
dirname,
|
||||
alias
|
||||
};
|
||||
});
|
||||
|
||||
@@ -207,29 +200,28 @@ function loadPluginDescriptor(descriptor, context) {
|
||||
return instantiatePlugin(loadDescriptor(descriptor, context), context);
|
||||
}
|
||||
|
||||
var instantiatePlugin = (0, _caching.makeWeakCache)(function (_ref5, cache) {
|
||||
var value = _ref5.value,
|
||||
options = _ref5.options,
|
||||
dirname = _ref5.dirname,
|
||||
alias = _ref5.alias;
|
||||
var pluginObj = (0, _plugins.validatePluginObject)(value);
|
||||
var plugin = Object.assign({}, pluginObj);
|
||||
const instantiatePlugin = (0, _caching.makeWeakCache)(({
|
||||
value,
|
||||
options,
|
||||
dirname,
|
||||
alias
|
||||
}, 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) {
|
||||
var inheritsDescriptor = {
|
||||
const inheritsDescriptor = {
|
||||
name: undefined,
|
||||
alias: alias + "$inherits",
|
||||
alias: `${alias}$inherits`,
|
||||
value: plugin.inherits,
|
||||
options: options,
|
||||
dirname: dirname
|
||||
options,
|
||||
dirname
|
||||
};
|
||||
var inherits = cache.invalidate(function (data) {
|
||||
return loadPluginDescriptor(inheritsDescriptor, data);
|
||||
});
|
||||
const inherits = cache.invalidate(data => loadPluginDescriptor(inheritsDescriptor, data));
|
||||
plugin.pre = chain(inherits.pre, plugin.pre);
|
||||
plugin.post = chain(inherits.post, plugin.post);
|
||||
plugin.manipulateOptions = chain(inherits.manipulateOptions, plugin.manipulateOptions);
|
||||
@@ -239,42 +231,27 @@ var instantiatePlugin = (0, _caching.makeWeakCache)(function (_ref5, cache) {
|
||||
return new _plugin.default(plugin, options, alias);
|
||||
});
|
||||
|
||||
var loadPresetDescriptor = function loadPresetDescriptor(descriptor, context) {
|
||||
const loadPresetDescriptor = (descriptor, context) => {
|
||||
return (0, _configChain.buildPresetChain)(instantiatePreset(loadDescriptor(descriptor, context)), context);
|
||||
};
|
||||
|
||||
var instantiatePreset = (0, _caching.makeWeakCache)(function (_ref6) {
|
||||
var value = _ref6.value,
|
||||
dirname = _ref6.dirname,
|
||||
alias = _ref6.alias;
|
||||
const instantiatePreset = (0, _caching.makeWeakCache)(({
|
||||
value,
|
||||
dirname,
|
||||
alias
|
||||
}) => {
|
||||
return {
|
||||
options: (0, _options.validate)("preset", value),
|
||||
alias: alias,
|
||||
dirname: dirname
|
||||
alias,
|
||||
dirname
|
||||
};
|
||||
});
|
||||
|
||||
function chain(a, b) {
|
||||
var fns = [a, b].filter(Boolean);
|
||||
const fns = [a, b].filter(Boolean);
|
||||
if (fns.length <= 1) return fns[0];
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
for (var _iterator2 = fns, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
|
||||
var _ref7;
|
||||
|
||||
if (_isArray2) {
|
||||
if (_i2 >= _iterator2.length) break;
|
||||
_ref7 = _iterator2[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator2.next();
|
||||
if (_i2.done) break;
|
||||
_ref7 = _i2.value;
|
||||
}
|
||||
|
||||
var fn = _ref7;
|
||||
return function (...args) {
|
||||
for (const fn of fns) {
|
||||
fn.apply(this, args);
|
||||
}
|
||||
};
|
||||
|
52
node_modules/@babel/core/lib/config/helpers/config-api.js
generated
vendored
52
node_modules/@babel/core/lib/config/helpers/config-api.js
generated
vendored
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.default = makeAPI;
|
||||
|
||||
function _semver() {
|
||||
var data = _interopRequireDefault(require("semver"));
|
||||
const data = _interopRequireDefault(require("semver"));
|
||||
|
||||
_semver = function _semver() {
|
||||
_semver = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -17,32 +17,38 @@ function _semver() {
|
||||
|
||||
var _ = require("../../");
|
||||
|
||||
var _caching = require("../caching");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function makeAPI(cache) {
|
||||
var env = function env(value) {
|
||||
return cache.using(function (data) {
|
||||
if (typeof value === "undefined") return data.envName;
|
||||
if (typeof value === "function") return value(data.envName);
|
||||
if (!Array.isArray(value)) value = [value];
|
||||
return value.some(function (entry) {
|
||||
if (typeof entry !== "string") {
|
||||
throw new Error("Unexpected non-string value");
|
||||
}
|
||||
const env = value => cache.using(data => {
|
||||
if (typeof value === "undefined") return data.envName;
|
||||
|
||||
return entry === data.envName;
|
||||
});
|
||||
if (typeof value === "function") {
|
||||
return (0, _caching.assertSimpleType)(value(data.envName));
|
||||
}
|
||||
|
||||
if (!Array.isArray(value)) value = [value];
|
||||
return 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,
|
||||
cache: cache.simple(),
|
||||
env: env,
|
||||
async: function async() {
|
||||
return false;
|
||||
},
|
||||
assertVersion: assertVersion
|
||||
env,
|
||||
async: () => false,
|
||||
caller,
|
||||
assertVersion,
|
||||
tokTypes: undefined
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +58,7 @@ function assertVersion(range) {
|
||||
throw new Error("Expected string or integer value.");
|
||||
}
|
||||
|
||||
range = "^" + range + ".0.0-0";
|
||||
range = `^${range}.0.0-0`;
|
||||
}
|
||||
|
||||
if (typeof range !== "string") {
|
||||
@@ -60,13 +66,13 @@ function assertVersion(range) {
|
||||
}
|
||||
|
||||
if (_semver().default.satisfies(_.version, range)) return;
|
||||
var limit = Error.stackTraceLimit;
|
||||
const limit = Error.stackTraceLimit;
|
||||
|
||||
if (typeof limit === "number" && limit < 25) {
|
||||
Error.stackTraceLimit = 25;
|
||||
}
|
||||
|
||||
var 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 "${_.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;
|
||||
@@ -75,6 +81,6 @@ function assertVersion(range) {
|
||||
throw Object.assign(err, {
|
||||
code: "BABEL_VERSION_UNSUPPORTED",
|
||||
version: _.version,
|
||||
range: range
|
||||
range
|
||||
});
|
||||
}
|
6
node_modules/@babel/core/lib/config/helpers/environment.js
generated
vendored
6
node_modules/@babel/core/lib/config/helpers/environment.js
generated
vendored
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.getEnv = getEnv;
|
||||
|
||||
function getEnv(defaultValue) {
|
||||
if (defaultValue === void 0) {
|
||||
defaultValue = "development";
|
||||
}
|
||||
|
||||
function getEnv(defaultValue = "development") {
|
||||
return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue;
|
||||
}
|
23
node_modules/@babel/core/lib/config/index.js
generated
vendored
23
node_modules/@babel/core/lib/config/index.js
generated
vendored
@@ -6,17 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.loadOptions = loadOptions;
|
||||
Object.defineProperty(exports, "default", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _full.default;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, "loadPartialConfig", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
get: function () {
|
||||
return _partial.loadPartialConfig;
|
||||
}
|
||||
});
|
||||
exports.OptionManager = void 0;
|
||||
|
||||
var _full = _interopRequireDefault(require("./full"));
|
||||
|
||||
@@ -25,20 +24,6 @@ var _partial = require("./partial");
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function loadOptions(opts) {
|
||||
var config = (0, _full.default)(opts);
|
||||
const config = (0, _full.default)(opts);
|
||||
return config ? config.options : null;
|
||||
}
|
||||
|
||||
var OptionManager = function () {
|
||||
function OptionManager() {}
|
||||
|
||||
var _proto = OptionManager.prototype;
|
||||
|
||||
_proto.init = function init(opts) {
|
||||
return loadOptions(opts);
|
||||
};
|
||||
|
||||
return OptionManager;
|
||||
}();
|
||||
|
||||
exports.OptionManager = OptionManager;
|
||||
}
|
52
node_modules/@babel/core/lib/config/item.js
generated
vendored
52
node_modules/@babel/core/lib/config/item.js
generated
vendored
@@ -8,9 +8,9 @@ exports.createConfigItem = createConfigItem;
|
||||
exports.getItemDescriptor = getItemDescriptor;
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -25,14 +25,12 @@ function createItemFromDescriptor(desc) {
|
||||
return new ConfigItem(desc);
|
||||
}
|
||||
|
||||
function createConfigItem(value, _temp) {
|
||||
var _ref = _temp === void 0 ? {} : _temp,
|
||||
_ref$dirname = _ref.dirname,
|
||||
dirname = _ref$dirname === void 0 ? "." : _ref$dirname,
|
||||
type = _ref.type;
|
||||
|
||||
var descriptor = (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), {
|
||||
type: type,
|
||||
function createConfigItem(value, {
|
||||
dirname = ".",
|
||||
type
|
||||
} = {}) {
|
||||
const descriptor = (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), {
|
||||
type,
|
||||
alias: "programmatic item"
|
||||
});
|
||||
return createItemFromDescriptor(descriptor);
|
||||
@@ -46,25 +44,23 @@ function getItemDescriptor(item) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var ConfigItem = function ConfigItem(descriptor) {
|
||||
this._descriptor = descriptor;
|
||||
Object.defineProperty(this, "_descriptor", {
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
if (this._descriptor.options === false) {
|
||||
throw new Error("Assertion failure - unexpected false options");
|
||||
class ConfigItem {
|
||||
constructor(descriptor) {
|
||||
this._descriptor = descriptor;
|
||||
Object.defineProperty(this, "_descriptor", {
|
||||
enumerable: false
|
||||
});
|
||||
this.value = this._descriptor.value;
|
||||
this.options = this._descriptor.options;
|
||||
this.dirname = this._descriptor.dirname;
|
||||
this.name = this._descriptor.name;
|
||||
this.file = this._descriptor.file ? {
|
||||
request: this._descriptor.file.request,
|
||||
resolved: this._descriptor.file.resolved
|
||||
} : undefined;
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
this.value = this._descriptor.value;
|
||||
this.options = this._descriptor.options;
|
||||
this.dirname = this._descriptor.dirname;
|
||||
this.name = this._descriptor.name;
|
||||
this.file = this._descriptor.file ? {
|
||||
request: this._descriptor.file.request,
|
||||
resolved: this._descriptor.file.resolved
|
||||
} : undefined;
|
||||
Object.freeze(this);
|
||||
};
|
||||
}
|
||||
|
||||
Object.freeze(ConfigItem.prototype);
|
108
node_modules/@babel/core/lib/config/partial.js
generated
vendored
108
node_modules/@babel/core/lib/config/partial.js
generated
vendored
@@ -7,9 +7,9 @@ exports.default = loadPrivatePartialConfig;
|
||||
exports.loadPartialConfig = loadPartialConfig;
|
||||
|
||||
function _path() {
|
||||
var data = _interopRequireDefault(require("path"));
|
||||
const data = _interopRequireDefault(require("path"));
|
||||
|
||||
_path = function _path() {
|
||||
_path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -28,45 +28,78 @@ 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) {
|
||||
switch (rootMode) {
|
||||
case "root":
|
||||
return rootDir;
|
||||
|
||||
case "upward-optional":
|
||||
{
|
||||
const upwardRootDir = (0, _files.findConfigUpwards)(rootDir);
|
||||
return upwardRootDir === null ? rootDir : upwardRootDir;
|
||||
}
|
||||
|
||||
case "upward":
|
||||
{
|
||||
const upwardRootDir = (0, _files.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}"`), {
|
||||
code: "BABEL_ROOT_NOT_FOUND",
|
||||
dirname: rootDir
|
||||
});
|
||||
}
|
||||
|
||||
default:
|
||||
throw new Error(`Assertion failure - unknown rootMode value`);
|
||||
}
|
||||
}
|
||||
|
||||
function loadPrivatePartialConfig(inputOpts) {
|
||||
if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) {
|
||||
throw new Error("Babel options must be an object, null, or undefined");
|
||||
}
|
||||
|
||||
var args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
|
||||
var _args$envName = args.envName,
|
||||
envName = _args$envName === void 0 ? (0, _environment.getEnv)() : _args$envName,
|
||||
_args$cwd = args.cwd,
|
||||
cwd = _args$cwd === void 0 ? "." : _args$cwd;
|
||||
const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {};
|
||||
const {
|
||||
envName = (0, _environment.getEnv)(),
|
||||
cwd = ".",
|
||||
root: rootDir = ".",
|
||||
rootMode = "root",
|
||||
caller
|
||||
} = args;
|
||||
|
||||
var absoluteCwd = _path().default.resolve(cwd);
|
||||
const absoluteCwd = _path().default.resolve(cwd);
|
||||
|
||||
var context = {
|
||||
filename: args.filename ? _path().default.resolve(cwd, args.filename) : null,
|
||||
const absoluteRootDir = resolveRootMode(_path().default.resolve(absoluteCwd, rootDir), rootMode);
|
||||
const context = {
|
||||
filename: typeof args.filename === "string" ? _path().default.resolve(cwd, args.filename) : undefined,
|
||||
cwd: absoluteCwd,
|
||||
envName: envName
|
||||
root: absoluteRootDir,
|
||||
envName,
|
||||
caller
|
||||
};
|
||||
var configChain = (0, _configChain.buildRootChain)(args, context);
|
||||
const configChain = (0, _configChain.buildRootChain)(args, context);
|
||||
if (!configChain) return null;
|
||||
var options = {};
|
||||
configChain.options.forEach(function (opts) {
|
||||
const options = {};
|
||||
configChain.options.forEach(opts => {
|
||||
(0, _util.mergeOptions)(options, opts);
|
||||
});
|
||||
options.babelrc = false;
|
||||
options.envName = envName;
|
||||
options.cwd = absoluteCwd;
|
||||
options.configFile = false;
|
||||
options.passPerPreset = false;
|
||||
options.plugins = configChain.plugins.map(function (descriptor) {
|
||||
return (0, _item.createItemFromDescriptor)(descriptor);
|
||||
});
|
||||
options.presets = configChain.presets.map(function (descriptor) {
|
||||
return (0, _item.createItemFromDescriptor)(descriptor);
|
||||
});
|
||||
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));
|
||||
return {
|
||||
options: options,
|
||||
context: context,
|
||||
options,
|
||||
context,
|
||||
ignore: configChain.ignore,
|
||||
babelrc: configChain.babelrc,
|
||||
config: configChain.config
|
||||
@@ -74,13 +107,15 @@ function loadPrivatePartialConfig(inputOpts) {
|
||||
}
|
||||
|
||||
function loadPartialConfig(inputOpts) {
|
||||
var result = loadPrivatePartialConfig(inputOpts);
|
||||
const result = loadPrivatePartialConfig(inputOpts);
|
||||
if (!result) return null;
|
||||
var options = result.options,
|
||||
babelrc = result.babelrc,
|
||||
ignore = result.ignore,
|
||||
config = result.config;
|
||||
(options.plugins || []).forEach(function (item) {
|
||||
const {
|
||||
options,
|
||||
babelrc,
|
||||
ignore,
|
||||
config
|
||||
} = result;
|
||||
(options.plugins || []).forEach(item => {
|
||||
if (item.value instanceof _plugin.default) {
|
||||
throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()");
|
||||
}
|
||||
@@ -88,8 +123,8 @@ function loadPartialConfig(inputOpts) {
|
||||
return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined);
|
||||
}
|
||||
|
||||
var PartialConfig = function () {
|
||||
function PartialConfig(options, babelrc, ignore, config) {
|
||||
class PartialConfig {
|
||||
constructor(options, babelrc, ignore, config) {
|
||||
this.options = options;
|
||||
this.babelignore = ignore;
|
||||
this.babelrc = babelrc;
|
||||
@@ -97,13 +132,10 @@ var PartialConfig = function () {
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
var _proto = PartialConfig.prototype;
|
||||
|
||||
_proto.hasFilesystemConfig = function hasFilesystemConfig() {
|
||||
hasFilesystemConfig() {
|
||||
return this.babelrc !== undefined || this.config !== undefined;
|
||||
};
|
||||
}
|
||||
|
||||
return PartialConfig;
|
||||
}();
|
||||
}
|
||||
|
||||
Object.freeze(PartialConfig.prototype);
|
52
node_modules/@babel/core/lib/config/pattern-to-regex.js
generated
vendored
Normal file
52
node_modules/@babel/core/lib/config/pattern-to-regex.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = pathToPattern;
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(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 endSep = `(?:${sep}|$)`;
|
||||
const substitution = `[^${sep}]+`;
|
||||
const starPat = `(?:${substitution}${sep})`;
|
||||
const starPatLast = `(?:${substitution}${endSep})`;
|
||||
const starStarPat = `${starPat}*?`;
|
||||
const starStarPatLast = `${starPat}*?${starPatLast}?`;
|
||||
|
||||
function pathToPattern(pattern, dirname) {
|
||||
const parts = _path().default.resolve(dirname, pattern).split(_path().default.sep);
|
||||
|
||||
return new RegExp(["^", ...parts.map((part, i) => {
|
||||
const last = i === parts.length - 1;
|
||||
if (part === "**") return last ? starStarPatLast : starStarPat;
|
||||
if (part === "*") return last ? starPatLast : starPat;
|
||||
|
||||
if (part.indexOf("*.") === 0) {
|
||||
return substitution + (0, _escapeRegExp().default)(part.slice(1)) + (last ? endSep : sep);
|
||||
}
|
||||
|
||||
return (0, _escapeRegExp().default)(part) + (last ? endSep : sep);
|
||||
})].join(""));
|
||||
}
|
23
node_modules/@babel/core/lib/config/plugin.js
generated
vendored
23
node_modules/@babel/core/lib/config/plugin.js
generated
vendored
@@ -5,15 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
var Plugin = function Plugin(plugin, options, key) {
|
||||
this.key = plugin.name || key;
|
||||
this.manipulateOptions = plugin.manipulateOptions;
|
||||
this.post = plugin.post;
|
||||
this.pre = plugin.pre;
|
||||
this.visitor = plugin.visitor || {};
|
||||
this.parserOverride = plugin.parserOverride;
|
||||
this.generatorOverride = plugin.generatorOverride;
|
||||
this.options = options;
|
||||
};
|
||||
class Plugin {
|
||||
constructor(plugin, options, key) {
|
||||
this.key = plugin.name || key;
|
||||
this.manipulateOptions = plugin.manipulateOptions;
|
||||
this.post = plugin.post;
|
||||
this.pre = plugin.pre;
|
||||
this.visitor = plugin.visitor || {};
|
||||
this.parserOverride = plugin.parserOverride;
|
||||
this.generatorOverride = plugin.generatorOverride;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = Plugin;
|
27
node_modules/@babel/core/lib/config/util.js
generated
vendored
27
node_modules/@babel/core/lib/config/util.js
generated
vendored
@@ -6,34 +6,25 @@ Object.defineProperty(exports, "__esModule", {
|
||||
exports.mergeOptions = mergeOptions;
|
||||
|
||||
function mergeOptions(target, source) {
|
||||
var _arr = Object.keys(source);
|
||||
|
||||
for (var _i = 0; _i < _arr.length; _i++) {
|
||||
var k = _arr[_i];
|
||||
|
||||
for (const k of Object.keys(source)) {
|
||||
if (k === "parserOpts" && source.parserOpts) {
|
||||
var parserOpts = source.parserOpts;
|
||||
var targetObj = target.parserOpts = target.parserOpts || {};
|
||||
const parserOpts = source.parserOpts;
|
||||
const targetObj = target.parserOpts = target.parserOpts || {};
|
||||
mergeDefaultFields(targetObj, parserOpts);
|
||||
} else if (k === "generatorOpts" && source.generatorOpts) {
|
||||
var generatorOpts = source.generatorOpts;
|
||||
|
||||
var _targetObj = target.generatorOpts = target.generatorOpts || {};
|
||||
|
||||
mergeDefaultFields(_targetObj, generatorOpts);
|
||||
const generatorOpts = source.generatorOpts;
|
||||
const targetObj = target.generatorOpts = target.generatorOpts || {};
|
||||
mergeDefaultFields(targetObj, generatorOpts);
|
||||
} else {
|
||||
var val = source[k];
|
||||
const val = source[k];
|
||||
if (val !== undefined) target[k] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mergeDefaultFields(target, source) {
|
||||
var _arr2 = Object.keys(source);
|
||||
|
||||
for (var _i2 = 0; _i2 < _arr2.length; _i2++) {
|
||||
var k = _arr2[_i2];
|
||||
var val = source[k];
|
||||
for (const k of Object.keys(source)) {
|
||||
const val = source[k];
|
||||
if (val !== undefined) target[k] = val;
|
||||
}
|
||||
}
|
165
node_modules/@babel/core/lib/config/validation/option-assertions.js
generated
vendored
165
node_modules/@babel/core/lib/config/validation/option-assertions.js
generated
vendored
@@ -3,9 +3,13 @@
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.msg = msg;
|
||||
exports.access = access;
|
||||
exports.assertRootMode = assertRootMode;
|
||||
exports.assertSourceMaps = assertSourceMaps;
|
||||
exports.assertCompact = assertCompact;
|
||||
exports.assertSourceType = assertSourceType;
|
||||
exports.assertCallerMetadata = assertCallerMetadata;
|
||||
exports.assertInputSourceMap = assertInputSourceMap;
|
||||
exports.assertString = assertString;
|
||||
exports.assertFunction = assertFunction;
|
||||
@@ -18,109 +22,166 @@ exports.assertConfigFileSearch = assertConfigFileSearch;
|
||||
exports.assertBabelrcSearch = assertBabelrcSearch;
|
||||
exports.assertPluginList = assertPluginList;
|
||||
|
||||
function assertSourceMaps(key, value) {
|
||||
function msg(loc) {
|
||||
switch (loc.type) {
|
||||
case "root":
|
||||
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:
|
||||
throw new Error(`Assertion failure: Unknown type ${loc.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
function access(loc, name) {
|
||||
return {
|
||||
type: "access",
|
||||
name,
|
||||
parent: loc
|
||||
};
|
||||
}
|
||||
|
||||
function assertRootMode(loc, value) {
|
||||
if (value !== undefined && value !== "root" && value !== "upward" && value !== "upward-optional") {
|
||||
throw new Error(`${msg(loc)} must be a "root", "upward", "upward-optional" or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertSourceMaps(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && value !== "inline" && value !== "both") {
|
||||
throw new Error("." + key + " must be a boolean, \"inline\", \"both\", or undefined");
|
||||
throw new Error(`${msg(loc)} must be a boolean, "inline", "both", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertCompact(key, value) {
|
||||
function assertCompact(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && value !== "auto") {
|
||||
throw new Error("." + key + " must be a boolean, \"auto\", or undefined");
|
||||
throw new Error(`${msg(loc)} must be a boolean, "auto", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertSourceType(key, value) {
|
||||
function assertSourceType(loc, value) {
|
||||
if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") {
|
||||
throw new Error("." + key + " must be \"module\", \"script\", \"unambiguous\", or undefined");
|
||||
throw new Error(`${msg(loc)} must be "module", "script", "unambiguous", or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertInputSourceMap(key, value) {
|
||||
function assertCallerMetadata(loc, value) {
|
||||
const obj = assertObject(loc, value);
|
||||
|
||||
if (obj) {
|
||||
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") {
|
||||
throw new Error(`${msg(propLoc)} must be null, undefined, a boolean, a string, or a number.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertInputSourceMap(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) {
|
||||
throw new Error(".inputSourceMap must be a boolean, object, or undefined");
|
||||
throw new Error(`${msg(loc)} must be a boolean, object, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertString(key, value) {
|
||||
function assertString(loc, value) {
|
||||
if (value !== undefined && typeof value !== "string") {
|
||||
throw new Error("." + key + " must be a string, or undefined");
|
||||
throw new Error(`${msg(loc)} must be a string, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertFunction(key, value) {
|
||||
function assertFunction(loc, value) {
|
||||
if (value !== undefined && typeof value !== "function") {
|
||||
throw new Error("." + key + " must be a function, or undefined");
|
||||
throw new Error(`${msg(loc)} must be a function, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertBoolean(key, value) {
|
||||
function assertBoolean(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean") {
|
||||
throw new Error("." + key + " must be a boolean, or undefined");
|
||||
throw new Error(`${msg(loc)} must be a boolean, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertObject(key, value) {
|
||||
function assertObject(loc, value) {
|
||||
if (value !== undefined && (typeof value !== "object" || Array.isArray(value) || !value)) {
|
||||
throw new Error("." + key + " must be an object, or undefined");
|
||||
throw new Error(`${msg(loc)} must be an object, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertArray(key, value) {
|
||||
function assertArray(loc, value) {
|
||||
if (value != null && !Array.isArray(value)) {
|
||||
throw new Error("." + key + " must be an array, or undefined");
|
||||
throw new Error(`${msg(loc)} must be an array, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertIgnoreList(key, value) {
|
||||
var arr = assertArray(key, value);
|
||||
function assertIgnoreList(loc, value) {
|
||||
const arr = assertArray(loc, value);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach(function (item, i) {
|
||||
return assertIgnoreItem(key, i, item);
|
||||
});
|
||||
arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function assertIgnoreItem(key, index, value) {
|
||||
function assertIgnoreItem(loc, value) {
|
||||
if (typeof value !== "string" && typeof value !== "function" && !(value instanceof RegExp)) {
|
||||
throw new Error("." + key + "[" + index + "] must be an array of string/Funtion/RegExp values, or undefined");
|
||||
throw new Error(`${msg(loc)} must be an array of string/Funtion/RegExp values, or undefined`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertConfigApplicableTest(key, value) {
|
||||
function assertConfigApplicableTest(loc, value) {
|
||||
if (value === undefined) return value;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item, i) {
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(item)) {
|
||||
throw new Error("." + key + "[" + i + "] must be a string/Function/RegExp.");
|
||||
throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`);
|
||||
}
|
||||
});
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error("." + key + " must be a string/Function/RegExp, or an array of those");
|
||||
throw new Error(`${msg(loc)} must be a string/Function/RegExp, or an array of those`);
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -130,79 +191,77 @@ function checkValidTest(value) {
|
||||
return typeof value === "string" || typeof value === "function" || value instanceof RegExp;
|
||||
}
|
||||
|
||||
function assertConfigFileSearch(key, value) {
|
||||
function assertConfigFileSearch(loc, value) {
|
||||
if (value !== undefined && typeof value !== "boolean" && typeof value !== "string") {
|
||||
throw new Error("." + key + " must be a undefined, a boolean, a string, " + ("got " + JSON.stringify(value)));
|
||||
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string, ` + `got ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertBabelrcSearch(key, value) {
|
||||
function assertBabelrcSearch(loc, value) {
|
||||
if (value === undefined || typeof value === "boolean") return value;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach(function (item, i) {
|
||||
if (typeof item !== "string") {
|
||||
throw new Error("." + key + "[" + i + "] must be a string.");
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(item)) {
|
||||
throw new Error(`${msg(access(loc, i))} must be a string/Function/RegExp.`);
|
||||
}
|
||||
});
|
||||
} else if (typeof value !== "string") {
|
||||
throw new Error("." + key + " must be a undefined, a boolean, a string, " + ("or an array of strings, got " + JSON.stringify(value)));
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` + `or an array of those, got ${JSON.stringify(value)}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertPluginList(key, value) {
|
||||
var arr = assertArray(key, value);
|
||||
function assertPluginList(loc, value) {
|
||||
const arr = assertArray(loc, value);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach(function (item, i) {
|
||||
return assertPluginItem(key, i, item);
|
||||
});
|
||||
arr.forEach((item, i) => assertPluginItem(access(loc, i), item));
|
||||
}
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
function assertPluginItem(key, index, value) {
|
||||
function assertPluginItem(loc, value) {
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 0) {
|
||||
throw new Error("." + key + "[" + index + "] must include an object");
|
||||
throw new Error(`${msg(loc)} must include an object`);
|
||||
}
|
||||
|
||||
if (value.length > 3) {
|
||||
throw new Error("." + key + "[" + index + "] may only be a two-tuple or three-tuple");
|
||||
throw new Error(`${msg(loc)} may only be a two-tuple or three-tuple`);
|
||||
}
|
||||
|
||||
assertPluginTarget(key, index, true, value[0]);
|
||||
assertPluginTarget(access(loc, 0), value[0]);
|
||||
|
||||
if (value.length > 1) {
|
||||
var opts = value[1];
|
||||
const opts = value[1];
|
||||
|
||||
if (opts !== undefined && opts !== false && (typeof opts !== "object" || Array.isArray(opts))) {
|
||||
throw new Error("." + key + "[" + index + "][1] must be an object, false, or undefined");
|
||||
throw new Error(`${msg(access(loc, 1))} must be an object, false, or undefined`);
|
||||
}
|
||||
}
|
||||
|
||||
if (value.length === 3) {
|
||||
var name = value[2];
|
||||
const name = value[2];
|
||||
|
||||
if (name !== undefined && typeof name !== "string") {
|
||||
throw new Error("." + key + "[" + index + "][2] must be a string, or undefined");
|
||||
throw new Error(`${msg(access(loc, 2))} must be a string, or undefined`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertPluginTarget(key, index, false, value);
|
||||
assertPluginTarget(loc, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function assertPluginTarget(key, index, inArray, value) {
|
||||
function assertPluginTarget(loc, value) {
|
||||
if ((typeof value !== "object" || !value) && typeof value !== "string" && typeof value !== "function") {
|
||||
throw new Error("." + key + "[" + index + "]" + (inArray ? "[0]" : "") + " must be a string, object, function");
|
||||
throw new Error(`${msg(loc)} must be a string, object, function`);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
159
node_modules/@babel/core/lib/config/validation/options.js
generated
vendored
159
node_modules/@babel/core/lib/config/validation/options.js
generated
vendored
@@ -13,33 +13,37 @@ var _optionAssertions = require("./option-assertions");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ROOT_VALIDATORS = {
|
||||
const ROOT_VALIDATORS = {
|
||||
cwd: _optionAssertions.assertString,
|
||||
root: _optionAssertions.assertString,
|
||||
rootMode: _optionAssertions.assertRootMode,
|
||||
configFile: _optionAssertions.assertConfigFileSearch,
|
||||
caller: _optionAssertions.assertCallerMetadata,
|
||||
filename: _optionAssertions.assertString,
|
||||
filenameRelative: _optionAssertions.assertString,
|
||||
babelrc: _optionAssertions.assertBoolean,
|
||||
babelrcRoots: _optionAssertions.assertBabelrcSearch,
|
||||
code: _optionAssertions.assertBoolean,
|
||||
ast: _optionAssertions.assertBoolean,
|
||||
envName: _optionAssertions.assertString
|
||||
};
|
||||
var NONPRESET_VALIDATORS = {
|
||||
extends: _optionAssertions.assertString,
|
||||
env: assertEnvSet,
|
||||
ignore: _optionAssertions.assertIgnoreList,
|
||||
only: _optionAssertions.assertIgnoreList,
|
||||
overrides: assertOverridesList,
|
||||
test: _optionAssertions.assertConfigApplicableTest,
|
||||
include: _optionAssertions.assertConfigApplicableTest,
|
||||
exclude: _optionAssertions.assertConfigApplicableTest
|
||||
const BABELRC_VALIDATORS = {
|
||||
babelrc: _optionAssertions.assertBoolean,
|
||||
babelrcRoots: _optionAssertions.assertBabelrcSearch
|
||||
};
|
||||
var COMMON_VALIDATORS = {
|
||||
const NONPRESET_VALIDATORS = {
|
||||
extends: _optionAssertions.assertString,
|
||||
ignore: _optionAssertions.assertIgnoreList,
|
||||
only: _optionAssertions.assertIgnoreList
|
||||
};
|
||||
const COMMON_VALIDATORS = {
|
||||
inputSourceMap: _optionAssertions.assertInputSourceMap,
|
||||
presets: _optionAssertions.assertPluginList,
|
||||
plugins: _optionAssertions.assertPluginList,
|
||||
passPerPreset: _optionAssertions.assertBoolean,
|
||||
env: assertEnvSet,
|
||||
overrides: assertOverridesList,
|
||||
test: _optionAssertions.assertConfigApplicableTest,
|
||||
include: _optionAssertions.assertConfigApplicableTest,
|
||||
exclude: _optionAssertions.assertConfigApplicableTest,
|
||||
retainLines: _optionAssertions.assertBoolean,
|
||||
comments: _optionAssertions.assertBoolean,
|
||||
shouldPrintComment: _optionAssertions.assertFunction,
|
||||
@@ -62,44 +66,60 @@ var COMMON_VALIDATORS = {
|
||||
generatorOpts: _optionAssertions.assertObject
|
||||
};
|
||||
|
||||
function getSource(loc) {
|
||||
return loc.type === "root" ? loc.source : getSource(loc.parent);
|
||||
}
|
||||
|
||||
function validate(type, opts) {
|
||||
return validateNested({
|
||||
type: "root",
|
||||
source: type
|
||||
}, opts);
|
||||
}
|
||||
|
||||
function validateNested(loc, opts) {
|
||||
const type = getSource(loc);
|
||||
assertNoDuplicateSourcemap(opts);
|
||||
Object.keys(opts).forEach(function (key) {
|
||||
Object.keys(opts).forEach(key => {
|
||||
const optLoc = {
|
||||
type: "option",
|
||||
name: key,
|
||||
parent: loc
|
||||
};
|
||||
|
||||
if (type === "preset" && NONPRESET_VALIDATORS[key]) {
|
||||
throw new Error("." + key + " is not allowed in preset options");
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in preset options`);
|
||||
}
|
||||
|
||||
if (type !== "arguments" && ROOT_VALIDATORS[key]) {
|
||||
throw new Error("." + key + " is only allowed in root programmatic options");
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options`);
|
||||
}
|
||||
|
||||
if (type === "env" && key === "env") {
|
||||
throw new Error("." + key + " is not allowed inside another env block");
|
||||
if (type !== "arguments" && type !== "configfile" && BABELRC_VALIDATORS[key]) {
|
||||
if (type === "babelrcfile" || type === "extendsfile") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is not allowed in .babelrc or "extends"ed files, only in root programmatic options, ` + `or babel.config.js/config file options`);
|
||||
}
|
||||
|
||||
throw new Error(`${(0, _optionAssertions.msg)(optLoc)} is only allowed in root programmatic options, or babel.config.js/config file options`);
|
||||
}
|
||||
|
||||
if (type === "env" && key === "overrides") {
|
||||
throw new Error("." + key + " is not allowed inside an env block");
|
||||
}
|
||||
|
||||
if (type === "override" && key === "overrides") {
|
||||
throw new Error("." + key + " is not allowed inside an overrides block");
|
||||
}
|
||||
|
||||
var validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || ROOT_VALIDATORS[key];
|
||||
if (validator) validator(key, opts[key]);else throw buildUnknownError(key);
|
||||
const validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || BABELRC_VALIDATORS[key] || ROOT_VALIDATORS[key] || throwUnknownError;
|
||||
validator(optLoc, opts[key]);
|
||||
});
|
||||
return opts;
|
||||
}
|
||||
|
||||
function buildUnknownError(key) {
|
||||
function throwUnknownError(loc) {
|
||||
const key = loc.name;
|
||||
|
||||
if (_removed.default[key]) {
|
||||
var _removed$key = _removed.default[key],
|
||||
message = _removed$key.message,
|
||||
_removed$key$version = _removed$key.version,
|
||||
version = _removed$key$version === void 0 ? 5 : _removed$key$version;
|
||||
throw new ReferenceError("Using removed Babel " + version + " option: ." + key + " - " + message);
|
||||
const {
|
||||
message,
|
||||
version = 5
|
||||
} = _removed.default[key];
|
||||
throw new ReferenceError(`Using removed Babel ${version} option: ${(0, _optionAssertions.msg)(loc)} - ${message}`);
|
||||
} else {
|
||||
var unknownOptErr = "Unknown option: ." + key + ". Check out http://babeljs.io/docs/usage/options/ for more information about options.";
|
||||
const unknownOptErr = `Unknown option: ${(0, _optionAssertions.msg)(loc)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`;
|
||||
throw new ReferenceError(unknownOptErr);
|
||||
}
|
||||
}
|
||||
@@ -114,48 +134,53 @@ function assertNoDuplicateSourcemap(opts) {
|
||||
}
|
||||
}
|
||||
|
||||
function assertEnvSet(key, value) {
|
||||
var obj = (0, _optionAssertions.assertObject)(key, value);
|
||||
function assertEnvSet(loc, value) {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside of another .env block`);
|
||||
}
|
||||
|
||||
const parent = loc.parent;
|
||||
const obj = (0, _optionAssertions.assertObject)(loc, value);
|
||||
|
||||
if (obj) {
|
||||
var _arr = Object.keys(obj);
|
||||
|
||||
for (var _i = 0; _i < _arr.length; _i++) {
|
||||
var _key = _arr[_i];
|
||||
|
||||
var _env = (0, _optionAssertions.assertObject)(_key, obj[_key]);
|
||||
|
||||
if (_env) validate("env", _env);
|
||||
for (const envName of Object.keys(obj)) {
|
||||
const env = (0, _optionAssertions.assertObject)((0, _optionAssertions.access)(loc, envName), obj[envName]);
|
||||
if (!env) continue;
|
||||
const envLoc = {
|
||||
type: "env",
|
||||
name: envName,
|
||||
parent
|
||||
};
|
||||
validateNested(envLoc, env);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function assertOverridesList(key, value) {
|
||||
var arr = (0, _optionAssertions.assertArray)(key, value);
|
||||
function assertOverridesList(loc, value) {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${(0, _optionAssertions.msg)(loc)} is not allowed inside an .env block`);
|
||||
}
|
||||
|
||||
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) {
|
||||
for (var _iterator = arr.entries(), _isArray = Array.isArray(_iterator), _i2 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i2 >= _iterator.length) break;
|
||||
_ref = _iterator[_i2++];
|
||||
} else {
|
||||
_i2 = _iterator.next();
|
||||
if (_i2.done) break;
|
||||
_ref = _i2.value;
|
||||
}
|
||||
|
||||
var _ref2 = _ref,
|
||||
index = _ref2[0],
|
||||
item = _ref2[1];
|
||||
|
||||
var _env2 = (0, _optionAssertions.assertObject)("" + index, item);
|
||||
|
||||
if (!_env2) throw new Error("." + key + "[" + index + "] must be an object");
|
||||
validate("override", _env2);
|
||||
for (const [index, item] of arr.entries()) {
|
||||
const objLoc = (0, _optionAssertions.access)(loc, index);
|
||||
const env = (0, _optionAssertions.assertObject)(objLoc, item);
|
||||
if (!env) throw new Error(`${(0, _optionAssertions.msg)(objLoc)} must be an object`);
|
||||
const overridesLoc = {
|
||||
type: "overrides",
|
||||
index,
|
||||
parent
|
||||
};
|
||||
validateNested(overridesLoc, env);
|
||||
}
|
||||
}
|
||||
|
||||
|
22
node_modules/@babel/core/lib/config/validation/plugins.js
generated
vendored
22
node_modules/@babel/core/lib/config/validation/plugins.js
generated
vendored
@@ -7,7 +7,7 @@ exports.validatePluginObject = validatePluginObject;
|
||||
|
||||
var _optionAssertions = require("./option-assertions");
|
||||
|
||||
var VALIDATORS = {
|
||||
const VALIDATORS = {
|
||||
name: _optionAssertions.assertString,
|
||||
manipulateOptions: _optionAssertions.assertFunction,
|
||||
pre: _optionAssertions.assertFunction,
|
||||
@@ -19,15 +19,13 @@ var VALIDATORS = {
|
||||
};
|
||||
|
||||
function assertVisitorMap(key, value) {
|
||||
var obj = (0, _optionAssertions.assertObject)(key, value);
|
||||
const obj = (0, _optionAssertions.assertObject)(key, value);
|
||||
|
||||
if (obj) {
|
||||
Object.keys(obj).forEach(function (prop) {
|
||||
return assertVisitorHandler(prop, obj[prop]);
|
||||
});
|
||||
Object.keys(obj).forEach(prop => 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(`.${key} cannot contain catch-all "enter" or "exit" handlers. Please target individual nodes.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,22 +34,22 @@ function assertVisitorMap(key, value) {
|
||||
|
||||
function assertVisitorHandler(key, value) {
|
||||
if (value && typeof value === "object") {
|
||||
Object.keys(value).forEach(function (handler) {
|
||||
Object.keys(value).forEach(handler => {
|
||||
if (handler !== "enter" && handler !== "exit") {
|
||||
throw new Error(".visitor[\"" + key + "\"] may only have .enter and/or .exit handlers.");
|
||||
throw new Error(`.visitor["${key}"] may only have .enter and/or .exit handlers.`);
|
||||
}
|
||||
});
|
||||
} else if (typeof value !== "function") {
|
||||
throw new Error(".visitor[\"" + key + "\"] must be a function");
|
||||
throw new Error(`.visitor["${key}"] must be a function`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function validatePluginObject(obj) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var validator = VALIDATORS[key];
|
||||
if (validator) validator(key, obj[key]);else throw new Error("." + key + " is not a valid Plugin property");
|
||||
Object.keys(obj).forEach(key => {
|
||||
const validator = VALIDATORS[key];
|
||||
if (validator) validator(key, obj[key]);else throw new Error(`.${key} is not a valid Plugin property`);
|
||||
});
|
||||
return obj;
|
||||
}
|
Reference in New Issue
Block a user