@babel/core
Advanced tools
Comparing version 7.12.17 to 7.13.0
@@ -78,3 +78,3 @@ "use strict"; | ||
if (!programmaticChain) return null; | ||
const programmaticReport = programmaticLogger.output(); | ||
const programmaticReport = yield* programmaticLogger.output(); | ||
let configFile; | ||
@@ -100,3 +100,3 @@ | ||
if (!result) return null; | ||
configReport = configFileLogger.output(); | ||
configReport = yield* configFileLogger.output(); | ||
@@ -142,3 +142,3 @@ if (babelrc === undefined) { | ||
} else { | ||
babelRcReport = babelrcLogger.output(); | ||
babelRcReport = yield* babelrcLogger.output(); | ||
mergeChain(fileChain, result); | ||
@@ -377,3 +377,3 @@ } | ||
logger(config, index, envName); | ||
mergeChainOpts(chain, config); | ||
yield* mergeChainOpts(chain, config); | ||
} | ||
@@ -413,3 +413,3 @@ | ||
function mergeChainOpts(target, { | ||
function* mergeChainOpts(target, { | ||
options, | ||
@@ -420,4 +420,4 @@ plugins, | ||
target.options.push(options); | ||
target.plugins.push(...plugins()); | ||
target.presets.push(...presets()); | ||
target.plugins.push(...(yield* plugins())); | ||
target.presets.push(...(yield* presets())); | ||
return target; | ||
@@ -424,0 +424,0 @@ } |
@@ -10,2 +10,12 @@ "use strict"; | ||
function _gensync() { | ||
const data = _interopRequireDefault(require("gensync")); | ||
_gensync = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _files = require("./files"); | ||
@@ -17,2 +27,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function isEqualDescriptor(a, b) { | ||
@@ -22,2 +34,6 @@ return a.name === b.name && a.value === b.value && a.options === b.options && a.dirname === b.dirname && a.alias === b.alias && a.ownPass === b.ownPass && (a.file && a.file.request) === (b.file && b.file.request) && (a.file && a.file.resolved) === (b.file && b.file.resolved); | ||
function* handlerOf(value) { | ||
return value; | ||
} | ||
function createCachedDescriptors(dirname, options, alias) { | ||
@@ -31,4 +47,4 @@ const { | ||
options, | ||
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => [], | ||
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => [] | ||
plugins: plugins ? () => createCachedPluginDescriptors(plugins, dirname)(alias) : () => handlerOf([]), | ||
presets: presets ? () => createCachedPresetDescriptors(presets, dirname)(alias)(!!passPerPreset) : () => handlerOf([]) | ||
}; | ||
@@ -42,5 +58,6 @@ } | ||
options, | ||
plugins: () => { | ||
*plugins() { | ||
if (!plugins) { | ||
plugins = createPluginDescriptors(options.plugins || [], dirname, alias); | ||
plugins = yield* createPluginDescriptors(options.plugins || [], dirname, alias); | ||
} | ||
@@ -50,5 +67,6 @@ | ||
}, | ||
presets: () => { | ||
*presets() { | ||
if (!presets) { | ||
presets = createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset); | ||
presets = yield* createPresetDescriptors(options.presets || [], dirname, alias, !!options.passPerPreset); | ||
} | ||
@@ -58,2 +76,3 @@ | ||
} | ||
}; | ||
@@ -65,3 +84,6 @@ } | ||
const dirname = cache.using(dir => dir); | ||
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCacheSync)(passPerPreset => createPresetDescriptors(items, dirname, alias, passPerPreset).map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc)))); | ||
return (0, _caching.makeStrongCacheSync)(alias => (0, _caching.makeStrongCache)(function* (passPerPreset) { | ||
const descriptors = yield* createPresetDescriptors(items, dirname, alias, passPerPreset); | ||
return descriptors.map(desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc)); | ||
})); | ||
}); | ||
@@ -71,3 +93,6 @@ const PLUGIN_DESCRIPTOR_CACHE = new WeakMap(); | ||
const dirname = cache.using(dir => dir); | ||
return (0, _caching.makeStrongCacheSync)(alias => createPluginDescriptors(items, dirname, alias).map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc))); | ||
return (0, _caching.makeStrongCache)(function* (alias) { | ||
const descriptors = yield* createPluginDescriptors(items, dirname, alias); | ||
return descriptors.map(desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc)); | ||
}); | ||
}); | ||
@@ -109,16 +134,16 @@ const DEFAULT_OPTIONS = {}; | ||
function createPresetDescriptors(items, dirname, alias, passPerPreset) { | ||
return createDescriptors("preset", items, dirname, alias, passPerPreset); | ||
function* createPresetDescriptors(items, dirname, alias, passPerPreset) { | ||
return yield* createDescriptors("preset", items, dirname, alias, passPerPreset); | ||
} | ||
function createPluginDescriptors(items, dirname, alias) { | ||
return createDescriptors("plugin", items, dirname, alias); | ||
function* createPluginDescriptors(items, dirname, alias) { | ||
return yield* createDescriptors("plugin", items, dirname, alias); | ||
} | ||
function createDescriptors(type, items, dirname, alias, ownPass) { | ||
const descriptors = items.map((item, index) => createDescriptor(item, dirname, { | ||
function* createDescriptors(type, items, dirname, alias, ownPass) { | ||
const descriptors = yield* _gensync().default.all(items.map((item, index) => createDescriptor(item, dirname, { | ||
type, | ||
alias: `${alias}$${index}`, | ||
ownPass: !!ownPass | ||
})); | ||
}))); | ||
assertNoDuplicates(descriptors); | ||
@@ -128,3 +153,3 @@ return descriptors; | ||
function createDescriptor(pair, dirname, { | ||
function* createDescriptor(pair, dirname, { | ||
type, | ||
@@ -165,3 +190,3 @@ alias, | ||
value | ||
} = resolver(value, dirname)); | ||
} = yield* resolver(value, dirname)); | ||
file = { | ||
@@ -168,0 +193,0 @@ request, |
@@ -55,3 +55,3 @@ "use strict"; | ||
var _configApi = _interopRequireDefault(require("../helpers/config-api")); | ||
var _configApi = require("../helpers/config-api"); | ||
@@ -213,3 +213,3 @@ var _utils = require("./utils"); | ||
yield* []; | ||
options = options((0, _configApi.default)(cache)); | ||
options = options((0, _configApi.makeConfigAPI)(cache)); | ||
assertCache = true; | ||
@@ -216,0 +216,0 @@ } |
@@ -42,10 +42,10 @@ "use strict"; | ||
function* loadCjsOrMjsDefault(filepath, asyncError) { | ||
function* loadCjsOrMjsDefault(filepath, asyncError, fallbackToTranspiledModule = false) { | ||
switch (guessJSModuleType(filepath)) { | ||
case "cjs": | ||
return loadCjsDefault(filepath); | ||
return loadCjsDefault(filepath, fallbackToTranspiledModule); | ||
case "unknown": | ||
try { | ||
return loadCjsDefault(filepath); | ||
return loadCjsDefault(filepath, fallbackToTranspiledModule); | ||
} catch (e) { | ||
@@ -77,6 +77,6 @@ if (e.code !== "ERR_REQUIRE_ESM") throw e; | ||
function loadCjsDefault(filepath) { | ||
function loadCjsDefault(filepath, fallbackToTranspiledModule) { | ||
const module = require(filepath); | ||
return (module == null ? void 0 : module.__esModule) ? module.default || undefined : module; | ||
return (module == null ? void 0 : module.__esModule) ? module.default || (fallbackToTranspiledModule ? module : undefined) : module; | ||
} | ||
@@ -83,0 +83,0 @@ |
@@ -31,2 +31,4 @@ "use strict"; | ||
var _moduleTypes = _interopRequireDefault(require("./module-types")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -52,3 +54,3 @@ | ||
function loadPlugin(name, dirname) { | ||
function* loadPlugin(name, dirname) { | ||
const filepath = resolvePlugin(name, dirname); | ||
@@ -60,3 +62,3 @@ | ||
const value = requireModule("plugin", filepath); | ||
const value = yield* requireModule("plugin", filepath); | ||
debug("Loaded plugin %o from %o.", name, dirname); | ||
@@ -69,3 +71,3 @@ return { | ||
function loadPreset(name, dirname) { | ||
function* loadPreset(name, dirname) { | ||
const filepath = resolvePreset(name, dirname); | ||
@@ -77,3 +79,3 @@ | ||
const value = requireModule("preset", filepath); | ||
const value = yield* requireModule("preset", filepath); | ||
debug("Loaded preset %o from %o.", name, dirname); | ||
@@ -186,3 +188,3 @@ return { | ||
function requireModule(type, name) { | ||
function* requireModule(type, name) { | ||
if (LOADING_MODULES.has(name)) { | ||
@@ -194,3 +196,6 @@ 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.'); | ||
LOADING_MODULES.add(name); | ||
return require(name); | ||
return yield* (0, _moduleTypes.default)(name, `You appear to be using a native ECMAScript module ${type}, ` + "which is only supported when running Babel asynchronously.", true); | ||
} catch (err) { | ||
err.message = `[BABEL]: ${err.message} (While processing: ${name})`; | ||
throw err; | ||
} finally { | ||
@@ -197,0 +202,0 @@ LOADING_MODULES.delete(name); |
@@ -46,6 +46,8 @@ "use strict"; | ||
var _configApi = _interopRequireDefault(require("./helpers/config-api")); | ||
var _configApi = require("./helpers/config-api"); | ||
var _partial = _interopRequireDefault(require("./partial")); | ||
var Context = _interopRequireWildcard(require("./cache-contexts")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
@@ -58,2 +60,4 @@ | ||
var _default = (0, _gensync().default)(function* loadFullConfig(inputOpts) { | ||
var _options$assumptions; | ||
const result = yield* (0, _partial.default)(inputOpts); | ||
@@ -85,2 +89,7 @@ | ||
const pluginContext = Object.assign({}, context, { | ||
targets: options.targets, | ||
assumptions: (_options$assumptions = options.assumptions) != null ? _options$assumptions : {} | ||
}); | ||
const toDescriptor = item => { | ||
@@ -110,3 +119,3 @@ const desc = (0, _item.getItemDescriptor)(item); | ||
presets.push({ | ||
preset: yield* loadPresetDescriptor(descriptor, context), | ||
preset: yield* loadPresetDescriptor(descriptor, pluginContext), | ||
pass: [] | ||
@@ -116,3 +125,3 @@ }); | ||
presets.unshift({ | ||
preset: yield* loadPresetDescriptor(descriptor, context), | ||
preset: yield* loadPresetDescriptor(descriptor, pluginContext), | ||
pass: pluginDescriptorsPass | ||
@@ -163,3 +172,3 @@ }); | ||
try { | ||
pass.push(yield* loadPluginDescriptor(descriptor, context)); | ||
pass.push(yield* loadPluginDescriptor(descriptor, pluginContext)); | ||
} catch (e) { | ||
@@ -203,3 +212,3 @@ if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") { | ||
const loadDescriptor = (0, _caching.makeWeakCache)(function* ({ | ||
const makeDescriptorLoader = apiFactory => (0, _caching.makeWeakCache)(function* ({ | ||
value, | ||
@@ -215,6 +224,7 @@ options, | ||
if (typeof value === "function") { | ||
const api = Object.assign({}, context, (0, _configApi.default)(cache)); | ||
const factory = (0, _async.maybeAsync)(value, `You appear to be using an async plugin/preset, but Babel has been called synchronously`); | ||
const api = Object.assign({}, context, apiFactory(cache)); | ||
try { | ||
item = value(api, options, dirname); | ||
item = yield* factory(api, options, dirname); | ||
} catch (e) { | ||
@@ -233,5 +243,5 @@ if (alias) { | ||
if (typeof item.then === "function") { | ||
if ((0, _async.isThenable)(item)) { | ||
yield* []; | ||
throw new Error(`You appear to be using an async plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version.`); | ||
throw new Error(`You appear to be using a promise as a plugin, ` + `which your current version of Babel does not support. ` + `If you're using a published plugin, ` + `you may need to upgrade your @babel/core version. ` + `As an alternative, you can prefix the promise with "await". ` + `(While processing: ${JSON.stringify(alias)})`); | ||
} | ||
@@ -247,2 +257,5 @@ | ||
const pluginDescriptorLoader = makeDescriptorLoader(_configApi.makePluginAPI); | ||
const presetDescriptorLoader = makeDescriptorLoader(_configApi.makePresetAPI); | ||
function* loadPluginDescriptor(descriptor, context) { | ||
@@ -257,3 +270,3 @@ if (descriptor.value instanceof _plugin.default) { | ||
return yield* instantiatePlugin(yield* loadDescriptor(descriptor, context), context); | ||
return yield* instantiatePlugin(yield* pluginDescriptorLoader(descriptor, context), context); | ||
} | ||
@@ -315,3 +328,3 @@ | ||
function* loadPresetDescriptor(descriptor, context) { | ||
const preset = instantiatePreset(yield* loadDescriptor(descriptor, context)); | ||
const preset = instantiatePreset(yield* presetDescriptorLoader(descriptor, context)); | ||
validatePreset(preset, context, descriptor); | ||
@@ -318,0 +331,0 @@ return yield* (0, _configChain.buildPresetChain)(preset, context); |
@@ -6,3 +6,5 @@ "use strict"; | ||
}); | ||
exports.default = makeAPI; | ||
exports.makeConfigAPI = makeConfigAPI; | ||
exports.makePresetAPI = makePresetAPI; | ||
exports.makePluginAPI = makePluginAPI; | ||
@@ -23,5 +25,11 @@ function _semver() { | ||
var Context = _interopRequireWildcard(require("../cache-contexts")); | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function makeAPI(cache) { | ||
function makeConfigAPI(cache) { | ||
const env = value => cache.using(data => { | ||
@@ -56,2 +64,18 @@ if (typeof value === "undefined") return data.envName; | ||
function makePresetAPI(cache) { | ||
const targets = () => JSON.parse(cache.using(data => JSON.stringify(data.targets))); | ||
return Object.assign({}, makeConfigAPI(cache), { | ||
targets | ||
}); | ||
} | ||
function makePluginAPI(cache) { | ||
const assumption = name => cache.using(data => data.assumptions[name]); | ||
return Object.assign({}, makePresetAPI(cache), { | ||
assumption | ||
}); | ||
} | ||
function assertVersion(range) { | ||
@@ -58,0 +82,0 @@ if (typeof range === "number") { |
@@ -28,7 +28,7 @@ "use strict"; | ||
function createConfigItem(value, { | ||
function* createConfigItem(value, { | ||
dirname = ".", | ||
type | ||
} = {}) { | ||
const descriptor = (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), { | ||
const descriptor = yield* (0, _configDescriptors.createDescriptor)(value, _path().default.resolve(dirname), { | ||
type, | ||
@@ -35,0 +35,0 @@ alias: "programmatic item" |
@@ -43,2 +43,4 @@ "use strict"; | ||
var _resolveTargets = require("./resolve-targets"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -104,16 +106,22 @@ | ||
if (!configChain) return null; | ||
const options = {}; | ||
const merged = { | ||
assumptions: {} | ||
}; | ||
configChain.options.forEach(opts => { | ||
(0, _util.mergeOptions)(options, opts); | ||
(0, _util.mergeOptions)(merged, opts); | ||
}); | ||
options.cloneInputAst = cloneInputAst; | ||
options.babelrc = false; | ||
options.configFile = false; | ||
options.passPerPreset = false; | ||
options.envName = context.envName; | ||
options.cwd = context.cwd; | ||
options.root = context.root; | ||
options.filename = typeof context.filename === "string" ? context.filename : undefined; | ||
options.plugins = configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)); | ||
options.presets = configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)); | ||
const options = Object.assign({}, merged, { | ||
targets: (0, _resolveTargets.resolveTargets)(merged, absoluteRootDir, filename), | ||
cloneInputAst, | ||
babelrc: false, | ||
configFile: false, | ||
browserslistConfigFile: false, | ||
passPerPreset: false, | ||
envName: context.envName, | ||
cwd: context.cwd, | ||
root: context.root, | ||
filename: typeof context.filename === "string" ? context.filename : undefined, | ||
plugins: configChain.plugins.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)), | ||
presets: configChain.presets.map(descriptor => (0, _item.createItemFromDescriptor)(descriptor)) | ||
}); | ||
return { | ||
@@ -120,0 +128,0 @@ options, |
@@ -7,2 +7,15 @@ "use strict"; | ||
exports.ConfigPrinter = exports.ChainFormatter = void 0; | ||
function _gensync() { | ||
const data = _interopRequireDefault(require("gensync")); | ||
_gensync = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const ChainFormatter = { | ||
@@ -44,7 +57,7 @@ Programmatic: 0, | ||
optionsAndDescriptors(opt) { | ||
*optionsAndDescriptors(opt) { | ||
const content = Object.assign({}, opt.options); | ||
delete content.overrides; | ||
delete content.env; | ||
const pluginDescriptors = [...opt.plugins()]; | ||
const pluginDescriptors = [...(yield* opt.plugins())]; | ||
@@ -55,3 +68,3 @@ if (pluginDescriptors.length) { | ||
const presetDescriptors = [...opt.presets()]; | ||
const presetDescriptors = [...(yield* opt.presets())]; | ||
@@ -115,13 +128,14 @@ if (presetDescriptors.length) { | ||
static format(config) { | ||
static *format(config) { | ||
let title = Formatter.title(config.type, config.callerName, config.filepath); | ||
const loc = Formatter.loc(config.index, config.envName); | ||
if (loc) title += ` ${loc}`; | ||
const content = Formatter.optionsAndDescriptors(config.content); | ||
const content = yield* Formatter.optionsAndDescriptors(config.content); | ||
return `${title}\n${content}`; | ||
} | ||
output() { | ||
*output() { | ||
if (this._stack.length === 0) return ""; | ||
return this._stack.map(s => ConfigPrinter.format(s)).join("\n\n"); | ||
const configs = yield* _gensync().default.all(this._stack.map(s => ConfigPrinter.format(s))); | ||
return configs.join("\n\n"); | ||
} | ||
@@ -128,0 +142,0 @@ |
@@ -11,10 +11,6 @@ "use strict"; | ||
for (const k of Object.keys(source)) { | ||
if (k === "parserOpts" && source.parserOpts) { | ||
const parserOpts = source.parserOpts; | ||
const targetObj = target.parserOpts = target.parserOpts || {}; | ||
if ((k === "parserOpts" || k === "generatorOpts" || k === "assumptions") && source[k]) { | ||
const parserOpts = source[k]; | ||
const targetObj = target[k] || (target[k] = {}); | ||
mergeDefaultFields(targetObj, parserOpts); | ||
} else if (k === "generatorOpts" && source.generatorOpts) { | ||
const generatorOpts = source.generatorOpts; | ||
const targetObj = target.generatorOpts = target.generatorOpts || {}; | ||
mergeDefaultFields(targetObj, generatorOpts); | ||
} else { | ||
@@ -21,0 +17,0 @@ const val = source[k]; |
@@ -24,3 +24,17 @@ "use strict"; | ||
exports.assertPluginList = assertPluginList; | ||
exports.assertTargets = assertTargets; | ||
exports.assertAssumptions = assertAssumptions; | ||
function _helperCompilationTargets() { | ||
const data = require("@babel/helper-compilation-targets"); | ||
_helperCompilationTargets = function () { | ||
return data; | ||
}; | ||
return data; | ||
} | ||
var _options = require("./options"); | ||
function msg(loc) { | ||
@@ -269,2 +283,72 @@ switch (loc.type) { | ||
return value; | ||
} | ||
function assertTargets(loc, value) { | ||
if ((0, _helperCompilationTargets().isBrowsersQueryValid)(value)) return value; | ||
if (typeof value !== "object" || !value || Array.isArray(value)) { | ||
throw new Error(`${msg(loc)} must be a string, an array of strings or an object`); | ||
} | ||
const browsersLoc = access(loc, "browsers"); | ||
const esmodulesLoc = access(loc, "esmodules"); | ||
assertBrowsersList(browsersLoc, value.browsers); | ||
assertBoolean(esmodulesLoc, value.esmodules); | ||
for (const key of Object.keys(value)) { | ||
const val = value[key]; | ||
const subLoc = access(loc, key); | ||
if (key === "esmodules") assertBoolean(subLoc, val);else if (key === "browsers") assertBrowsersList(subLoc, val);else if (!Object.hasOwnProperty.call(_helperCompilationTargets().TargetNames, key)) { | ||
const validTargets = Object.keys(_helperCompilationTargets().TargetNames).join(", "); | ||
throw new Error(`${msg(subLoc)} is not a valid target. Supported targets are ${validTargets}`); | ||
} else assertBrowserVersion(subLoc, val); | ||
} | ||
return value; | ||
} | ||
function assertBrowsersList(loc, value) { | ||
if (value !== undefined && !(0, _helperCompilationTargets().isBrowsersQueryValid)(value)) { | ||
throw new Error(`${msg(loc)} must be undefined, a string or an array of strings`); | ||
} | ||
} | ||
function assertBrowserVersion(loc, value) { | ||
if (typeof value === "number" && Math.round(value) === value) return; | ||
if (typeof value === "string") return; | ||
throw new Error(`${msg(loc)} must be a string or an integer number`); | ||
} | ||
function assertAssumptions(loc, value) { | ||
if (value === undefined) return; | ||
if (typeof value !== "object" || value === null) { | ||
throw new Error(`${msg(loc)} must be an object or undefined.`); | ||
} | ||
let root = loc; | ||
do { | ||
root = root.parent; | ||
} while (root.type !== "root"); | ||
const inPreset = root.source === "preset"; | ||
for (const name of Object.keys(value)) { | ||
const subLoc = access(loc, name); | ||
if (!_options.assumptionsNames.has(name)) { | ||
throw new Error(`${msg(subLoc)} is not a supported assumption.`); | ||
} | ||
if (typeof value[name] !== "boolean") { | ||
throw new Error(`${msg(subLoc)} must be a boolean.`); | ||
} | ||
if (inPreset && value[name] === false) { | ||
throw new Error(`${msg(subLoc)} cannot be set to 'false' inside presets.`); | ||
} | ||
} | ||
return value; | ||
} |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.checkNoUnwrappedItemOptionPairs = checkNoUnwrappedItemOptionPairs; | ||
exports.assumptionsNames = void 0; | ||
@@ -38,3 +39,6 @@ var _plugin = _interopRequireDefault(require("../plugin")); | ||
ignore: _optionAssertions.assertIgnoreList, | ||
only: _optionAssertions.assertIgnoreList | ||
only: _optionAssertions.assertIgnoreList, | ||
targets: _optionAssertions.assertTargets, | ||
browserslistConfigFile: _optionAssertions.assertConfigFileSearch, | ||
browserslistEnv: _optionAssertions.assertString | ||
}; | ||
@@ -46,2 +50,3 @@ const COMMON_VALIDATORS = { | ||
passPerPreset: _optionAssertions.assertBoolean, | ||
assumptions: _optionAssertions.assertAssumptions, | ||
env: assertEnvSet, | ||
@@ -73,2 +78,4 @@ overrides: assertOverridesList, | ||
}; | ||
const assumptionsNames = new Set(["arrayLikeIsIterable", "constantReexports", "constantSuper", "enumerableModuleMeta", "ignoreFunctionLength", "ignoreToPrimitiveHint", "iterableIsArray", "mutableTemplateObject", "noClassCalls", "noDocumentAll", "noNewArrows", "objectRestNoSymbols", "privateFieldsAsProperties", "pureGetters", "setClassMethods", "setComputedProperties", "setPublicClassFields", "setSpreadProperties", "skipForOfIteratorClosing", "superIsCallableConstructor"]); | ||
exports.assumptionsNames = assumptionsNames; | ||
@@ -75,0 +82,0 @@ function getSource(loc) { |
@@ -244,5 +244,5 @@ "use strict"; | ||
const version = "7.12.17"; | ||
const version = "7.13.0"; | ||
exports.version = version; | ||
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs"]); | ||
const DEFAULT_EXTENSIONS = Object.freeze([".js", ".jsx", ".es6", ".es", ".mjs", ".cjs"]); | ||
exports.DEFAULT_EXTENSIONS = DEFAULT_EXTENSIONS; | ||
@@ -249,0 +249,0 @@ |
{ | ||
"name": "@babel/core", | ||
"version": "7.12.17", | ||
"version": "7.13.0", | ||
"description": "Babel compiler core.", | ||
@@ -42,4 +42,6 @@ "main": "lib/index.js", | ||
"./lib/config/files/index.js": "./lib/config/files/index-browser.js", | ||
"./lib/config/resolve-targets.js": "./lib/config/resolve-targets-browser.js", | ||
"./lib/transform-file.js": "./lib/transform-file-browser.js", | ||
"./src/config/files/index.js": "./src/config/files/index-browser.js", | ||
"./src/config/resolve-targets.js": "./src/config/resolve-targets-browser.js", | ||
"./src/transform-file.js": "./src/transform-file-browser.js" | ||
@@ -49,20 +51,21 @@ }, | ||
"@babel/code-frame": "^7.12.13", | ||
"@babel/generator": "^7.12.17", | ||
"@babel/helper-module-transforms": "^7.12.17", | ||
"@babel/helpers": "^7.12.17", | ||
"@babel/parser": "^7.12.17", | ||
"@babel/generator": "^7.13.0", | ||
"@babel/helper-compilation-targets": "^7.13.0", | ||
"@babel/helper-module-transforms": "^7.13.0", | ||
"@babel/helpers": "^7.13.0", | ||
"@babel/parser": "^7.13.0", | ||
"@babel/template": "^7.12.13", | ||
"@babel/traverse": "^7.12.17", | ||
"@babel/types": "^7.12.17", | ||
"@babel/traverse": "^7.13.0", | ||
"@babel/types": "^7.13.0", | ||
"convert-source-map": "^1.7.0", | ||
"debug": "^4.1.0", | ||
"gensync": "^1.0.0-beta.1", | ||
"gensync": "^1.0.0-beta.2", | ||
"json5": "^2.1.2", | ||
"lodash": "^4.17.19", | ||
"semver": "^5.4.1", | ||
"semver": "7.0.0", | ||
"source-map": "^0.5.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/helper-transform-fixture-test-runner": "7.12.17" | ||
"@babel/helper-transform-fixture-test-runner": "7.13.0" | ||
} | ||
} |
@@ -83,3 +83,3 @@ // @flow | ||
dirname: string, | ||
): { filepath: string, value: mixed } { | ||
): Handler<{ filepath: string, value: mixed }> { | ||
throw new Error( | ||
@@ -93,3 +93,3 @@ `Cannot load plugin ${name} relative to ${dirname} in a browser`, | ||
dirname: string, | ||
): { filepath: string, value: mixed } { | ||
): Handler<{ filepath: string, value: mixed }> { | ||
throw new Error( | ||
@@ -96,0 +96,0 @@ `Cannot load preset ${name} relative to ${dirname} in a browser`, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
183936
58
5182
10
16
+ Added@babel/compat-data@7.26.2(transitive)
+ Added@babel/helper-compilation-targets@7.25.9(transitive)
+ Added@babel/helper-validator-option@7.25.9(transitive)
+ Addedbrowserslist@4.24.2(transitive)
+ Addedcaniuse-lite@1.0.30001680(transitive)
+ Addedelectron-to-chromium@1.5.62(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addednode-releases@2.0.18(transitive)
+ Addedsemver@6.3.17.0.0(transitive)
+ Addedupdate-browserslist-db@1.1.1(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedsemver@5.7.2(transitive)
Updated@babel/generator@^7.13.0
Updated@babel/helpers@^7.13.0
Updated@babel/parser@^7.13.0
Updated@babel/traverse@^7.13.0
Updated@babel/types@^7.13.0
Updatedgensync@^1.0.0-beta.2
Updatedsemver@7.0.0