diff options
Diffstat (limited to 'node_modules/@babel/core/lib')
42 files changed, 4767 insertions, 0 deletions
diff --git a/node_modules/@babel/core/lib/config/caching.js b/node_modules/@babel/core/lib/config/caching.js new file mode 100644 index 00000000..d092b2d0 --- /dev/null +++ b/node_modules/@babel/core/lib/config/caching.js @@ -0,0 +1,200 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.makeStrongCache = makeStrongCache; +exports.makeWeakCache = makeWeakCache; + +function makeStrongCache(handler) { + return makeCachedFunction(new Map(), handler); +} + +function makeWeakCache(handler) { + return makeCachedFunction(new WeakMap(), handler); +} + +function makeCachedFunction(callCache, handler) { + return function cachedFunction(arg, data) { + 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; + } + + const _ref = _ref2; + const value = _ref.value, + valid = _ref.valid; + if (valid(data)) return value; + } + } + + const cache = new CacheConfigurator(data); + const value = handler(arg, cache); + if (!cache.configured()) cache.forever(); + cache.deactivate(); + + switch (cache.mode()) { + case "forever": + cachedValue = [{ + value, + valid: () => true + }]; + callCache.set(arg, cachedValue); + break; + + case "invalidate": + cachedValue = [{ + value, + valid: cache.validator() + }]; + callCache.set(arg, cachedValue); + break; + + case "valid": + if (cachedValue) { + cachedValue.push({ + value, + valid: cache.validator() + }); + } else { + cachedValue = [{ + value, + valid: cache.validator() + }]; + callCache.set(arg, cachedValue); + } + + } + + return value; + }; +} + +class CacheConfigurator { + constructor(data) { + this._active = true; + this._never = false; + this._forever = false; + this._invalidate = false; + this._configured = false; + this._pairs = []; + this._data = data; + } + + simple() { + return makeSimpleConfigurator(this); + } + + mode() { + if (this._never) return "never"; + if (this._forever) return "forever"; + if (this._invalidate) return "invalidate"; + return "valid"; + } + + forever() { + if (!this._active) { + throw new Error("Cannot change caching after evaluation has completed."); + } + + if (this._never) { + throw new Error("Caching has already been configured with .never()"); + } + + this._forever = true; + this._configured = true; + } + + never() { + if (!this._active) { + throw new Error("Cannot change caching after evaluation has completed."); + } + + if (this._forever) { + throw new Error("Caching has already been configured with .forever()"); + } + + this._never = true; + this._configured = true; + } + + using(handler) { + if (!this._active) { + throw new Error("Cannot change caching after evaluation has completed."); + } + + if (this._never || this._forever) { + throw new Error("Caching has already been configured with .never or .forever()"); + } + + this._configured = true; + const key = handler(this._data); + + this._pairs.push([key, handler]); + + return key; + } + + invalidate(handler) { + if (!this._active) { + throw new Error("Cannot change caching after evaluation has completed."); + } + + if (this._never || this._forever) { + throw new Error("Caching has already been configured with .never or .forever()"); + } + + this._invalidate = true; + this._configured = true; + const key = handler(this._data); + + this._pairs.push([key, handler]); + + return key; + } + + validator() { + const pairs = this._pairs; + return data => pairs.every(([key, fn]) => key === fn(data)); + } + + deactivate() { + this._active = false; + } + + configured() { + return this._configured; + } + +} + +function makeSimpleConfigurator(cache) { + function cacheFn(val) { + if (typeof val === "boolean") { + if (val) cache.forever();else cache.never(); + return; + } + + return cache.using(val); + } + + cacheFn.forever = () => cache.forever(); + + cacheFn.never = () => cache.never(); + + cacheFn.using = cb => cache.using(() => cb()); + + cacheFn.invalidate = cb => cache.invalidate(() => cb()); + + return cacheFn; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/config-chain.js b/node_modules/@babel/core/lib/config/config-chain.js new file mode 100644 index 00000000..22bca2bd --- /dev/null +++ b/node_modules/@babel/core/lib/config/config-chain.js @@ -0,0 +1,487 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.buildRootChain = buildRootChain; +exports.buildPresetChain = void 0; + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +function _micromatch() { + const data = _interopRequireDefault(require("micromatch")); + + _micromatch = function _micromatch() { + return data; + }; + + return data; +} + +function _debug() { + const data = _interopRequireDefault(require("debug")); + + _debug = function _debug() { + return data; + }; + + return data; +} + +var _options = require("./validation/options"); + +var _files = require("./files"); + +var _caching = require("./caching"); + +var _configDescriptors = require("./config-descriptors"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const debug = (0, _debug().default)("babel:config:config-chain"); +const buildPresetChain = 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.buildPresetChain = buildPresetChain; +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) { + const programmaticChain = loadProgrammaticChain({ + options: opts, + dirname: context.cwd + }, context); + if (!programmaticChain) return null; + const _opts$root = opts.root, + rootDir = _opts$root === void 0 ? "." : _opts$root, + _opts$configFile = opts.configFile, + configFileName = _opts$configFile === void 0 ? true : _opts$configFile; + let babelrc = opts.babelrc, + babelrcRoots = opts.babelrcRoots; + + const absoluteRoot = _path().default.resolve(context.cwd, rootDir); + + let 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); + } + + const configFileChain = emptyChain(); + + if (configFile) { + const validatedFile = validateConfigFile(configFile); + const result = loadFileChain(validatedFile, context); + if (!result) return null; + + if (babelrc === undefined) { + babelrc = validatedFile.options.babelrc; + } + + if (babelrcRoots === undefined) { + babelrcRoots = validatedFile.options.babelrcRoots; + } + + mergeChain(configFileChain, result); + } + + const pkgData = typeof context.filename === "string" ? (0, _files.findPackageData)(context.filename) : null; + let ignoreFile, babelrcFile; + const fileChain = emptyChain(); + + if ((babelrc === true || babelrc === undefined) && pkgData && babelrcLoadEnabled(context, pkgData, babelrcRoots, absoluteRoot)) { + var _findRelativeConfig = (0, _files.findRelativeConfig)(pkgData, context.envName); + + ignoreFile = _findRelativeConfig.ignore; + babelrcFile = _findRelativeConfig.config; + + if (ignoreFile && shouldIgnore(context, ignoreFile.ignore, null, ignoreFile.dirname)) { + return null; + } + + if (babelrcFile) { + const result = loadFileChain(validateBabelrcFile(babelrcFile), context); + if (!result) return null; + mergeChain(fileChain, result); + } + } + + const chain = mergeChain(mergeChain(mergeChain(emptyChain(), configFileChain), fileChain), programmaticChain); + return { + plugins: dedupDescriptors(chain.plugins), + presets: dedupDescriptors(chain.presets), + options: chain.options.map(o => normalizeOptions(o)), + ignore: ignoreFile || undefined, + babelrc: babelrcFile || undefined, + config: configFile || undefined + }; +} + +function babelrcLoadEnabled(context, pkgData, babelrcRoots, absoluteRoot) { + if (typeof babelrcRoots === "boolean") return babelrcRoots; + + if (babelrcRoots === undefined) { + return pkgData.directories.indexOf(absoluteRoot) !== -1; + } + + let babelrcPatterns = babelrcRoots; + if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns]; + babelrcPatterns = babelrcPatterns.map(pat => _path().default.resolve(context.cwd, pat)); + + if (babelrcPatterns.length === 1 && babelrcPatterns[0] === absoluteRoot) { + return pkgData.directories.indexOf(absoluteRoot) !== -1; + } + + return (0, _micromatch().default)(pkgData.directories, babelrcPatterns).length > 0; +} + +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({ + dirname, + options +}, alias, descriptors, envName) { + const opts = options.env && options.env[envName]; + return opts ? descriptors(dirname, opts, `${alias}.env["${envName}"]`) : null; +} + +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}]`); +} + +function buildOverrideEnvDescriptors({ + dirname, + options +}, alias, descriptors, index, envName) { + const override = options.overrides && options.overrides[index]; + if (!override) throw new Error("Assertion failure - missing override"); + const opts = override.env && override.env[envName]; + return opts ? descriptors(dirname, opts, `${alias}.overrides[${index}].env["${envName}"]`) : null; +} + +function makeChainWalker({ + root, + env, + overrides, + overridesEnv +}) { + return (input, context, files = new Set()) => { + const dirname = input.dirname; + const flattenedConfigs = []; + const rootOpts = root(input); + + if (configIsApplicable(rootOpts, dirname, context)) { + flattenedConfigs.push(rootOpts); + const envOpts = env(input, context.envName); + + if (envOpts && configIsApplicable(envOpts, dirname, context)) { + flattenedConfigs.push(envOpts); + } + + (rootOpts.options.overrides || []).forEach((_, index) => { + const overrideOps = overrides(input, index); + + if (configIsApplicable(overrideOps, dirname, context)) { + flattenedConfigs.push(overrideOps); + const overrideEnvOpts = overridesEnv(input, index, context.envName); + + if (overrideEnvOpts && configIsApplicable(overrideEnvOpts, dirname, context)) { + flattenedConfigs.push(overrideEnvOpts); + } + } + }); + } + + if (flattenedConfigs.some(({ + options: { + ignore, + only + } + }) => shouldIgnore(context, ignore, only, dirname))) { + return null; + } + + const chain = emptyChain(); + + for (var _i = 0; _i < flattenedConfigs.length; _i++) { + const op = flattenedConfigs[_i]; + + if (!mergeExtendsChain(chain, op.options, dirname, context, files)) { + return null; + } + + mergeChainOpts(chain, op); + } + + return chain; + }; +} + +function mergeExtendsChain(chain, opts, dirname, context, files) { + if (opts.extends === undefined) return true; + const file = (0, _files.loadConfig)(opts.extends, dirname, context.envName); + + if (files.has(file)) { + throw new Error(`Configuration cycle detected loading ${file.filepath}.\n` + `File already loaded following the config chain:\n` + Array.from(files, file => ` - ${file.filepath}`).join("\n")); + } + + files.add(file); + const fileChain = loadFileChain(validateExtendFile(file), context, files); + files.delete(file); + if (!fileChain) return false; + mergeChain(chain, fileChain); + return true; +} + +function mergeChain(target, source) { + target.options.push(...source.options); + target.plugins.push(...source.plugins); + target.presets.push(...source.presets); + return target; +} + +function mergeChainOpts(target, { + options, + plugins, + presets +}) { + target.options.push(options); + target.plugins.push(...plugins()); + target.presets.push(...presets()); + return target; +} + +function emptyChain() { + return { + options: [], + presets: [], + plugins: [] + }; +} + +function normalizeOptions(opts) { + const options = Object.assign({}, opts); + delete options.extends; + delete options.env; + delete options.plugins; + delete options.presets; + delete options.passPerPreset; + delete options.ignore; + delete options.only; + + if (options.sourceMap) { + options.sourceMaps = options.sourceMap; + delete options.sourceMap; + } + + return options; +} + +function dedupDescriptors(items) { + const map = new Map(); + const descriptors = []; + + for (var _iterator = items, _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; + } + + const item = _ref; + + if (typeof item.value === "function") { + const fnKey = item.value; + let nameMap = map.get(fnKey); + + if (!nameMap) { + nameMap = new Map(); + map.set(fnKey, nameMap); + } + + let desc = nameMap.get(item.name); + + if (!desc) { + desc = { + value: null + }; + descriptors.push(desc); + if (!item.ownPass) nameMap.set(item.name, desc); + } + + if (item.options === false) { + desc.value = null; + } else { + desc.value = item; + } + } else { + descriptors.push({ + value: item + }); + } + } + + return descriptors.reduce((acc, desc) => { + if (desc.value) acc.push(desc.value); + return acc; + }, []); +} + +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`); + } + + const ctx = context; + const patterns = Array.isArray(test) ? test : [test]; + return matchesPatterns(ctx, patterns, dirname, false); +} + +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`); + } + + const 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 (only) { + if (context.filename === null) { + throw new Error(`Configuration contains ignore checks, but no filename was passed to Babel`); + } + + const 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; + } + } + + return false; +} + +function matchesPatterns(context, patterns, dirname, allowNegation = true) { + const res = []; + const strings = []; + const fns = []; + patterns.forEach(pattern => { + if (typeof pattern === "string") strings.push(pattern);else if (typeof pattern === "function") fns.push(pattern);else res.push(pattern); + }); + const filename = context.filename; + if (res.some(re => re.test(context.filename))) return true; + if (fns.some(fn => fn(filename))) return true; + + if (strings.length > 0) { + const possibleDirs = getPossibleDirs(context); + const absolutePatterns = strings.map(pattern => { + const 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); + }); + + if ((0, _micromatch().default)(possibleDirs, absolutePatterns, { + nocase: true, + nonegate: !allowNegation + }).length > 0) { + return true; + } + } + + return false; +} + +const getPossibleDirs = (0, _caching.makeWeakCache)(context => { + let current = context.filename; + if (current === null) return []; + const possibleDirs = [current]; + + while (true) { + const previous = current; + current = _path().default.dirname(current); + if (previous === current) break; + possibleDirs.push(current); + } + + return possibleDirs; +});
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/config-descriptors.js b/node_modules/@babel/core/lib/config/config-descriptors.js new file mode 100644 index 00000000..c4373f8b --- /dev/null +++ b/node_modules/@babel/core/lib/config/config-descriptors.js @@ -0,0 +1,206 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createCachedDescriptors = createCachedDescriptors; +exports.createUncachedDescriptors = createUncachedDescriptors; +exports.createDescriptor = createDescriptor; + +var _files = require("./files"); + +var _item = require("./item"); + +var _caching = require("./caching"); + +function createCachedDescriptors(dirname, options, alias) { + const plugins = options.plugins, + presets = options.presets, + passPerPreset = options.passPerPreset; + return { + options, + plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => [], + presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => [] + }; +} + +function createUncachedDescriptors(dirname, options, alias) { + let plugins; + let presets; + return { + options, + plugins: function (_plugins) { + function plugins() { + return _plugins.apply(this, arguments); + } + + plugins.toString = function () { + return _plugins.toString(); + }; + + return 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; + }(() => { + if (!presets) { + presets = createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset); + } + + return presets; + }) + }; +} + +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))); +}); +const createCachedPluginDescriptors = (0, _caching.makeWeakCache)((items, cache) => { + const dirname = cache.using(dir => dir); + return (0, _caching.makeStrongCache)(alias => createPluginDescriptors(items, dirname, alias)); +}); + +function createPresetDescriptors(items, dirname, alias, passPerPreset) { + return createDescriptors("preset", items, dirname, alias, passPerPreset); +} + +function createPluginDescriptors(items, dirname, alias) { + return createDescriptors("plugin", items, dirname, alias); +} + +function createDescriptors(type, items, dirname, alias, ownPass) { + const descriptors = items.map((item, index) => createDescriptor(item, dirname, { + type, + alias: `${alias}$${index}`, + ownPass: !!ownPass + })); + assertNoDuplicates(descriptors); + return descriptors; +} + +function createDescriptor(pair, dirname, { + type, + alias, + ownPass +}) { + const desc = (0, _item.getItemDescriptor)(pair); + + if (desc) { + return desc; + } + + 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]; + } else { + var _value2 = value; + value = _value2[0]; + options = _value2[1]; + } + } + + 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"); + } + + const resolver = type === "plugin" ? _files.loadPlugin : _files.loadPreset; + const request = value; + + var _resolver = resolver(value, dirname); + + filepath = _resolver.filepath; + value = _resolver.value; + file = { + request, + resolved: filepath + }; + } + + if (!value) { + throw new Error(`Unexpected falsy value: ${String(value)}`); + } + + if (typeof value === "object" && value.__esModule) { + if (value.default) { + value = value.default; + } else { + throw new Error("Must export a default export when using ES6 modules."); + } + } + + if (typeof value !== "object" && typeof value !== "function") { + throw new Error(`Unsupported format: ${typeof value}. Expected an object or a function.`); + } + + if (filepath !== null && typeof value === "object" && value) { + throw new Error(`Plugin/Preset files are not allowed to export objects, only functions. In ${filepath}`); + } + + return { + name, + alias: filepath || alias, + value, + options, + dirname, + ownPass, + file + }; +} + +function assertNoDuplicates(items) { + const map = new Map(); + + for (var _iterator = items, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const item = _ref; + if (typeof item.value !== "function") continue; + let nameMap = map.get(item.value); + + if (!nameMap) { + nameMap = new Set(); + map.set(item.value, nameMap); + } + + 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")); + } + + nameMap.add(item.name); + } +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/configuration.js b/node_modules/@babel/core/lib/config/files/configuration.js new file mode 100644 index 00000000..e0667159 --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/configuration.js @@ -0,0 +1,306 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.findRelativeConfig = findRelativeConfig; +exports.findRootConfig = findRootConfig; +exports.loadConfig = loadConfig; + +function _debug() { + const data = _interopRequireDefault(require("debug")); + + _debug = function _debug() { + return data; + }; + + return data; +} + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +function _fs() { + const data = _interopRequireDefault(require("fs")); + + _fs = function _fs() { + return data; + }; + + return data; +} + +function _json() { + const data = _interopRequireDefault(require("json5")); + + _json = function _json() { + return data; + }; + + return data; +} + +function _resolve() { + const data = _interopRequireDefault(require("resolve")); + + _resolve = function _resolve() { + return data; + }; + + return data; +} + +var _caching = require("../caching"); + +var _configApi = _interopRequireDefault(require("../helpers/config-api")); + +var _utils = require("./utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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) { + let config = null; + let ignore = null; + + const dirname = _path().default.dirname(packageData.filepath); + + for (var _iterator = packageData.directories, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const loc = _ref; + + if (!config) { + config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce((previousConfig, name) => { + const filepath = _path().default.join(loc, name); + + const config = readConfig(filepath, envName); + + if (config && previousConfig) { + 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); + 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}`); + } + + config = pkgConfig; + } + + if (config) { + debug("Found configuration %o from %o.", config.filepath, dirname); + } + } + + if (!ignore) { + const ignoreLoc = _path().default.join(loc, BABELIGNORE_FILENAME); + + ignore = readIgnoreConfig(ignoreLoc); + + if (ignore) { + debug("Found ignore %o from %o.", ignore.filepath, dirname); + } + } + } + + return { + config, + ignore + }; +} + +function findRootConfig(dirname, envName) { + const filepath = _path().default.resolve(dirname, BABEL_CONFIG_JS_FILENAME); + + const conf = readConfig(filepath, envName); + + if (conf) { + debug("Found root config %o in $o.", BABEL_CONFIG_JS_FILENAME, dirname); + } + + return conf; +} + +function loadConfig(name, dirname, envName) { + const filepath = _resolve().default.sync(name, { + basedir: dirname + }); + + const conf = readConfig(filepath, envName); + + if (!conf) { + throw new Error(`Config file ${filepath} contains no configuration data`); + } + + debug("Loaded config %o from $o.", name, dirname); + return conf; +} + +function readConfig(filepath, envName) { + return _path().default.extname(filepath) === ".js" ? readConfigJS(filepath, { + envName + }) : readConfigJSON5(filepath); +} + +const LOADING_CONFIGS = new Set(); +const readConfigJS = (0, _caching.makeStrongCache)((filepath, cache) => { + if (!_fs().default.existsSync(filepath)) { + cache.forever(); + return null; + } + + if (LOADING_CONFIGS.has(filepath)) { + cache.never(); + debug("Auto-ignoring usage of config %o.", filepath); + return { + filepath, + dirname: _path().default.dirname(filepath), + options: {} + }; + } + + let options; + + try { + LOADING_CONFIGS.add(filepath); + + const configModule = require(filepath); + + options = configModule && configModule.__esModule ? configModule.default || undefined : configModule; + } catch (err) { + err.message = `${filepath}: Error while loading config - ${err.message}`; + throw err; + } finally { + LOADING_CONFIGS.delete(filepath); + } + + if (typeof options === "function") { + options = options((0, _configApi.default)(cache)); + if (!cache.configured()) throwConfigError(); + } + + if (!options || typeof options !== "object" || Array.isArray(options)) { + throw new Error(`${filepath}: Configuration should be an exported JavaScript object.`); + } + + if (typeof options.then === "function") { + throw new Error(`You appear to be using an async configuration, ` + `which your current version of Babel does not support. ` + `We may add support for this in the future, ` + `but if you're on the most recent version of @babel/core and still ` + `seeing this error, then you'll need to synchronously return your config.`); + } + + return { + filepath, + dirname: _path().default.dirname(filepath), + options + }; +}); +const packageToBabelConfig = (0, _caching.makeWeakCache)(file => { + if (typeof file.options.babel === "undefined") return null; + const babel = file.options.babel; + + if (typeof babel !== "object" || Array.isArray(babel) || babel === null) { + throw new Error(`${file.filepath}: .babel property must be an object`); + } + + return { + filepath: file.filepath, + dirname: file.dirname, + options: babel + }; +}); +const readConfigJSON5 = (0, _utils.makeStaticFileCache)((filepath, content) => { + let options; + + try { + options = _json().default.parse(content); + } catch (err) { + err.message = `${filepath}: Error while parsing config - ${err.message}`; + throw err; + } + + if (!options) throw new Error(`${filepath}: No config detected`); + + if (typeof options !== "object") { + throw new Error(`${filepath}: Config returned typeof ${typeof options}`); + } + + if (Array.isArray(options)) { + throw new Error(`${filepath}: Expected config object but found array`); + } + + return { + filepath, + dirname: _path().default.dirname(filepath), + options + }; +}); +const readIgnoreConfig = (0, _utils.makeStaticFileCache)((filepath, content) => { + const ignore = content.split("\n").map(line => line.replace(/#(.*?)$/, "").trim()).filter(line => !!line); + return { + filepath, + dirname: _path().default.dirname(filepath), + ignore + }; +}); + +function throwConfigError() { + 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 { }; +};`); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/index-browser.js b/node_modules/@babel/core/lib/config/files/index-browser.js new file mode 100644 index 00000000..4f0174ee --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/index-browser.js @@ -0,0 +1,54 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.findPackageData = findPackageData; +exports.findRelativeConfig = findRelativeConfig; +exports.findRootConfig = findRootConfig; +exports.loadConfig = loadConfig; +exports.resolvePlugin = resolvePlugin; +exports.resolvePreset = resolvePreset; +exports.loadPlugin = loadPlugin; +exports.loadPreset = loadPreset; + +function findPackageData(filepath) { + return { + filepath, + directories: [], + pkg: null, + isPackage: false + }; +} + +function findRelativeConfig(pkgData, envName) { + return { + pkg: null, + config: null, + ignore: null + }; +} + +function findRootConfig(dirname, envName) { + return null; +} + +function loadConfig(name, dirname, envName) { + throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`); +} + +function resolvePlugin(name, dirname) { + return null; +} + +function resolvePreset(name, dirname) { + return null; +} + +function loadPlugin(name, dirname) { + throw new Error(`Cannot load plugin ${name} relative to ${dirname} in a browser`); +} + +function loadPreset(name, dirname) { + throw new Error(`Cannot load preset ${name} relative to ${dirname} in a browser`); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/index.js b/node_modules/@babel/core/lib/config/files/index.js new file mode 100644 index 00000000..25c3008b --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/index.js @@ -0,0 +1,61 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "findPackageData", { + enumerable: true, + get: function get() { + return _package.findPackageData; + } +}); +Object.defineProperty(exports, "findRelativeConfig", { + enumerable: true, + get: function get() { + return _configuration.findRelativeConfig; + } +}); +Object.defineProperty(exports, "findRootConfig", { + enumerable: true, + get: function get() { + return _configuration.findRootConfig; + } +}); +Object.defineProperty(exports, "loadConfig", { + enumerable: true, + get: function get() { + return _configuration.loadConfig; + } +}); +Object.defineProperty(exports, "resolvePlugin", { + enumerable: true, + get: function get() { + return _plugins.resolvePlugin; + } +}); +Object.defineProperty(exports, "resolvePreset", { + enumerable: true, + get: function get() { + return _plugins.resolvePreset; + } +}); +Object.defineProperty(exports, "loadPlugin", { + enumerable: true, + get: function get() { + return _plugins.loadPlugin; + } +}); +Object.defineProperty(exports, "loadPreset", { + enumerable: true, + get: function get() { + return _plugins.loadPreset; + } +}); + +var _package = require("./package"); + +var _configuration = require("./configuration"); + +var _plugins = require("./plugins"); + +({});
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/package.js b/node_modules/@babel/core/lib/config/files/package.js new file mode 100644 index 00000000..4557b8ab --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/package.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.findPackageData = findPackageData; + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +var _utils = require("./utils"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const PACKAGE_FILENAME = "package.json"; + +function findPackageData(filepath) { + let pkg = null; + const directories = []; + let isPackage = true; + + 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)); + + const nextLoc = _path().default.dirname(dirname); + + if (dirname === nextLoc) { + isPackage = false; + break; + } + + dirname = nextLoc; + } + + return { + filepath, + directories, + pkg, + isPackage + }; +} + +const readConfigPackage = (0, _utils.makeStaticFileCache)((filepath, content) => { + let options; + + try { + options = JSON.parse(content); + } catch (err) { + err.message = `${filepath}: Error while parsing JSON - ${err.message}`; + throw err; + } + + if (typeof options !== "object") { + throw new Error(`${filepath}: Config returned typeof ${typeof options}`); + } + + if (Array.isArray(options)) { + throw new Error(`${filepath}: Expected config object but found array`); + } + + return { + filepath, + dirname: _path().default.dirname(filepath), + options + }; +});
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/plugins.js b/node_modules/@babel/core/lib/config/files/plugins.js new file mode 100644 index 00000000..e771dbe6 --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/plugins.js @@ -0,0 +1,168 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.resolvePlugin = resolvePlugin; +exports.resolvePreset = resolvePreset; +exports.loadPlugin = loadPlugin; +exports.loadPreset = loadPreset; + +function _debug() { + const data = _interopRequireDefault(require("debug")); + + _debug = function _debug() { + return data; + }; + + return data; +} + +function _resolve() { + const data = _interopRequireDefault(require("resolve")); + + _resolve = function _resolve() { + return data; + }; + + return data; +} + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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-|[^/]+\/)/; + +function resolvePlugin(name, dirname) { + return resolveStandardizedName("plugin", name, dirname); +} + +function resolvePreset(name, dirname) { + return resolveStandardizedName("preset", name, dirname); +} + +function loadPlugin(name, dirname) { + const filepath = resolvePlugin(name, dirname); + + if (!filepath) { + throw new Error(`Plugin ${name} not found relative to ${dirname}`); + } + + const value = requireModule("plugin", filepath); + debug("Loaded plugin %o from %o.", name, dirname); + return { + filepath, + value + }; +} + +function loadPreset(name, dirname) { + const filepath = resolvePreset(name, dirname); + + if (!filepath) { + throw new Error(`Preset ${name} not found relative to ${dirname}`); + } + + const value = requireModule("preset", filepath); + debug("Loaded preset %o from %o.", name, dirname); + return { + filepath, + value + }; +} + +function standardizeName(type, name) { + if (_path().default.isAbsolute(name)) return name; + const isPreset = type === "preset"; + return name.replace(isPreset ? BABEL_PRESET_PREFIX_RE : BABEL_PLUGIN_PREFIX_RE, `babel-${type}-`).replace(isPreset ? BABEL_PRESET_ORG_RE : BABEL_PLUGIN_ORG_RE, `$1${type}-`).replace(isPreset ? OTHER_PRESET_ORG_RE : OTHER_PLUGIN_ORG_RE, `$1babel-${type}-`).replace(EXACT_RE, ""); +} + +function resolveStandardizedName(type, name, dirname = process.cwd()) { + const standardizedName = standardizeName(type, name); + + try { + return _resolve().default.sync(standardizedName, { + basedir: dirname + }); + } catch (e) { + if (e.code !== "MODULE_NOT_FOUND") throw e; + + if (standardizedName !== name) { + let resolvedOriginal = false; + + try { + _resolve().default.sync(name, { + basedir: dirname + }); + + resolvedOriginal = true; + } catch (e2) {} + + if (resolvedOriginal) { + e.message += `\n- If you want to resolve "${name}", use "module:${name}"`; + } + } + + let resolvedBabel = false; + + try { + _resolve().default.sync(standardizeName(type, "@babel/" + name), { + basedir: dirname + }); + + resolvedBabel = true; + } catch (e2) {} + + if (resolvedBabel) { + e.message += `\n- Did you mean "@babel/${name}"?`; + } + + let resolvedOppositeType = false; + const oppositeType = type === "preset" ? "plugin" : "preset"; + + try { + _resolve().default.sync(standardizeName(oppositeType, name), { + basedir: dirname + }); + + resolvedOppositeType = true; + } catch (e2) {} + + if (resolvedOppositeType) { + e.message += `\n- Did you accidentally pass a ${type} as a ${oppositeType}?`; + } + + throw e; + } +} + +const LOADING_MODULES = new Set(); + +function requireModule(type, name) { + if (LOADING_MODULES.has(name)) { + throw new Error(`Reentrant ${type} detected trying to load "${name}". This module is not ignored ` + "and is trying to load itself while compiling itself, leading to a dependency cycle. " + 'We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.'); + } + + try { + LOADING_MODULES.add(name); + return require(name); + } finally { + LOADING_MODULES.delete(name); + } +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/types.js b/node_modules/@babel/core/lib/config/files/types.js new file mode 100644 index 00000000..9a390c31 --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/types.js @@ -0,0 +1 @@ +"use strict";
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/files/utils.js b/node_modules/@babel/core/lib/config/files/utils.js new file mode 100644 index 00000000..9314e2dc --- /dev/null +++ b/node_modules/@babel/core/lib/config/files/utils.js @@ -0,0 +1,41 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.makeStaticFileCache = makeStaticFileCache; + +function _fs() { + const data = _interopRequireDefault(require("fs")); + + _fs = function _fs() { + return data; + }; + + return data; +} + +var _caching = require("../caching"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function makeStaticFileCache(fn) { + return (0, _caching.makeStrongCache)((filepath, cache) => { + if (cache.invalidate(() => fileMtime(filepath)) === null) { + cache.forever(); + return null; + } + + return fn(filepath, _fs().default.readFileSync(filepath, "utf8")); + }); +} + +function fileMtime(filepath) { + try { + return +_fs().default.statSync(filepath).mtime; + } catch (e) { + if (e.code !== "ENOENT" && e.code !== "ENOTDIR") throw e; + } + + return null; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/full.js b/node_modules/@babel/core/lib/config/full.js new file mode 100644 index 00000000..e2875cdf --- /dev/null +++ b/node_modules/@babel/core/lib/config/full.js @@ -0,0 +1,268 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = loadFullConfig; + +var _util = require("./util"); + +var context = _interopRequireWildcard(require("../index")); + +var _plugin = _interopRequireDefault(require("./plugin")); + +var _item = require("./item"); + +var _configChain = require("./config-chain"); + +function _traverse() { + const data = _interopRequireDefault(require("@babel/traverse")); + + _traverse = function _traverse() { + return data; + }; + + return data; +} + +var _caching = require("./caching"); + +var _options = require("./validation/options"); + +var _plugins = require("./validation/plugins"); + +var _configApi = _interopRequireDefault(require("./helpers/config-api")); + +var _partial = _interopRequireDefault(require("./partial")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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) { + const result = (0, _partial.default)(inputOpts); + + if (!result) { + return null; + } + + const options = result.options, + context = result.context; + const optionDefaults = {}; + const passes = [[]]; + + try { + const plugins = options.plugins, + presets = options.presets; + + if (!plugins || !presets) { + throw new Error("Assertion failure - plugins and presets exist"); + } + + const ignored = function recurseDescriptors(config, pass) { + const plugins = config.plugins.map(descriptor => { + return loadPluginDescriptor(descriptor, context); + }); + const presets = config.presets.map(descriptor => { + return { + preset: loadPresetDescriptor(descriptor, context), + pass: descriptor.ownPass ? [] : pass + }; + }); + + if (presets.length > 0) { + 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; + } + + const _ref = _ref2; + const preset = _ref.preset, + pass = _ref.pass; + if (!preset) return true; + const ignored = recurseDescriptors({ + plugins: preset.plugins, + presets: preset.presets + }, pass); + if (ignored) return true; + preset.options.forEach(opts => { + (0, _util.mergeOptions)(optionDefaults, opts); + }); + } + } + + if (plugins.length > 0) { + pass.unshift(...plugins); + } + }({ + plugins: plugins.map(item => { + const desc = (0, _item.getItemDescriptor)(item); + + if (!desc) { + throw new Error("Assertion failure - must be config item"); + } + + return desc; + }), + presets: presets.map(item => { + const desc = (0, _item.getItemDescriptor)(item); + + if (!desc) { + throw new Error("Assertion failure - must be config item"); + } + + return desc; + }) + }, passes[0]); + + if (ignored) return null; + } catch (e) { + if (!/^\[BABEL\]/.test(e.message)) { + e.message = `[BABEL] ${context.filename || "unknown"}: ${e.message}`; + } + + throw e; + } + + const opts = optionDefaults; + (0, _util.mergeOptions)(opts, options); + opts.plugins = passes[0]; + opts.presets = passes.slice(1).filter(plugins => plugins.length > 0).map(plugins => ({ + plugins + })); + opts.passPerPreset = opts.presets.length > 0; + return { + options: opts, + passes: passes + }; +} + +const loadDescriptor = (0, _caching.makeWeakCache)(({ + value, + options, + dirname, + alias +}, cache) => { + if (options === false) throw new Error("Assertion failure"); + options = options || {}; + let item = value; + + if (typeof value === "function") { + 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)})`; + } + + throw e; + } + } + + if (!item || typeof item !== "object") { + throw new Error("Plugin/Preset did not return an object."); + } + + 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.`); + } + + return { + value: item, + options, + dirname, + alias + }; +}); + +function loadPluginDescriptor(descriptor, context) { + if (descriptor.value instanceof _plugin.default) { + if (descriptor.options) { + throw new Error("Passed options to an existing Plugin instance will not work."); + } + + return descriptor.value; + } + + return instantiatePlugin(loadDescriptor(descriptor, context), context); +} + +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) { + const inheritsDescriptor = { + name: undefined, + alias: `${alias}$inherits`, + value: plugin.inherits, + options, + dirname + }; + 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); + plugin.visitor = _traverse().default.visitors.merge([inherits.visitor || {}, plugin.visitor || {}]); + } + + return new _plugin.default(plugin, options, alias); +}); + +const loadPresetDescriptor = (descriptor, context) => { + return (0, _configChain.buildPresetChain)(instantiatePreset(loadDescriptor(descriptor, context)), context); +}; + +const instantiatePreset = (0, _caching.makeWeakCache)(({ + value, + dirname, + alias +}) => { + return { + options: (0, _options.validate)("preset", value), + alias, + dirname + }; +}); + +function chain(a, b) { + const fns = [a, b].filter(Boolean); + if (fns.length <= 1) return fns[0]; + return function (...args) { + for (var _iterator2 = fns, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + const fn = _ref3; + fn.apply(this, args); + } + }; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/helpers/config-api.js b/node_modules/@babel/core/lib/config/helpers/config-api.js new file mode 100644 index 00000000..78080a80 --- /dev/null +++ b/node_modules/@babel/core/lib/config/helpers/config-api.js @@ -0,0 +1,76 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = makeAPI; + +function _semver() { + const data = _interopRequireDefault(require("semver")); + + _semver = function _semver() { + return data; + }; + + return data; +} + +var _ = require("../../"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function makeAPI(cache) { + const env = value => cache.using(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(entry => { + if (typeof entry !== "string") { + throw new Error("Unexpected non-string value"); + } + + return entry === data.envName; + }); + }); + + return { + version: _.version, + cache: cache.simple(), + env, + async: () => false, + assertVersion + }; +} + +function assertVersion(range) { + if (typeof range === "number") { + if (!Number.isInteger(range)) { + throw new Error("Expected string or integer value."); + } + + range = `^${range}.0.0-0`; + } + + if (typeof range !== "string") { + throw new Error("Expected string or integer value."); + } + + if (_semver().default.satisfies(_.version, range)) return; + const limit = Error.stackTraceLimit; + + if (typeof limit === "number" && limit < 25) { + Error.stackTraceLimit = 25; + } + + const err = new Error(`Requires Babel "${range}", but was loaded with "${_.version}". ` + `If you are sure you have a compatible version of @babel/core, ` + `it is likely that something in your build process is loading the ` + `wrong version. Inspect the stack trace of this error to look for ` + `the first entry that doesn't mention "@babel/core" or "babel-core" ` + `to see what is calling Babel.`); + + if (typeof limit === "number") { + Error.stackTraceLimit = limit; + } + + throw Object.assign(err, { + code: "BABEL_VERSION_UNSUPPORTED", + version: _.version, + range + }); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/helpers/environment.js b/node_modules/@babel/core/lib/config/helpers/environment.js new file mode 100644 index 00000000..e4bfdbc7 --- /dev/null +++ b/node_modules/@babel/core/lib/config/helpers/environment.js @@ -0,0 +1,10 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getEnv = getEnv; + +function getEnv(defaultValue = "development") { + return process.env.BABEL_ENV || process.env.NODE_ENV || defaultValue; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/index.js b/node_modules/@babel/core/lib/config/index.js new file mode 100644 index 00000000..829a7952 --- /dev/null +++ b/node_modules/@babel/core/lib/config/index.js @@ -0,0 +1,39 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.loadOptions = loadOptions; +Object.defineProperty(exports, "default", { + enumerable: true, + get: function get() { + return _full.default; + } +}); +Object.defineProperty(exports, "loadPartialConfig", { + enumerable: true, + get: function get() { + return _partial.loadPartialConfig; + } +}); +exports.OptionManager = void 0; + +var _full = _interopRequireDefault(require("./full")); + +var _partial = require("./partial"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function loadOptions(opts) { + const config = (0, _full.default)(opts); + return config ? config.options : null; +} + +class OptionManager { + init(opts) { + return loadOptions(opts); + } + +} + +exports.OptionManager = OptionManager;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/item.js b/node_modules/@babel/core/lib/config/item.js new file mode 100644 index 00000000..3f2d5e69 --- /dev/null +++ b/node_modules/@babel/core/lib/config/item.js @@ -0,0 +1,71 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.createItemFromDescriptor = createItemFromDescriptor; +exports.createConfigItem = createConfigItem; +exports.getItemDescriptor = getItemDescriptor; + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +var _configDescriptors = require("./config-descriptors"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function createItemFromDescriptor(desc) { + return new ConfigItem(desc); +} + +function createConfigItem(value, { + dirname = ".", + type +} = {}) { + const descriptor = (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), { + type, + alias: "programmatic item" + }); + return createItemFromDescriptor(descriptor); +} + +function getItemDescriptor(item) { + if (item instanceof ConfigItem) { + return item._descriptor; + } + + return undefined; +} + +class ConfigItem { + constructor(descriptor) { + this._descriptor = descriptor; + Object.defineProperty(this, "_descriptor", { + enumerable: false + }); + + if (this._descriptor.options === false) { + throw new Error("Assertion failure - unexpected false options"); + } + + 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);
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/partial.js b/node_modules/@babel/core/lib/config/partial.js new file mode 100644 index 00000000..8b8937ed --- /dev/null +++ b/node_modules/@babel/core/lib/config/partial.js @@ -0,0 +1,103 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = loadPrivatePartialConfig; +exports.loadPartialConfig = loadPartialConfig; + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +var _plugin = _interopRequireDefault(require("./plugin")); + +var _util = require("./util"); + +var _item = require("./item"); + +var _configChain = require("./config-chain"); + +var _environment = require("./helpers/environment"); + +var _options = require("./validation/options"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function loadPrivatePartialConfig(inputOpts) { + if (inputOpts != null && (typeof inputOpts !== "object" || Array.isArray(inputOpts))) { + throw new Error("Babel options must be an object, null, or undefined"); + } + + const args = inputOpts ? (0, _options.validate)("arguments", inputOpts) : {}; + const _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 absoluteCwd = _path().default.resolve(cwd); + + const context = { + filename: args.filename ? _path().default.resolve(cwd, args.filename) : null, + cwd: absoluteCwd, + envName + }; + const configChain = (0, _configChain.buildRootChain)(args, context); + if (!configChain) return null; + const options = {}; + configChain.options.forEach(opts => { + (0, _util.mergeOptions)(options, opts); + }); + options.babelrc = false; + options.configFile = false; + options.envName = envName; + options.cwd = absoluteCwd; + options.passPerPreset = false; + options.plugins = configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)); + options.presets = configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)); + return { + options, + context, + ignore: configChain.ignore, + babelrc: configChain.babelrc, + config: configChain.config + }; +} + +function loadPartialConfig(inputOpts) { + const result = loadPrivatePartialConfig(inputOpts); + if (!result) return null; + const options = result.options, + babelrc = result.babelrc, + ignore = result.ignore, + config = result.config; + (options.plugins || []).forEach(item => { + if (item.value instanceof _plugin.default) { + throw new Error("Passing cached plugin instances is not supported in " + "babel.loadPartialConfig()"); + } + }); + return new PartialConfig(options, babelrc ? babelrc.filepath : undefined, ignore ? ignore.filepath : undefined, config ? config.filepath : undefined); +} + +class PartialConfig { + constructor(options, babelrc, ignore, config) { + this.options = options; + this.babelignore = ignore; + this.babelrc = babelrc; + this.config = config; + Object.freeze(this); + } + + hasFilesystemConfig() { + return this.babelrc !== undefined || this.config !== undefined; + } + +} + +Object.freeze(PartialConfig.prototype);
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/plugin.js b/node_modules/@babel/core/lib/config/plugin.js new file mode 100644 index 00000000..3c780708 --- /dev/null +++ b/node_modules/@babel/core/lib/config/plugin.js @@ -0,0 +1,22 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +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;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/util.js b/node_modules/@babel/core/lib/config/util.js new file mode 100644 index 00000000..96de62c1 --- /dev/null +++ b/node_modules/@babel/core/lib/config/util.js @@ -0,0 +1,37 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.mergeOptions = mergeOptions; + +function mergeOptions(target, source) { + var _arr = Object.keys(source); + + for (var _i = 0; _i < _arr.length; _i++) { + const k = _arr[_i]; + + if (k === "parserOpts" && source.parserOpts) { + const parserOpts = source.parserOpts; + const targetObj = target.parserOpts = target.parserOpts || {}; + mergeDefaultFields(targetObj, parserOpts); + } else if (k === "generatorOpts" && source.generatorOpts) { + const generatorOpts = source.generatorOpts; + const targetObj = target.generatorOpts = target.generatorOpts || {}; + mergeDefaultFields(targetObj, generatorOpts); + } else { + 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++) { + const k = _arr2[_i2]; + const val = source[k]; + if (val !== undefined) target[k] = val; + } +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/validation/option-assertions.js b/node_modules/@babel/core/lib/config/validation/option-assertions.js new file mode 100644 index 00000000..4aa57c37 --- /dev/null +++ b/node_modules/@babel/core/lib/config/validation/option-assertions.js @@ -0,0 +1,205 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.assertSourceMaps = assertSourceMaps; +exports.assertCompact = assertCompact; +exports.assertSourceType = assertSourceType; +exports.assertInputSourceMap = assertInputSourceMap; +exports.assertString = assertString; +exports.assertFunction = assertFunction; +exports.assertBoolean = assertBoolean; +exports.assertObject = assertObject; +exports.assertArray = assertArray; +exports.assertIgnoreList = assertIgnoreList; +exports.assertConfigApplicableTest = assertConfigApplicableTest; +exports.assertConfigFileSearch = assertConfigFileSearch; +exports.assertBabelrcSearch = assertBabelrcSearch; +exports.assertPluginList = assertPluginList; + +function assertSourceMaps(key, value) { + if (value !== undefined && typeof value !== "boolean" && value !== "inline" && value !== "both") { + throw new Error(`.${key} must be a boolean, "inline", "both", or undefined`); + } + + return value; +} + +function assertCompact(key, value) { + if (value !== undefined && typeof value !== "boolean" && value !== "auto") { + throw new Error(`.${key} must be a boolean, "auto", or undefined`); + } + + return value; +} + +function assertSourceType(key, value) { + if (value !== undefined && value !== "module" && value !== "script" && value !== "unambiguous") { + throw new Error(`.${key} must be "module", "script", "unambiguous", or undefined`); + } + + return value; +} + +function assertInputSourceMap(key, value) { + if (value !== undefined && typeof value !== "boolean" && (typeof value !== "object" || !value)) { + throw new Error(".inputSourceMap must be a boolean, object, or undefined"); + } + + return value; +} + +function assertString(key, value) { + if (value !== undefined && typeof value !== "string") { + throw new Error(`.${key} must be a string, or undefined`); + } + + return value; +} + +function assertFunction(key, value) { + if (value !== undefined && typeof value !== "function") { + throw new Error(`.${key} must be a function, or undefined`); + } + + return value; +} + +function assertBoolean(key, value) { + if (value !== undefined && typeof value !== "boolean") { + throw new Error(`.${key} must be a boolean, or undefined`); + } + + return value; +} + +function assertObject(key, value) { + if (value !== undefined && (typeof value !== "object" || Array.isArray(value) || !value)) { + throw new Error(`.${key} must be an object, or undefined`); + } + + return value; +} + +function assertArray(key, value) { + if (value != null && !Array.isArray(value)) { + throw new Error(`.${key} must be an array, or undefined`); + } + + return value; +} + +function assertIgnoreList(key, value) { + const arr = assertArray(key, value); + + if (arr) { + arr.forEach((item, i) => assertIgnoreItem(key, i, item)); + } + + return arr; +} + +function assertIgnoreItem(key, index, 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`); + } + + return value; +} + +function assertConfigApplicableTest(key, value) { + if (value === undefined) return value; + + if (Array.isArray(value)) { + value.forEach((item, i) => { + if (!checkValidTest(item)) { + throw new Error(`.${key}[${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`); + } + + return value; +} + +function checkValidTest(value) { + return typeof value === "string" || typeof value === "function" || value instanceof RegExp; +} + +function assertConfigFileSearch(key, 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)}`); + } + + return value; +} + +function assertBabelrcSearch(key, value) { + if (value === undefined || typeof value === "boolean") return value; + + if (Array.isArray(value)) { + value.forEach((item, i) => { + if (typeof item !== "string") { + throw new Error(`.${key}[${i}] must be a string.`); + } + }); + } 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)}`); + } + + return value; +} + +function assertPluginList(key, value) { + const arr = assertArray(key, value); + + if (arr) { + arr.forEach((item, i) => assertPluginItem(key, i, item)); + } + + return arr; +} + +function assertPluginItem(key, index, value) { + if (Array.isArray(value)) { + if (value.length === 0) { + throw new Error(`.${key}[${index}] must include an object`); + } + + if (value.length > 3) { + throw new Error(`.${key}[${index}] may only be a two-tuple or three-tuple`); + } + + assertPluginTarget(key, index, true, value[0]); + + if (value.length > 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`); + } + } + + if (value.length === 3) { + const name = value[2]; + + if (name !== undefined && typeof name !== "string") { + throw new Error(`.${key}[${index}][2] must be a string, or undefined`); + } + } + } else { + assertPluginTarget(key, index, false, value); + } + + return value; +} + +function assertPluginTarget(key, index, inArray, 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`); + } + + return value; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/validation/options.js b/node_modules/@babel/core/lib/config/validation/options.js new file mode 100644 index 00000000..b427b693 --- /dev/null +++ b/node_modules/@babel/core/lib/config/validation/options.js @@ -0,0 +1,169 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validate = validate; + +var _plugin = _interopRequireDefault(require("../plugin")); + +var _removed = _interopRequireDefault(require("./removed")); + +var _optionAssertions = require("./option-assertions"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +const ROOT_VALIDATORS = { + cwd: _optionAssertions.assertString, + root: _optionAssertions.assertString, + configFile: _optionAssertions.assertConfigFileSearch, + filename: _optionAssertions.assertString, + filenameRelative: _optionAssertions.assertString, + code: _optionAssertions.assertBoolean, + ast: _optionAssertions.assertBoolean, + envName: _optionAssertions.assertString +}; +const BABELRC_VALIDATORS = { + babelrc: _optionAssertions.assertBoolean, + babelrcRoots: _optionAssertions.assertBabelrcSearch +}; +const 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 COMMON_VALIDATORS = { + inputSourceMap: _optionAssertions.assertInputSourceMap, + presets: _optionAssertions.assertPluginList, + plugins: _optionAssertions.assertPluginList, + passPerPreset: _optionAssertions.assertBoolean, + retainLines: _optionAssertions.assertBoolean, + comments: _optionAssertions.assertBoolean, + shouldPrintComment: _optionAssertions.assertFunction, + compact: _optionAssertions.assertCompact, + minified: _optionAssertions.assertBoolean, + auxiliaryCommentBefore: _optionAssertions.assertString, + auxiliaryCommentAfter: _optionAssertions.assertString, + sourceType: _optionAssertions.assertSourceType, + wrapPluginVisitorMethod: _optionAssertions.assertFunction, + highlightCode: _optionAssertions.assertBoolean, + sourceMaps: _optionAssertions.assertSourceMaps, + sourceMap: _optionAssertions.assertSourceMaps, + sourceFileName: _optionAssertions.assertString, + sourceRoot: _optionAssertions.assertString, + getModuleId: _optionAssertions.assertFunction, + moduleRoot: _optionAssertions.assertString, + moduleIds: _optionAssertions.assertBoolean, + moduleId: _optionAssertions.assertString, + parserOpts: _optionAssertions.assertObject, + generatorOpts: _optionAssertions.assertObject +}; + +function validate(type, opts) { + assertNoDuplicateSourcemap(opts); + Object.keys(opts).forEach(key => { + if (type === "preset" && NONPRESET_VALIDATORS[key]) { + throw new Error(`.${key} is not allowed in preset options`); + } + + if (type !== "arguments" && ROOT_VALIDATORS[key]) { + throw new Error(`.${key} is only allowed in root programmatic options`); + } + + if (type !== "arguments" && type !== "configfile" && BABELRC_VALIDATORS[key]) { + if (type === "babelrcfile" || type === "extendsfile") { + throw new Error(`.${key} is not allowed in .babelrc or "extend"ed files, only in root programmatic options, ` + `or babel.config.js/config file options`); + } + + throw new Error(`.${key} is only allowed in root programmatic options, or babel.config.js/config file options`); + } + + if (type === "env" && key === "env") { + throw new Error(`.${key} is not allowed inside another env block`); + } + + 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`); + } + + const validator = COMMON_VALIDATORS[key] || NONPRESET_VALIDATORS[key] || BABELRC_VALIDATORS[key] || ROOT_VALIDATORS[key]; + if (validator) validator(key, opts[key]);else throw buildUnknownError(key); + }); + return opts; +} + +function buildUnknownError(key) { + if (_removed.default[key]) { + const _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}`); + } else { + const unknownOptErr = `Unknown option: .${key}. Check out http://babeljs.io/docs/usage/options/ for more information about options.`; + throw new ReferenceError(unknownOptErr); + } +} + +function has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); +} + +function assertNoDuplicateSourcemap(opts) { + if (has(opts, "sourceMap") && has(opts, "sourceMaps")) { + throw new Error(".sourceMap is an alias for .sourceMaps, cannot use both"); + } +} + +function assertEnvSet(key, value) { + const obj = (0, _optionAssertions.assertObject)(key, value); + + if (obj) { + var _arr = Object.keys(obj); + + for (var _i = 0; _i < _arr.length; _i++) { + const key = _arr[_i]; + const env = (0, _optionAssertions.assertObject)(key, obj[key]); + if (env) validate("env", env); + } + } + + return obj; +} + +function assertOverridesList(key, value) { + const arr = (0, _optionAssertions.assertArray)(key, 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; + } + + const _ref2 = _ref, + index = _ref2[0], + item = _ref2[1]; + const env = (0, _optionAssertions.assertObject)(`${index}`, item); + if (!env) throw new Error(`.${key}[${index}] must be an object`); + validate("override", env); + } + } + + return arr; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/validation/plugins.js b/node_modules/@babel/core/lib/config/validation/plugins.js new file mode 100644 index 00000000..73b498cd --- /dev/null +++ b/node_modules/@babel/core/lib/config/validation/plugins.js @@ -0,0 +1,55 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.validatePluginObject = validatePluginObject; + +var _optionAssertions = require("./option-assertions"); + +const VALIDATORS = { + name: _optionAssertions.assertString, + manipulateOptions: _optionAssertions.assertFunction, + pre: _optionAssertions.assertFunction, + post: _optionAssertions.assertFunction, + inherits: _optionAssertions.assertFunction, + visitor: assertVisitorMap, + parserOverride: _optionAssertions.assertFunction, + generatorOverride: _optionAssertions.assertFunction +}; + +function assertVisitorMap(key, value) { + const obj = (0, _optionAssertions.assertObject)(key, value); + + if (obj) { + 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.`); + } + } + + return obj; +} + +function assertVisitorHandler(key, value) { + if (value && typeof value === "object") { + Object.keys(value).forEach(handler => { + if (handler !== "enter" && handler !== "exit") { + 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`); + } + + return value; +} + +function validatePluginObject(obj) { + 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; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/config/validation/removed.js b/node_modules/@babel/core/lib/config/validation/removed.js new file mode 100644 index 00000000..f0fcd7de --- /dev/null +++ b/node_modules/@babel/core/lib/config/validation/removed.js @@ -0,0 +1,66 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _default = { + auxiliaryComment: { + message: "Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`" + }, + blacklist: { + message: "Put the specific transforms you want in the `plugins` option" + }, + breakConfig: { + message: "This is not a necessary option in Babel 6" + }, + experimental: { + message: "Put the specific transforms you want in the `plugins` option" + }, + externalHelpers: { + message: "Use the `external-helpers` plugin instead. " + "Check out http://babeljs.io/docs/plugins/external-helpers/" + }, + extra: { + message: "" + }, + jsxPragma: { + message: "use the `pragma` option in the `react-jsx` plugin. " + "Check out http://babeljs.io/docs/plugins/transform-react-jsx/" + }, + loose: { + message: "Specify the `loose` option for the relevant plugin you are using " + "or use a preset that sets the option." + }, + metadataUsedHelpers: { + message: "Not required anymore as this is enabled by default" + }, + modules: { + message: "Use the corresponding module transform plugin in the `plugins` option. " + "Check out http://babeljs.io/docs/plugins/#modules" + }, + nonStandard: { + message: "Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. " + "Also check out the react preset http://babeljs.io/docs/plugins/preset-react/" + }, + optional: { + message: "Put the specific transforms you want in the `plugins` option" + }, + sourceMapName: { + message: "The `sourceMapName` option has been removed because it makes more sense for the " + "tooling that calls Babel to assign `map.file` themselves." + }, + stage: { + message: "Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets" + }, + whitelist: { + message: "Put the specific transforms you want in the `plugins` option" + }, + resolveModuleSource: { + version: 6, + message: "Use `babel-plugin-module-resolver@3`'s 'resolvePath' options" + }, + metadata: { + version: 6, + message: "Generated plugin metadata is always included in the output result" + }, + sourceMapTarget: { + version: 6, + message: "The `sourceMapTarget` option has been removed because it makes more sense for the tooling " + "that calls Babel to assign `map.file` themselves." + } +}; +exports.default = _default;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/index.js b/node_modules/@babel/core/lib/index.js new file mode 100644 index 00000000..aa2e6afc --- /dev/null +++ b/node_modules/@babel/core/lib/index.js @@ -0,0 +1,197 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Plugin = Plugin; +Object.defineProperty(exports, "File", { + enumerable: true, + get: function get() { + return _file.default; + } +}); +Object.defineProperty(exports, "buildExternalHelpers", { + enumerable: true, + get: function get() { + return _buildExternalHelpers.default; + } +}); +Object.defineProperty(exports, "resolvePlugin", { + enumerable: true, + get: function get() { + return _files.resolvePlugin; + } +}); +Object.defineProperty(exports, "resolvePreset", { + enumerable: true, + get: function get() { + return _files.resolvePreset; + } +}); +Object.defineProperty(exports, "version", { + enumerable: true, + get: function get() { + return _package.version; + } +}); +Object.defineProperty(exports, "getEnv", { + enumerable: true, + get: function get() { + return _environment.getEnv; + } +}); +Object.defineProperty(exports, "traverse", { + enumerable: true, + get: function get() { + return _traverse().default; + } +}); +Object.defineProperty(exports, "template", { + enumerable: true, + get: function get() { + return _template().default; + } +}); +Object.defineProperty(exports, "loadPartialConfig", { + enumerable: true, + get: function get() { + return _config.loadPartialConfig; + } +}); +Object.defineProperty(exports, "loadOptions", { + enumerable: true, + get: function get() { + return _config.loadOptions; + } +}); +Object.defineProperty(exports, "OptionManager", { + enumerable: true, + get: function get() { + return _config.OptionManager; + } +}); +Object.defineProperty(exports, "createConfigItem", { + enumerable: true, + get: function get() { + return _item.createConfigItem; + } +}); +Object.defineProperty(exports, "transform", { + enumerable: true, + get: function get() { + return _transform.default; + } +}); +Object.defineProperty(exports, "transformSync", { + enumerable: true, + get: function get() { + return _transformSync.default; + } +}); +Object.defineProperty(exports, "transformFile", { + enumerable: true, + get: function get() { + return _transformFile.default; + } +}); +Object.defineProperty(exports, "transformFileSync", { + enumerable: true, + get: function get() { + return _transformFileSync.default; + } +}); +Object.defineProperty(exports, "transformFromAst", { + enumerable: true, + get: function get() { + return _transformAst.default; + } +}); +Object.defineProperty(exports, "transformFromAstSync", { + enumerable: true, + get: function get() { + return _transformAstSync.default; + } +}); +Object.defineProperty(exports, "parse", { + enumerable: true, + get: function get() { + return _parse.default; + } +}); +exports.types = exports.DEFAULT_EXTENSIONS = void 0; + +var _file = _interopRequireDefault(require("./transformation/file/file")); + +var _buildExternalHelpers = _interopRequireDefault(require("./tools/build-external-helpers")); + +var _files = require("./config/files"); + +var _package = require("../package.json"); + +var _environment = require("./config/helpers/environment"); + +function _types() { + const data = _interopRequireWildcard(require("@babel/types")); + + _types = function _types() { + return data; + }; + + return data; +} + +Object.defineProperty(exports, "types", { + enumerable: true, + get: function get() { + return _types(); + } +}); + +function _traverse() { + const data = _interopRequireDefault(require("@babel/traverse")); + + _traverse = function _traverse() { + return data; + }; + + return data; +} + +function _template() { + const data = _interopRequireDefault(require("@babel/template")); + + _template = function _template() { + return data; + }; + + return data; +} + +var _config = require("./config"); + +var _item = require("./config/item"); + +var _transform = _interopRequireDefault(require("./transform")); + +var _transformSync = _interopRequireDefault(require("./transform-sync")); + +var _transformFile = _interopRequireDefault(require("./transform-file")); + +var _transformFileSync = _interopRequireDefault(require("./transform-file-sync")); + +var _transformAst = _interopRequireDefault(require("./transform-ast")); + +var _transformAstSync = _interopRequireDefault(require("./transform-ast-sync")); + +var _parse = _interopRequireDefault(require("./parse")); + +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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function Plugin(alias) { + throw new Error(`The (${alias}) Babel 5 plugin is being run with an unsupported Babel version.`); +} + +const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs"]); +exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/parse.js b/node_modules/@babel/core/lib/parse.js new file mode 100644 index 00000000..2251e268 --- /dev/null +++ b/node_modules/@babel/core/lib/parse.js @@ -0,0 +1,25 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = parse; + +var _config = _interopRequireDefault(require("./config")); + +var _normalizeFile = _interopRequireDefault(require("./transformation/normalize-file")); + +var _normalizeOpts = _interopRequireDefault(require("./transformation/normalize-opts")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function parse(code, opts) { + const config = (0, _config.default)(opts); + + if (config === null) { + return null; + } + + const file = (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code); + return file.ast; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/tools/build-external-helpers.js b/node_modules/@babel/core/lib/tools/build-external-helpers.js new file mode 100644 index 00000000..02af09e7 --- /dev/null +++ b/node_modules/@babel/core/lib/tools/build-external-helpers.js @@ -0,0 +1,144 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _default; + +function helpers() { + const data = _interopRequireWildcard(require("@babel/helpers")); + + helpers = function helpers() { + return data; + }; + + return data; +} + +function _generator() { + const data = _interopRequireDefault(require("@babel/generator")); + + _generator = function _generator() { + return data; + }; + + return data; +} + +function _template() { + const data = _interopRequireDefault(require("@babel/template")); + + _template = function _template() { + return data; + }; + + return data; +} + +function t() { + const data = _interopRequireWildcard(require("@babel/types")); + + t = function t() { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } } + +const buildUmdWrapper = replacements => _template().default` + (function (root, factory) { + if (typeof define === "function" && define.amd) { + define(AMD_ARGUMENTS, factory); + } else if (typeof exports === "object") { + factory(COMMON_ARGUMENTS); + } else { + factory(BROWSER_ARGUMENTS); + } + })(UMD_ROOT, function (FACTORY_PARAMETERS) { + FACTORY_BODY + }); + `(replacements); + +function buildGlobal(whitelist) { + const namespace = t().identifier("babelHelpers"); + const body = []; + const container = t().functionExpression(null, [t().identifier("global")], t().blockStatement(body)); + const tree = t().program([t().expressionStatement(t().callExpression(container, [t().conditionalExpression(t().binaryExpression("===", t().unaryExpression("typeof", t().identifier("global")), t().stringLiteral("undefined")), t().identifier("self"), t().identifier("global"))]))]); + body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().assignmentExpression("=", t().memberExpression(t().identifier("global"), namespace), t().objectExpression([])))])); + buildHelpers(body, namespace, whitelist); + return tree; +} + +function buildModule(whitelist) { + const body = []; + const refs = buildHelpers(body, null, whitelist); + body.unshift(t().exportNamedDeclaration(null, Object.keys(refs).map(name => { + return t().exportSpecifier(t().cloneNode(refs[name]), t().identifier(name)); + }))); + return t().program(body, [], "module"); +} + +function buildUmd(whitelist) { + const namespace = t().identifier("babelHelpers"); + const body = []; + body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().identifier("global"))])); + buildHelpers(body, namespace, whitelist); + return t().program([buildUmdWrapper({ + FACTORY_PARAMETERS: t().identifier("global"), + BROWSER_ARGUMENTS: t().assignmentExpression("=", t().memberExpression(t().identifier("root"), namespace), t().objectExpression([])), + COMMON_ARGUMENTS: t().identifier("exports"), + AMD_ARGUMENTS: t().arrayExpression([t().stringLiteral("exports")]), + FACTORY_BODY: body, + UMD_ROOT: t().identifier("this") + })]); +} + +function buildVar(whitelist) { + const namespace = t().identifier("babelHelpers"); + const body = []; + body.push(t().variableDeclaration("var", [t().variableDeclarator(namespace, t().objectExpression([]))])); + const tree = t().program(body); + buildHelpers(body, namespace, whitelist); + body.push(t().expressionStatement(namespace)); + return tree; +} + +function buildHelpers(body, namespace, whitelist) { + const getHelperReference = name => { + return namespace ? t().memberExpression(namespace, t().identifier(name)) : t().identifier(`_${name}`); + }; + + const refs = {}; + helpers().list.forEach(function (name) { + if (whitelist && whitelist.indexOf(name) < 0) return; + const ref = refs[name] = getHelperReference(name); + + const _helpers$get = helpers().get(name, getHelperReference, ref), + nodes = _helpers$get.nodes; + + body.push(...nodes); + }); + return refs; +} + +function _default(whitelist, outputType = "global") { + let tree; + const build = { + global: buildGlobal, + module: buildModule, + umd: buildUmd, + var: buildVar + }[outputType]; + + if (build) { + tree = build(whitelist); + } else { + throw new Error(`Unsupported output type ${outputType}`); + } + + return (0, _generator().default)(tree).code; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-ast-sync.js b/node_modules/@babel/core/lib/transform-ast-sync.js new file mode 100644 index 00000000..a4946dd6 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-ast-sync.js @@ -0,0 +1,19 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = transformFromAstSync; + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function transformFromAstSync(ast, code, opts) { + const config = (0, _config.default)(opts); + if (config === null) return null; + if (!ast) throw new Error("No AST given"); + return (0, _transformation.runSync)(config, code, ast); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-ast.js b/node_modules/@babel/core/lib/transform-ast.js new file mode 100644 index 00000000..13f18a40 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-ast.js @@ -0,0 +1,39 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +var _transformAstSync = _interopRequireDefault(require("./transform-ast-sync")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var transformFromAst = function transformFromAst(ast, code, opts, callback) { + if (typeof opts === "function") { + opts = undefined; + callback = opts; + } + + if (callback === undefined) return (0, _transformAstSync.default)(ast, code, opts); + const cb = callback; + process.nextTick(() => { + let cfg; + + try { + cfg = (0, _config.default)(opts); + if (cfg === null) return cb(null, null); + } catch (err) { + return cb(err); + } + + if (!ast) return cb(new Error("No AST given")); + (0, _transformation.runAsync)(cfg, code, ast, cb); + }); +}; + +exports.default = transformFromAst;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-file-browser.js b/node_modules/@babel/core/lib/transform-file-browser.js new file mode 100644 index 00000000..735e5829 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-file-browser.js @@ -0,0 +1,14 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = transformFile; + +function transformFile(filename, opts = {}, callback) { + if (typeof opts === "function") { + callback = opts; + } + + callback(new Error("Transforming files is not supported in browsers"), null); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-file-sync-browser.js b/node_modules/@babel/core/lib/transform-file-sync-browser.js new file mode 100644 index 00000000..3f5740dd --- /dev/null +++ b/node_modules/@babel/core/lib/transform-file-sync-browser.js @@ -0,0 +1,10 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = transformFileSync; + +function transformFileSync() { + throw new Error("Transforming files is not supported in browsers"); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-file-sync.js b/node_modules/@babel/core/lib/transform-file-sync.js new file mode 100644 index 00000000..53086e55 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-file-sync.js @@ -0,0 +1,40 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = transformFileSync; + +function _fs() { + const data = _interopRequireDefault(require("fs")); + + _fs = function _fs() { + return data; + }; + + return data; +} + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function transformFileSync(filename, opts) { + let options; + + if (opts == null) { + options = { + filename + }; + } else if (opts && typeof opts === "object") { + options = Object.assign({}, opts, { + filename + }); + } + + const config = (0, _config.default)(options); + if (config === null) return null; + return (0, _transformation.runSync)(config, _fs().default.readFileSync(filename, "utf8")); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-file.js b/node_modules/@babel/core/lib/transform-file.js new file mode 100644 index 00000000..a5d4e5e9 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-file.js @@ -0,0 +1,61 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _fs() { + const data = _interopRequireDefault(require("fs")); + + _fs = function _fs() { + return data; + }; + + return data; +} + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var transformFile = function transformFile(filename, opts, callback) { + let options; + + if (typeof opts === "function") { + callback = opts; + opts = undefined; + } + + if (opts == null) { + options = { + filename + }; + } else if (opts && typeof opts === "object") { + options = Object.assign({}, opts, { + filename + }); + } + + process.nextTick(() => { + let cfg; + + try { + cfg = (0, _config.default)(options); + if (cfg === null) return callback(null, null); + } catch (err) { + return callback(err); + } + + const config = cfg; + + _fs().default.readFile(filename, "utf8", function (err, code) { + if (err) return callback(err, null); + (0, _transformation.runAsync)(config, code, null, callback); + }); + }); +}; + +exports.default = transformFile;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform-sync.js b/node_modules/@babel/core/lib/transform-sync.js new file mode 100644 index 00000000..f3a36581 --- /dev/null +++ b/node_modules/@babel/core/lib/transform-sync.js @@ -0,0 +1,18 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = transformSync; + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function transformSync(code, opts) { + const config = (0, _config.default)(opts); + if (config === null) return null; + return (0, _transformation.runSync)(config, code); +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transform.js b/node_modules/@babel/core/lib/transform.js new file mode 100644 index 00000000..7891c38b --- /dev/null +++ b/node_modules/@babel/core/lib/transform.js @@ -0,0 +1,38 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _config = _interopRequireDefault(require("./config")); + +var _transformation = require("./transformation"); + +var _transformSync = _interopRequireDefault(require("./transform-sync")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var transform = function transform(code, opts, callback) { + if (typeof opts === "function") { + opts = undefined; + callback = opts; + } + + if (callback === undefined) return (0, _transformSync.default)(code, opts); + const cb = callback; + process.nextTick(() => { + let cfg; + + try { + cfg = (0, _config.default)(opts); + if (cfg === null) return cb(null, null); + } catch (err) { + return cb(err); + } + + (0, _transformation.runAsync)(cfg, code, null, cb); + }); +}; + +exports.default = transform;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js b/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js new file mode 100644 index 00000000..4e6056af --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/block-hoist-plugin.js @@ -0,0 +1,67 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = loadBlockHoistPlugin; + +function _sortBy() { + const data = _interopRequireDefault(require("lodash/sortBy")); + + _sortBy = function _sortBy() { + return data; + }; + + return data; +} + +var _config = _interopRequireDefault(require("../config")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +let LOADED_PLUGIN; + +function loadBlockHoistPlugin() { + if (!LOADED_PLUGIN) { + const config = (0, _config.default)({ + babelrc: false, + configFile: false, + plugins: [blockHoistPlugin] + }); + LOADED_PLUGIN = config ? config.passes[0][0] : undefined; + if (!LOADED_PLUGIN) throw new Error("Assertion failure"); + } + + return LOADED_PLUGIN; +} + +const blockHoistPlugin = { + name: "internal.blockHoist", + visitor: { + Block: { + exit({ + node + }) { + let hasChange = false; + + for (let i = 0; i < node.body.length; i++) { + const bodyNode = node.body[i]; + + if (bodyNode && bodyNode._blockHoist != null) { + hasChange = true; + break; + } + } + + if (!hasChange) return; + node.body = (0, _sortBy().default)(node.body, function (bodyNode) { + let priority = bodyNode && bodyNode._blockHoist; + if (priority == null) priority = 1; + if (priority === true) priority = 2; + return -1 * priority; + }); + } + + } + } +};
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/file/file.js b/node_modules/@babel/core/lib/transformation/file/file.js new file mode 100644 index 00000000..c326b9f9 --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/file/file.js @@ -0,0 +1,238 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function helpers() { + const data = _interopRequireWildcard(require("@babel/helpers")); + + helpers = function helpers() { + return data; + }; + + return data; +} + +function _traverse() { + const data = _interopRequireWildcard(require("@babel/traverse")); + + _traverse = function _traverse() { + return data; + }; + + return data; +} + +function _codeFrame() { + const data = require("@babel/code-frame"); + + _codeFrame = function _codeFrame() { + return data; + }; + + return data; +} + +function t() { + const data = _interopRequireWildcard(require("@babel/types")); + + t = function t() { + return data; + }; + + return data; +} + +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; } } + +const errorVisitor = { + enter(path, state) { + const loc = path.node.loc; + + if (loc) { + state.loc = loc; + path.stop(); + } + } + +}; + +class File { + constructor(options, { + code, + ast, + shebang, + inputMap + }) { + this._map = new Map(); + this.declarations = {}; + this.path = null; + this.ast = {}; + this.metadata = {}; + this.hub = new (_traverse().Hub)(this); + this.code = ""; + this.shebang = ""; + this.inputMap = null; + this.opts = options; + this.code = code; + this.ast = ast; + this.shebang = shebang; + this.inputMap = inputMap; + this.path = _traverse().NodePath.get({ + hub: this.hub, + parentPath: null, + parent: this.ast, + container: this.ast, + key: "program" + }).setContext(); + this.scope = this.path.scope; + } + + set(key, val) { + this._map.set(key, val); + } + + get(key) { + return this._map.get(key); + } + + has(key) { + return this._map.has(key); + } + + getModuleName() { + const _this$opts = this.opts, + filename = _this$opts.filename, + _this$opts$filenameRe = _this$opts.filenameRelative, + filenameRelative = _this$opts$filenameRe === void 0 ? filename : _this$opts$filenameRe, + moduleId = _this$opts.moduleId, + _this$opts$moduleIds = _this$opts.moduleIds, + moduleIds = _this$opts$moduleIds === void 0 ? !!moduleId : _this$opts$moduleIds, + getModuleId = _this$opts.getModuleId, + sourceRootTmp = _this$opts.sourceRoot, + _this$opts$moduleRoot = _this$opts.moduleRoot, + moduleRoot = _this$opts$moduleRoot === void 0 ? sourceRootTmp : _this$opts$moduleRoot, + _this$opts$sourceRoot = _this$opts.sourceRoot, + sourceRoot = _this$opts$sourceRoot === void 0 ? moduleRoot : _this$opts$sourceRoot; + if (!moduleIds) return null; + + if (moduleId != null && !getModuleId) { + return moduleId; + } + + let moduleName = moduleRoot != null ? moduleRoot + "/" : ""; + + if (filenameRelative) { + const sourceRootReplacer = sourceRoot != null ? new RegExp("^" + sourceRoot + "/?") : ""; + moduleName += filenameRelative.replace(sourceRootReplacer, "").replace(/\.(\w*?)$/, ""); + } + + moduleName = moduleName.replace(/\\/g, "/"); + + if (getModuleId) { + return getModuleId(moduleName) || moduleName; + } else { + return moduleName; + } + } + + resolveModuleSource(source) { + return source; + } + + addImport() { + throw new Error("This API has been removed. If you're looking for this " + "functionality in Babel 7, you should import the " + "'@babel/helper-module-imports' module and use the functions exposed " + " from that module, such as 'addNamed' or 'addDefault'."); + } + + addHelper(name) { + const declar = this.declarations[name]; + if (declar) return t().cloneNode(declar); + const generator = this.get("helperGenerator"); + const runtime = this.get("helpersNamespace"); + + if (generator) { + const res = generator(name); + if (res) return res; + } else if (runtime) { + return t().memberExpression(t().cloneNode(runtime), t().identifier(name)); + } + + const uid = this.declarations[name] = this.scope.generateUidIdentifier(name); + const dependencies = {}; + + for (var _iterator = helpers().getDependencies(name), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const dep = _ref; + dependencies[dep] = this.addHelper(dep); + } + + const _helpers$get = helpers().get(name, dep => dependencies[dep], uid, Object.keys(this.scope.getAllBindings())), + nodes = _helpers$get.nodes, + globals = _helpers$get.globals; + + globals.forEach(name => { + if (this.path.scope.hasBinding(name, true)) { + this.path.scope.rename(name); + } + }); + nodes.forEach(node => { + node._compact = true; + }); + this.path.unshiftContainer("body", nodes); + this.path.get("body").forEach(path => { + if (nodes.indexOf(path.node) === -1) return; + if (path.isVariableDeclaration()) this.scope.registerDeclaration(path); + }); + return uid; + } + + addTemplateObject() { + throw new Error("This function has been moved into the template literal transform itself."); + } + + buildCodeFrameError(node, msg, Error = SyntaxError) { + let loc = node && (node.loc || node._loc); + msg = `${this.opts.filename}: ${msg}`; + + if (!loc && node) { + const state = { + loc: null + }; + (0, _traverse().default)(node, errorVisitor, this.scope, state); + loc = state.loc; + let txt = "This is an error on an internal node. Probably an internal error."; + if (loc) txt += " Location has been estimated."; + msg += ` (${txt})`; + } + + if (loc) { + const _this$opts$highlightC = this.opts.highlightCode, + highlightCode = _this$opts$highlightC === void 0 ? true : _this$opts$highlightC; + msg += "\n" + (0, _codeFrame().codeFrameColumns)(this.code, { + start: { + line: loc.start.line, + column: loc.start.column + 1 + } + }, { + highlightCode + }); + } + + return new Error(msg); + } + +} + +exports.default = File;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/file/generate.js b/node_modules/@babel/core/lib/transformation/file/generate.js new file mode 100644 index 00000000..98f2a54f --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/file/generate.js @@ -0,0 +1,114 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = generateCode; + +function _convertSourceMap() { + const data = _interopRequireDefault(require("convert-source-map")); + + _convertSourceMap = function _convertSourceMap() { + return data; + }; + + return data; +} + +function _generator() { + const data = _interopRequireDefault(require("@babel/generator")); + + _generator = function _generator() { + return data; + }; + + return data; +} + +var _mergeMap = _interopRequireDefault(require("./merge-map")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function generateCode(pluginPasses, file) { + const opts = file.opts, + ast = file.ast, + shebang = file.shebang, + code = file.code, + inputMap = file.inputMap; + const results = []; + + for (var _iterator = pluginPasses, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const plugins = _ref; + + for (var _iterator2 = plugins, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + const plugin = _ref2; + const generatorOverride = plugin.generatorOverride; + + if (generatorOverride) { + const result = generatorOverride(ast, opts.generatorOpts, code, _generator().default); + if (result !== undefined) results.push(result); + } + } + } + + let result; + + if (results.length === 0) { + result = (0, _generator().default)(ast, opts.generatorOpts, code); + } else if (results.length === 1) { + result = results[0]; + + if (typeof result.then === "function") { + throw new Error(`You appear to be using an async parser plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); + } + } else { + throw new Error("More than one plugin attempted to override codegen."); + } + + let _result = result, + outputCode = _result.code, + outputMap = _result.map; + + if (shebang) { + outputCode = `${shebang}\n${outputCode}`; + } + + if (outputMap && inputMap) { + outputMap = (0, _mergeMap.default)(inputMap.toObject(), outputMap); + } + + if (opts.sourceMaps === "inline" || opts.sourceMaps === "both") { + outputCode += "\n" + _convertSourceMap().default.fromObject(outputMap).toComment(); + } + + if (opts.sourceMaps === "inline") { + outputMap = null; + } + + return { + outputCode, + outputMap + }; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/file/merge-map.js b/node_modules/@babel/core/lib/transformation/file/merge-map.js new file mode 100644 index 00000000..6f0edd17 --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/file/merge-map.js @@ -0,0 +1,332 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = mergeSourceMap; + +function _sourceMap() { + const data = _interopRequireDefault(require("source-map")); + + _sourceMap = function _sourceMap() { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function mergeSourceMap(inputMap, map) { + const input = buildMappingData(inputMap); + const output = buildMappingData(map); + const mergedGenerator = new (_sourceMap().default.SourceMapGenerator)(); + + for (var _iterator = input.sources, _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; + } + + const _ref = _ref2; + const source = _ref.source; + + if (typeof source.content === "string") { + mergedGenerator.setSourceContent(source.path, source.content); + } + } + + if (output.sources.length === 1) { + const defaultSource = output.sources[0]; + const insertedMappings = new Map(); + eachInputGeneratedRange(input, (generated, original, source) => { + eachOverlappingGeneratedOutputRange(defaultSource, generated, item => { + const key = makeMappingKey(item); + if (insertedMappings.has(key)) return; + insertedMappings.set(key, item); + mergedGenerator.addMapping({ + source: source.path, + original: { + line: original.line, + column: original.columnStart + }, + generated: { + line: item.line, + column: item.columnStart + }, + name: original.name + }); + }); + }); + + for (var _iterator2 = insertedMappings.values(), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + const item = _ref3; + + if (item.columnEnd === Infinity) { + continue; + } + + const clearItem = { + line: item.line, + columnStart: item.columnEnd + }; + const key = makeMappingKey(clearItem); + + if (insertedMappings.has(key)) { + continue; + } + + mergedGenerator.addMapping({ + generated: { + line: clearItem.line, + column: clearItem.columnStart + } + }); + } + } + + const result = mergedGenerator.toJSON(); + + if (typeof input.sourceRoot === "string") { + result.sourceRoot = input.sourceRoot; + } + + return result; +} + +function makeMappingKey(item) { + return JSON.stringify([item.line, item.columnStart]); +} + +function eachOverlappingGeneratedOutputRange(outputFile, inputGeneratedRange, callback) { + const overlappingOriginal = filterApplicableOriginalRanges(outputFile, inputGeneratedRange); + + for (var _iterator3 = overlappingOriginal, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { + var _ref5; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref5 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref5 = _i3.value; + } + + const _ref4 = _ref5; + const generated = _ref4.generated; + + for (var _iterator4 = generated, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { + var _ref6; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref6 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref6 = _i4.value; + } + + const item = _ref6; + callback(item); + } + } +} + +function filterApplicableOriginalRanges({ + mappings +}, { + line, + columnStart, + columnEnd +}) { + return filterSortedArray(mappings, ({ + original: outOriginal + }) => { + if (line > outOriginal.line) return -1; + if (line < outOriginal.line) return 1; + if (columnStart >= outOriginal.columnEnd) return -1; + if (columnEnd <= outOriginal.columnStart) return 1; + return 0; + }); +} + +function eachInputGeneratedRange(map, callback) { + for (var _iterator5 = map.sources, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) { + var _ref8; + + if (_isArray5) { + if (_i5 >= _iterator5.length) break; + _ref8 = _iterator5[_i5++]; + } else { + _i5 = _iterator5.next(); + if (_i5.done) break; + _ref8 = _i5.value; + } + + const _ref7 = _ref8; + const source = _ref7.source, + mappings = _ref7.mappings; + + for (var _iterator6 = mappings, _isArray6 = Array.isArray(_iterator6), _i6 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) { + var _ref10; + + if (_isArray6) { + if (_i6 >= _iterator6.length) break; + _ref10 = _iterator6[_i6++]; + } else { + _i6 = _iterator6.next(); + if (_i6.done) break; + _ref10 = _i6.value; + } + + const _ref9 = _ref10; + const original = _ref9.original, + generated = _ref9.generated; + + for (var _iterator7 = generated, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : _iterator7[Symbol.iterator]();;) { + var _ref11; + + if (_isArray7) { + if (_i7 >= _iterator7.length) break; + _ref11 = _iterator7[_i7++]; + } else { + _i7 = _iterator7.next(); + if (_i7.done) break; + _ref11 = _i7.value; + } + + const item = _ref11; + callback(item, original, source); + } + } + } +} + +function buildMappingData(map) { + const consumer = new (_sourceMap().default.SourceMapConsumer)(Object.assign({}, map, { + sourceRoot: null + })); + const sources = new Map(); + const mappings = new Map(); + let last = null; + consumer.computeColumnSpans(); + consumer.eachMapping(m => { + if (m.originalLine === null) return; + let source = sources.get(m.source); + + if (!source) { + source = { + path: m.source, + content: consumer.sourceContentFor(m.source, true) + }; + sources.set(m.source, source); + } + + let sourceData = mappings.get(source); + + if (!sourceData) { + sourceData = { + source, + mappings: [] + }; + mappings.set(source, sourceData); + } + + const obj = { + line: m.originalLine, + columnStart: m.originalColumn, + columnEnd: Infinity, + name: m.name + }; + + if (last && last.source === source && last.mapping.line === m.originalLine) { + last.mapping.columnEnd = m.originalColumn; + } + + last = { + source, + mapping: obj + }; + sourceData.mappings.push({ + original: obj, + generated: consumer.allGeneratedPositionsFor({ + source: m.source, + line: m.originalLine, + column: m.originalColumn + }).map(item => ({ + line: item.line, + columnStart: item.column, + columnEnd: item.lastColumn + 1 + })) + }); + }, null, _sourceMap().default.SourceMapConsumer.ORIGINAL_ORDER); + return { + file: map.file, + sourceRoot: map.sourceRoot, + sources: Array.from(mappings.values()) + }; +} + +function findInsertionLocation(array, callback) { + let left = 0; + let right = array.length; + + while (left < right) { + const mid = Math.floor((left + right) / 2); + const item = array[mid]; + const result = callback(item); + + if (result === 0) { + left = mid; + break; + } + + if (result >= 0) { + right = mid; + } else { + left = mid + 1; + } + } + + let i = left; + + if (i < array.length) { + while (i > 0 && callback(array[i]) >= 0) { + i--; + } + + return i + 1; + } + + return i; +} + +function filterSortedArray(array, callback) { + const start = findInsertionLocation(array, callback); + const results = []; + + for (let i = start; i < array.length && callback(array[i]) === 0; i++) { + results.push(array[i]); + } + + return results; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/index.js b/node_modules/@babel/core/lib/transformation/index.js new file mode 100644 index 00000000..fc6aedba --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/index.js @@ -0,0 +1,137 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.runAsync = runAsync; +exports.runSync = runSync; + +function _traverse() { + const data = _interopRequireDefault(require("@babel/traverse")); + + _traverse = function _traverse() { + return data; + }; + + return data; +} + +var _pluginPass = _interopRequireDefault(require("./plugin-pass")); + +var _blockHoistPlugin = _interopRequireDefault(require("./block-hoist-plugin")); + +var _normalizeOpts = _interopRequireDefault(require("./normalize-opts")); + +var _normalizeFile = _interopRequireDefault(require("./normalize-file")); + +var _generate = _interopRequireDefault(require("./file/generate")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function runAsync(config, code, ast, callback) { + let result; + + try { + result = runSync(config, code, ast); + } catch (err) { + return callback(err); + } + + return callback(null, result); +} + +function runSync(config, code, ast) { + const file = (0, _normalizeFile.default)(config.passes, (0, _normalizeOpts.default)(config), code, ast); + transformFile(file, config.passes); + const opts = file.opts; + + const _ref = opts.code !== false ? (0, _generate.default)(config.passes, file) : {}, + outputCode = _ref.outputCode, + outputMap = _ref.outputMap; + + return { + metadata: file.metadata, + options: opts, + ast: opts.ast === true ? file.ast : null, + code: outputCode === undefined ? null : outputCode, + map: outputMap === undefined ? null : outputMap, + sourceType: file.ast.program.sourceType + }; +} + +function transformFile(file, pluginPasses) { + for (var _iterator = pluginPasses, _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; + } + + const pluginPairs = _ref2; + const passPairs = []; + const passes = []; + const visitors = []; + + for (var _iterator2 = pluginPairs.concat([(0, _blockHoistPlugin.default)()]), _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref3; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref3 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref3 = _i2.value; + } + + const plugin = _ref3; + const pass = new _pluginPass.default(file, plugin.key, plugin.options); + passPairs.push([plugin, pass]); + passes.push(pass); + visitors.push(plugin.visitor); + } + + for (var _i3 = 0; _i3 < passPairs.length; _i3++) { + const _passPairs$_i = passPairs[_i3], + plugin = _passPairs$_i[0], + pass = _passPairs$_i[1]; + const fn = plugin.pre; + + if (fn) { + const result = fn.call(pass, file); + + if (isThenable(result)) { + throw new Error(`You appear to be using an plugin with an async .pre, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + } + } + } + + const visitor = _traverse().default.visitors.merge(visitors, passes, file.opts.wrapPluginVisitorMethod); + + (0, _traverse().default)(file.ast, visitor, file.scope); + + for (var _i4 = 0; _i4 < passPairs.length; _i4++) { + const _passPairs$_i2 = passPairs[_i4], + plugin = _passPairs$_i2[0], + pass = _passPairs$_i2[1]; + const fn = plugin.post; + + if (fn) { + const result = fn.call(pass, file); + + if (isThenable(result)) { + throw new Error(`You appear to be using an plugin with an async .post, ` + `which your current version of Babel does not support.` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + } + } + } + } +} + +function isThenable(val) { + return !!val && (typeof val === "object" || typeof val === "function") && typeof val.then === "function"; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/normalize-file.js b/node_modules/@babel/core/lib/transformation/normalize-file.js new file mode 100644 index 00000000..6d21f2ef --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/normalize-file.js @@ -0,0 +1,176 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = normalizeFile; + +function t() { + const data = _interopRequireWildcard(require("@babel/types")); + + t = function t() { + return data; + }; + + return data; +} + +function _convertSourceMap() { + const data = _interopRequireDefault(require("convert-source-map")); + + _convertSourceMap = function _convertSourceMap() { + return data; + }; + + return data; +} + +function _babylon() { + const data = require("babylon"); + + _babylon = function _babylon() { + return data; + }; + + return data; +} + +function _codeFrame() { + const data = require("@babel/code-frame"); + + _codeFrame = function _codeFrame() { + return data; + }; + + return data; +} + +var _file = _interopRequireDefault(require("./file/file")); + +var _missingPluginHelper = _interopRequireDefault(require("./util/missing-plugin-helper")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +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; } } + +const shebangRegex = /^#!.*/; + +function normalizeFile(pluginPasses, options, code, ast) { + code = `${code || ""}`; + let shebang = null; + let inputMap = null; + + if (options.inputSourceMap !== false) { + inputMap = _convertSourceMap().default.fromSource(code); + + if (inputMap) { + code = _convertSourceMap().default.removeComments(code); + } else if (typeof options.inputSourceMap === "object") { + inputMap = _convertSourceMap().default.fromObject(options.inputSourceMap); + } + } + + const shebangMatch = shebangRegex.exec(code); + + if (shebangMatch) { + shebang = shebangMatch[0]; + code = code.replace(shebangRegex, ""); + } + + if (ast) { + if (ast.type === "Program") { + ast = t().file(ast, [], []); + } else if (ast.type !== "File") { + throw new Error("AST root must be a Program or File node"); + } + } else { + ast = parser(pluginPasses, options, code); + } + + return new _file.default(options, { + code, + ast, + shebang, + inputMap + }); +} + +function parser(pluginPasses, options, code) { + try { + const results = []; + + for (var _iterator = pluginPasses, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const plugins = _ref; + + for (var _iterator2 = plugins, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + const plugin = _ref2; + const parserOverride = plugin.parserOverride; + + if (parserOverride) { + const ast = parserOverride(code, options.parserOpts, _babylon().parse); + if (ast !== undefined) results.push(ast); + } + } + } + + if (results.length === 0) { + return (0, _babylon().parse)(code, options.parserOpts); + } else if (results.length === 1) { + if (typeof results[0].then === "function") { + throw new Error(`You appear to be using an async codegen plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, you may need to upgrade ` + `your @babel/core version.`); + } + + return results[0]; + } + + throw new Error("More than one plugin attempted to override parsing."); + } catch (err) { + if (err.code === "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED") { + err.message += "\nConsider renaming the file to '.mjs', or setting sourceType:module " + "or sourceType:unambiguous in your Babel config for this file."; + } + + const loc = err.loc, + missingPlugin = err.missingPlugin; + + if (loc) { + const codeFrame = (0, _codeFrame().codeFrameColumns)(code, { + start: { + line: loc.line, + column: loc.column + 1 + } + }, options); + + if (missingPlugin) { + err.message = `${options.filename || "unknown"}: ` + (0, _missingPluginHelper.default)(missingPlugin[0], loc, codeFrame); + } else { + err.message = `${options.filename || "unknown"}: ${err.message}\n\n` + codeFrame; + } + + err.code = "BABEL_PARSE_ERROR"; + } + + throw err; + } +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/normalize-opts.js b/node_modules/@babel/core/lib/transformation/normalize-opts.js new file mode 100644 index 00000000..9afc83db --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/normalize-opts.js @@ -0,0 +1,97 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = normalizeOptions; + +function _path() { + const data = _interopRequireDefault(require("path")); + + _path = function _path() { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function normalizeOptions(config) { + const _config$options = config.options, + filename = _config$options.filename, + cwd = _config$options.cwd, + _config$options$filen = _config$options.filenameRelative, + filenameRelative = _config$options$filen === void 0 ? typeof filename === "string" ? _path().default.relative(cwd, filename) : "unknown" : _config$options$filen, + _config$options$sourc = _config$options.sourceType, + sourceType = _config$options$sourc === void 0 ? "module" : _config$options$sourc, + inputSourceMap = _config$options.inputSourceMap, + _config$options$sourc2 = _config$options.sourceMaps, + sourceMaps = _config$options$sourc2 === void 0 ? !!inputSourceMap : _config$options$sourc2, + moduleRoot = _config$options.moduleRoot, + _config$options$sourc3 = _config$options.sourceRoot, + sourceRoot = _config$options$sourc3 === void 0 ? moduleRoot : _config$options$sourc3, + _config$options$sourc4 = _config$options.sourceFileName, + sourceFileName = _config$options$sourc4 === void 0 ? _path().default.basename(filenameRelative) : _config$options$sourc4, + _config$options$comme = _config$options.comments, + comments = _config$options$comme === void 0 ? true : _config$options$comme, + _config$options$compa = _config$options.compact, + compact = _config$options$compa === void 0 ? "auto" : _config$options$compa; + const opts = config.options; + const options = Object.assign({}, opts, { + parserOpts: Object.assign({ + sourceType: _path().default.extname(filenameRelative) === ".mjs" ? "module" : sourceType, + sourceFileName: filename, + plugins: [] + }, opts.parserOpts), + generatorOpts: Object.assign({ + filename, + auxiliaryCommentBefore: opts.auxiliaryCommentBefore, + auxiliaryCommentAfter: opts.auxiliaryCommentAfter, + retainLines: opts.retainLines, + comments, + shouldPrintComment: opts.shouldPrintComment, + compact, + minified: opts.minified, + sourceMaps, + sourceRoot, + sourceFileName + }, opts.generatorOpts) + }); + + for (var _iterator = config.passes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + const plugins = _ref; + + for (var _iterator2 = plugins, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + const plugin = _ref2; + + if (plugin.manipulateOptions) { + plugin.manipulateOptions(options, options.parserOpts); + } + } + } + + return options; +}
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/plugin-pass.js b/node_modules/@babel/core/lib/transformation/plugin-pass.js new file mode 100644 index 00000000..fe24bfd2 --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/plugin-pass.js @@ -0,0 +1,43 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +class PluginPass { + constructor(file, key, options) { + this._map = new Map(); + this.key = key; + this.file = file; + this.opts = options || {}; + this.filename = typeof file.opts.filename === "string" ? file.opts.filename : undefined; + } + + set(key, val) { + this._map.set(key, val); + } + + get(key) { + return this._map.get(key); + } + + addHelper(name) { + return this.file.addHelper(name); + } + + addImport() { + return this.file.addImport(); + } + + getModuleName() { + return this.file.getModuleName(); + } + + buildCodeFrameError(node, msg, Error) { + return this.file.buildCodeFrameError(node, msg, Error); + } + +} + +exports.default = PluginPass;
\ No newline at end of file diff --git a/node_modules/@babel/core/lib/transformation/util/missing-plugin-helper.js b/node_modules/@babel/core/lib/transformation/util/missing-plugin-helper.js new file mode 100644 index 00000000..d568709d --- /dev/null +++ b/node_modules/@babel/core/lib/transformation/util/missing-plugin-helper.js @@ -0,0 +1,237 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = generateMissingPluginMessage; +const pluginNameMap = { + asyncGenerators: { + syntax: { + name: "@babel/plugin-syntax-async-generators", + url: "https://git.io/vb4SY" + }, + transform: { + name: "@babel/plugin-proposal-async-generator-functions", + url: "https://git.io/vb4yp" + } + }, + classProperties: { + syntax: { + name: "@babel/plugin-syntax-class-properties", + url: "https://git.io/vb4yQ" + }, + transform: { + name: "@babel/plugin-proposal-class-properties", + url: "https://git.io/vb4SL" + } + }, + decorators: { + syntax: { + name: "@babel/plugin-syntax-decorators", + url: "https://git.io/vb4y9" + }, + transform: { + name: "@babel/plugin-proposal-decorators", + url: "https://git.io/vb4ST" + } + }, + doExpressions: { + syntax: { + name: "@babel/plugin-syntax-do-expressions", + url: "https://git.io/vb4yh" + }, + transform: { + name: "@babel/plugin-proposal-do-expressions", + url: "https://git.io/vb4S3" + } + }, + dynamicImport: { + syntax: { + name: "@babel/plugin-syntax-dynamic-import", + url: "https://git.io/vb4Sv" + } + }, + exportDefaultFrom: { + syntax: { + name: "@babel/plugin-syntax-export-default-from", + url: "https://git.io/vb4SO" + }, + transform: { + name: "@babel/plugin-proposal-export-default-from", + url: "https://git.io/vb4yH" + } + }, + exportNamespaceFrom: { + syntax: { + name: "@babel/plugin-syntax-export-namespace-from", + url: "https://git.io/vb4Sf" + }, + transform: { + name: "@babel/plugin-proposal-export-namespace-from", + url: "https://git.io/vb4SG" + } + }, + flow: { + syntax: { + name: "@babel/plugin-syntax-flow", + url: "https://git.io/vb4yb" + }, + transform: { + name: "@babel/plugin-transform-flow-strip-types", + url: "https://git.io/vb49g" + } + }, + functionBind: { + syntax: { + name: "@babel/plugin-syntax-function-bind", + url: "https://git.io/vb4y7" + }, + transform: { + name: "@babel/plugin-proposal-function-bind", + url: "https://git.io/vb4St" + } + }, + functionSent: { + syntax: { + name: "@babel/plugin-syntax-function-sent", + url: "https://git.io/vb4yN" + }, + transform: { + name: "@babel/plugin-proposal-function-sent", + url: "https://git.io/vb4SZ" + } + }, + importMeta: { + syntax: { + name: "@babel/plugin-syntax-import-meta", + url: "https://git.io/vbKK6" + } + }, + jsx: { + syntax: { + name: "@babel/plugin-syntax-jsx", + url: "https://git.io/vb4yA" + }, + transform: { + name: "@babel/plugin-transform-react-jsx", + url: "https://git.io/vb4yd" + } + }, + logicalAssignment: { + syntax: { + name: "@babel/plugin-syntax-logical-assignment-operators", + url: "https://git.io/vAlBp" + }, + transform: { + name: "@babel/plugin-proposal-logical-assignment-operators", + url: "https://git.io/vAlRe" + } + }, + nullishCoalescingOperator: { + syntax: { + name: "@babel/plugin-syntax-nullish-coalescing-operator", + url: "https://git.io/vb4yx" + }, + transform: { + name: "@babel/plugin-proposal-nullish-coalescing-operator", + url: "https://git.io/vb4Se" + } + }, + numericSeparator: { + syntax: { + name: "@babel/plugin-syntax-numeric-separator", + url: "https://git.io/vb4Sq" + }, + transform: { + name: "@babel/plugin-proposal-numeric-separator", + url: "https://git.io/vb4yS" + } + }, + objectRestSpread: { + syntax: { + name: "@babel/plugin-syntax-object-rest-spread", + url: "https://git.io/vb4y5" + }, + transform: { + name: "@babel/plugin-proposal-object-rest-spread", + url: "https://git.io/vb4Ss" + } + }, + optionalCatchBinding: { + syntax: { + name: "@babel/plugin-syntax-optional-catch-binding", + url: "https://git.io/vb4Sn" + }, + transform: { + name: "@babel/plugin-proposal-optional-catch-binding", + url: "https://git.io/vb4SI" + } + }, + optionalChaining: { + syntax: { + name: "@babel/plugin-syntax-optional-chaining", + url: "https://git.io/vb4Sc" + }, + transform: { + name: "@babel/plugin-proposal-optional-chaining", + url: "https://git.io/vb4Sk" + } + }, + pipelineOperator: { + syntax: { + name: "@babel/plugin-syntax-pipeline-operator", + url: "https://git.io/vb4yj" + }, + transform: { + name: "@babel/plugin-proposal-pipeline-operator", + url: "https://git.io/vb4SU" + } + }, + throwExpressions: { + syntax: { + name: "@babel/plugin-syntax-throw-expressions", + url: "https://git.io/vb4SJ" + }, + transform: { + name: "@babel/plugin-proposal-throw-expressions", + url: "https://git.io/vb4yF" + } + }, + typescript: { + syntax: { + name: "@babel/plugin-syntax-typescript", + url: "https://git.io/vb4SC" + }, + transform: { + name: "@babel/plugin-transform-typescript", + url: "https://git.io/vb4Sm" + } + } +}; + +const getNameURLCombination = ({ + name, + url +}) => `${name} (${url})`; + +function generateMissingPluginMessage(missingPluginName, loc, codeFrame) { + let helpMessage = `Support for the experimental syntax '${missingPluginName}' isn't currently enabled ` + `(${loc.line}:${loc.column + 1}):\n\n` + codeFrame; + const pluginInfo = pluginNameMap[missingPluginName]; + + if (pluginInfo) { + const syntaxPlugin = pluginInfo.syntax, + transformPlugin = pluginInfo.transform; + + if (syntaxPlugin) { + if (transformPlugin) { + const transformPluginInfo = getNameURLCombination(transformPlugin); + helpMessage += `\n\nAdd ${transformPluginInfo} to the 'plugins' section of your Babel config ` + `to enable transformation.`; + } else { + const syntaxPluginInfo = getNameURLCombination(syntaxPlugin); + helpMessage += `\n\nAdd ${syntaxPluginInfo} to the 'plugins' section of your Babel config ` + `to enable parsing.`; + } + } + } + + return helpMessage; +}
\ No newline at end of file |
