@babel/preset-env
Advanced tools
Comparing version 7.11.5 to 7.12.0
@@ -8,10 +8,6 @@ "use strict"; | ||
exports.default = normalizeOptions; | ||
exports.validateUseBuiltInsOption = exports.validateModulesOption = exports.validateIgnoreBrowserslistConfig = exports.validateStringOption = exports.validateBoolOption = exports.validateConfigPathOption = exports.checkDuplicateIncludeExcludes = exports.normalizePluginName = void 0; | ||
exports.validateUseBuiltInsOption = exports.validateModulesOption = exports.checkDuplicateIncludeExcludes = exports.normalizePluginName = void 0; | ||
var _data = _interopRequireDefault(require("core-js-compat/data")); | ||
var _levenary = _interopRequireDefault(require("levenary")); | ||
var _invariant = _interopRequireDefault(require("invariant")); | ||
var _semver = require("semver"); | ||
@@ -27,17 +23,11 @@ | ||
var _helperValidatorOption = require("@babel/helper-validator-option"); | ||
var _getPlatformSpecificDefault = require("./polyfills/corejs2/get-platform-specific-default"); | ||
var _package = require("../package.json"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const validateTopLevelOptions = options => { | ||
const validOptions = Object.keys(_options.TopLevelOptions); | ||
for (const option in options) { | ||
if (!_options.TopLevelOptions[option]) { | ||
throw new Error(`Invalid Option: ${option} is not a valid top-level option. | ||
Maybe you meant to use '${(0, _levenary.default)(option, validOptions)}'?`); | ||
} | ||
} | ||
}; | ||
const v = new _helperValidatorOption.OptionValidator(_package.name); | ||
const allPluginsList = Object.keys(_pluginsCompatData.plugins); | ||
@@ -66,3 +56,3 @@ const modulePlugins = ["proposal-dynamic-import", ...Object.keys(_moduleTransformations.default).map(m => _moduleTransformations.default[m])]; | ||
const invalidRegExpList = plugins.filter((p, i) => selectedPlugins[i].length === 0); | ||
(0, _invariant.default)(invalidRegExpList.length === 0, `Invalid Option: The plugins/built-ins '${invalidRegExpList.join(", ")}' passed to the '${type}' option are not | ||
v.invariant(invalidRegExpList.length === 0, `The plugins/built-ins '${invalidRegExpList.join(", ")}' passed to the '${type}' option are not | ||
valid. Please check data/[plugin-features|built-in-features].js in babel-preset-env`); | ||
@@ -78,3 +68,3 @@ return flatten(selectedPlugins); | ||
const duplicates = include.filter(opt => exclude.indexOf(opt) >= 0); | ||
(0, _invariant.default)(duplicates.length === 0, `Invalid Option: The plugins/built-ins '${duplicates.join(", ")}' were found in both the "include" and | ||
v.invariant(duplicates.length === 0, `The plugins/built-ins '${duplicates.join(", ")}' were found in both the "include" and | ||
"exclude" options.`); | ||
@@ -95,41 +85,4 @@ }; | ||
const validateConfigPathOption = (configPath = process.cwd()) => { | ||
(0, _invariant.default)(typeof configPath === "string", `Invalid Option: The configPath option '${configPath}' is invalid, only strings are allowed.`); | ||
return configPath; | ||
}; | ||
exports.validateConfigPathOption = validateConfigPathOption; | ||
const validateBoolOption = (name, value, defaultValue) => { | ||
if (typeof value === "undefined") { | ||
value = defaultValue; | ||
} | ||
if (typeof value !== "boolean") { | ||
throw new Error(`Preset env: '${name}' option must be a boolean.`); | ||
} | ||
return value; | ||
}; | ||
exports.validateBoolOption = validateBoolOption; | ||
const validateStringOption = (name, value, defaultValue) => { | ||
if (typeof value === "undefined") { | ||
value = defaultValue; | ||
} else if (typeof value !== "string") { | ||
throw new Error(`Preset env: '${name}' option must be a string.`); | ||
} | ||
return value; | ||
}; | ||
exports.validateStringOption = validateStringOption; | ||
const validateIgnoreBrowserslistConfig = ignoreBrowserslistConfig => validateBoolOption(_options.TopLevelOptions.ignoreBrowserslistConfig, ignoreBrowserslistConfig, false); | ||
exports.validateIgnoreBrowserslistConfig = validateIgnoreBrowserslistConfig; | ||
const validateModulesOption = (modulesOpt = _options.ModulesOption.auto) => { | ||
(0, _invariant.default)(_options.ModulesOption[modulesOpt.toString()] || modulesOpt === _options.ModulesOption.false, `Invalid Option: The 'modules' option must be one of \n` + ` - 'false' to indicate no module processing\n` + ` - a specific module type: 'commonjs', 'amd', 'umd', 'systemjs'` + ` - 'auto' (default) which will automatically select 'false' if the current\n` + ` process is known to support ES module syntax, or "commonjs" otherwise\n`); | ||
v.invariant(_options.ModulesOption[modulesOpt.toString()] || modulesOpt === _options.ModulesOption.false, `The 'modules' option must be one of \n` + ` - 'false' to indicate no module processing\n` + ` - a specific module type: 'commonjs', 'amd', 'umd', 'systemjs'` + ` - 'auto' (default) which will automatically select 'false' if the current\n` + ` process is known to support ES module syntax, or "commonjs" otherwise\n`); | ||
return modulesOpt; | ||
@@ -141,3 +94,3 @@ }; | ||
const validateUseBuiltInsOption = (builtInsOpt = false) => { | ||
(0, _invariant.default)(_options.UseBuiltInsOption[builtInsOpt.toString()] || builtInsOpt === _options.UseBuiltInsOption.false, `Invalid Option: The 'useBuiltIns' option must be either | ||
v.invariant(_options.UseBuiltInsOption[builtInsOpt.toString()] || builtInsOpt === _options.UseBuiltInsOption.false, `The 'useBuiltIns' option must be either | ||
'false' (default) to indicate no polyfill, | ||
@@ -182,3 +135,3 @@ '"entry"' to indicate replacing the entry polyfill, or | ||
function normalizeOptions(opts) { | ||
validateTopLevelOptions(opts); | ||
v.validateTopLevelOptions(opts, _options.TopLevelOptions); | ||
const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns); | ||
@@ -189,20 +142,19 @@ const corejs = normalizeCoreJSOption(opts.corejs, useBuiltIns); | ||
checkDuplicateIncludeExcludes(include, exclude); | ||
const shippedProposals = validateBoolOption(_options.TopLevelOptions.shippedProposals, opts.shippedProposals, false); | ||
return { | ||
bugfixes: validateBoolOption(_options.TopLevelOptions.bugfixes, opts.bugfixes, false), | ||
configPath: validateConfigPathOption(opts.configPath), | ||
bugfixes: v.validateBooleanOption(_options.TopLevelOptions.bugfixes, opts.bugfixes, false), | ||
configPath: v.validateStringOption(_options.TopLevelOptions.configPath, opts.configPath, process.cwd()), | ||
corejs, | ||
debug: validateBoolOption(_options.TopLevelOptions.debug, opts.debug, false), | ||
debug: v.validateBooleanOption(_options.TopLevelOptions.debug, opts.debug, false), | ||
include, | ||
exclude, | ||
forceAllTransforms: validateBoolOption(_options.TopLevelOptions.forceAllTransforms, opts.forceAllTransforms, false), | ||
ignoreBrowserslistConfig: validateIgnoreBrowserslistConfig(opts.ignoreBrowserslistConfig), | ||
loose: validateBoolOption(_options.TopLevelOptions.loose, opts.loose, false), | ||
forceAllTransforms: v.validateBooleanOption(_options.TopLevelOptions.forceAllTransforms, opts.forceAllTransforms, false), | ||
ignoreBrowserslistConfig: v.validateBooleanOption(_options.TopLevelOptions.ignoreBrowserslistConfig, opts.ignoreBrowserslistConfig, false), | ||
loose: v.validateBooleanOption(_options.TopLevelOptions.loose, opts.loose, false), | ||
modules: validateModulesOption(opts.modules), | ||
shippedProposals, | ||
spec: validateBoolOption(_options.TopLevelOptions.spec, opts.spec, false), | ||
shippedProposals: v.validateBooleanOption(_options.TopLevelOptions.shippedProposals, opts.shippedProposals, false), | ||
spec: v.validateBooleanOption(_options.TopLevelOptions.spec, opts.spec, false), | ||
targets: normalizeTargets(opts.targets), | ||
useBuiltIns: useBuiltIns, | ||
browserslistEnv: validateStringOption(_options.TopLevelOptions.browserslistEnv, opts.browserslistEnv) | ||
browserslistEnv: v.validateStringOption(_options.TopLevelOptions.browserslistEnv, opts.browserslistEnv) | ||
}; | ||
} |
{ | ||
"name": "@babel/preset-env", | ||
"version": "7.11.5", | ||
"version": "7.12.0", | ||
"description": "A Babel preset for each environment.", | ||
@@ -18,17 +18,18 @@ "author": "Henry Zhu <hi@henryzoo.com>", | ||
"dependencies": { | ||
"@babel/compat-data": "^7.11.0", | ||
"@babel/helper-compilation-targets": "^7.10.4", | ||
"@babel/compat-data": "^7.12.0", | ||
"@babel/helper-compilation-targets": "^7.12.0", | ||
"@babel/helper-module-imports": "^7.10.4", | ||
"@babel/helper-plugin-utils": "^7.10.4", | ||
"@babel/helper-validator-option": "^7.12.0", | ||
"@babel/plugin-proposal-async-generator-functions": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-dynamic-import": "^7.10.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.10.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.12.0", | ||
"@babel/plugin-proposal-json-strings": "^7.10.4", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.11.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4", | ||
"@babel/plugin-proposal-numeric-separator": "^7.10.4", | ||
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.0", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.0", | ||
"@babel/plugin-proposal-numeric-separator": "^7.12.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.11.0", | ||
"@babel/plugin-proposal-optional-catch-binding": "^7.10.4", | ||
"@babel/plugin-proposal-optional-chaining": "^7.11.0", | ||
"@babel/plugin-proposal-optional-chaining": "^7.12.0", | ||
"@babel/plugin-proposal-private-methods": "^7.10.4", | ||
@@ -64,3 +65,3 @@ "@babel/plugin-proposal-unicode-property-regex": "^7.10.4", | ||
"@babel/plugin-transform-modules-commonjs": "^7.10.4", | ||
"@babel/plugin-transform-modules-systemjs": "^7.10.4", | ||
"@babel/plugin-transform-modules-systemjs": "^7.12.0", | ||
"@babel/plugin-transform-modules-umd": "^7.10.4", | ||
@@ -82,7 +83,5 @@ "@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4", | ||
"@babel/preset-modules": "^0.1.3", | ||
"@babel/types": "^7.11.5", | ||
"@babel/types": "^7.12.0", | ||
"browserslist": "^4.12.0", | ||
"core-js-compat": "^3.6.2", | ||
"invariant": "^2.2.2", | ||
"levenary": "^1.1.1", | ||
"semver": "^5.5.0" | ||
@@ -94,9 +93,8 @@ }, | ||
"devDependencies": { | ||
"@babel/cli": "^7.11.5", | ||
"@babel/core": "^7.11.5", | ||
"@babel/cli": "^7.12.0", | ||
"@babel/core": "^7.12.0", | ||
"@babel/helper-fixtures": "^7.10.4", | ||
"@babel/helper-plugin-test-runner": "^7.10.4", | ||
"@babel/plugin-syntax-dynamic-import": "^7.2.0" | ||
}, | ||
"gitHead": "af64ccb2b00bc7574943674996c2f0507cdbfb6f" | ||
} | ||
} |
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
68
92608
1939
- Removedinvariant@^2.2.2
- Removedlevenary@^1.1.1
- Removedinvariant@2.2.4(transitive)
- Removedleven@3.1.0(transitive)
- Removedlevenary@1.1.1(transitive)
- Removedloose-envify@1.4.0(transitive)
Updated@babel/compat-data@^7.12.0
Updated@babel/plugin-proposal-logical-assignment-operators@^7.12.0
Updated@babel/plugin-proposal-nullish-coalescing-operator@^7.12.0
Updated@babel/types@^7.12.0