This commit is contained in:
2022-07-18 02:50:52 +00:00
parent befd344ab0
commit 06181b34d6
8569 changed files with 818704 additions and 352705 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
> A Babel preset for each environment.
See our website [@babel/preset-env](https://babeljs.io/docs/en/next/babel-preset-env.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20preset-env%22+is%3Aopen) associated with this package.
See our website [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20preset-env%22+is%3Aopen) associated with this package.
## Install
+1
View File
@@ -0,0 +1 @@
module.exports = require("core-js-compat/data.json");
+1
View File
@@ -0,0 +1 @@
{ "type": "commonjs" }
+2 -32
View File
@@ -1,32 +1,2 @@
/* eslint sort-keys: "error" */
// These mappings represent the syntax proposals that have been
// shipped by browsers, and are enabled by the `shippedProposals` option.
const proposalPlugins = new Set([
"proposal-class-properties",
"proposal-numeric-separator",
"proposal-private-methods"
]);
// use intermediary object to enforce alphabetical key order
const pluginSyntaxObject = {
"proposal-async-generator-functions": "syntax-async-generators",
"proposal-class-properties": "syntax-class-properties",
"proposal-json-strings": "syntax-json-strings",
"proposal-nullish-coalescing-operator": "syntax-nullish-coalescing-operator",
"proposal-numeric-separator": "syntax-numeric-separator",
"proposal-object-rest-spread": "syntax-object-rest-spread",
"proposal-optional-catch-binding": "syntax-optional-catch-binding",
"proposal-optional-chaining": "syntax-optional-chaining",
// note: we don't have syntax-private-methods
"proposal-private-methods": "syntax-class-properties",
"proposal-unicode-property-regex": null,
};
const pluginSyntaxEntries = Object.keys(pluginSyntaxObject).map(function (key) {
return [key, pluginSyntaxObject[key]];
});
const pluginSyntaxMap = new Map(pluginSyntaxEntries);
module.exports = { pluginSyntaxMap, proposalPlugins };
const { pluginSyntaxMap, proposalPlugins, proposalSyntaxPlugins } = require("../lib/shipped-proposals");
module.exports = { pluginSyntaxMap, proposalPlugins, proposalSyntaxPlugins };
+158 -121
View File
@@ -3,187 +3,224 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.minVersions = exports.default = void 0;
var _pluginSyntaxAsyncGenerators = _interopRequireDefault(require("@babel/plugin-syntax-async-generators"));
var _pluginSyntaxAsyncGenerators = require("@babel/plugin-syntax-async-generators");
var _pluginSyntaxClassProperties = _interopRequireDefault(require("@babel/plugin-syntax-class-properties"));
var _pluginSyntaxClassProperties = require("@babel/plugin-syntax-class-properties");
var _pluginSyntaxDynamicImport = _interopRequireDefault(require("@babel/plugin-syntax-dynamic-import"));
var _pluginSyntaxClassStaticBlock = require("@babel/plugin-syntax-class-static-block");
var _pluginSyntaxJsonStrings = _interopRequireDefault(require("@babel/plugin-syntax-json-strings"));
var _pluginSyntaxDynamicImport = require("@babel/plugin-syntax-dynamic-import");
var _pluginSyntaxNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-syntax-nullish-coalescing-operator"));
var _pluginSyntaxExportNamespaceFrom = require("@babel/plugin-syntax-export-namespace-from");
var _pluginSyntaxNumericSeparator = _interopRequireDefault(require("@babel/plugin-syntax-numeric-separator"));
var _pluginSyntaxImportAssertions = require("@babel/plugin-syntax-import-assertions");
var _pluginSyntaxObjectRestSpread = _interopRequireDefault(require("@babel/plugin-syntax-object-rest-spread"));
var _pluginSyntaxJsonStrings = require("@babel/plugin-syntax-json-strings");
var _pluginSyntaxOptionalCatchBinding = _interopRequireDefault(require("@babel/plugin-syntax-optional-catch-binding"));
var _pluginSyntaxLogicalAssignmentOperators = require("@babel/plugin-syntax-logical-assignment-operators");
var _pluginSyntaxOptionalChaining = _interopRequireDefault(require("@babel/plugin-syntax-optional-chaining"));
var _pluginSyntaxNullishCoalescingOperator = require("@babel/plugin-syntax-nullish-coalescing-operator");
var _pluginSyntaxTopLevelAwait = _interopRequireDefault(require("@babel/plugin-syntax-top-level-await"));
var _pluginSyntaxNumericSeparator = require("@babel/plugin-syntax-numeric-separator");
var _pluginProposalAsyncGeneratorFunctions = _interopRequireDefault(require("@babel/plugin-proposal-async-generator-functions"));
var _pluginSyntaxObjectRestSpread = require("@babel/plugin-syntax-object-rest-spread");
var _pluginProposalClassProperties = _interopRequireDefault(require("@babel/plugin-proposal-class-properties"));
var _pluginSyntaxOptionalCatchBinding = require("@babel/plugin-syntax-optional-catch-binding");
var _pluginProposalDynamicImport = _interopRequireDefault(require("@babel/plugin-proposal-dynamic-import"));
var _pluginSyntaxOptionalChaining = require("@babel/plugin-syntax-optional-chaining");
var _pluginProposalJsonStrings = _interopRequireDefault(require("@babel/plugin-proposal-json-strings"));
var _pluginSyntaxPrivatePropertyInObject = require("@babel/plugin-syntax-private-property-in-object");
var _pluginProposalNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-proposal-nullish-coalescing-operator"));
var _pluginSyntaxTopLevelAwait = require("@babel/plugin-syntax-top-level-await");
var _pluginProposalNumericSeparator = _interopRequireDefault(require("@babel/plugin-proposal-numeric-separator"));
var _pluginProposalAsyncGeneratorFunctions = require("@babel/plugin-proposal-async-generator-functions");
var _pluginProposalObjectRestSpread = _interopRequireDefault(require("@babel/plugin-proposal-object-rest-spread"));
var _pluginProposalClassProperties = require("@babel/plugin-proposal-class-properties");
var _pluginProposalOptionalCatchBinding = _interopRequireDefault(require("@babel/plugin-proposal-optional-catch-binding"));
var _pluginProposalClassStaticBlock = require("@babel/plugin-proposal-class-static-block");
var _pluginProposalOptionalChaining = _interopRequireDefault(require("@babel/plugin-proposal-optional-chaining"));
var _pluginProposalDynamicImport = require("@babel/plugin-proposal-dynamic-import");
var _pluginProposalPrivateMethods = _interopRequireDefault(require("@babel/plugin-proposal-private-methods"));
var _pluginProposalExportNamespaceFrom = require("@babel/plugin-proposal-export-namespace-from");
var _pluginProposalUnicodePropertyRegex = _interopRequireDefault(require("@babel/plugin-proposal-unicode-property-regex"));
var _pluginProposalJsonStrings = require("@babel/plugin-proposal-json-strings");
var _pluginTransformAsyncToGenerator = _interopRequireDefault(require("@babel/plugin-transform-async-to-generator"));
var _pluginProposalLogicalAssignmentOperators = require("@babel/plugin-proposal-logical-assignment-operators");
var _pluginTransformArrowFunctions = _interopRequireDefault(require("@babel/plugin-transform-arrow-functions"));
var _pluginProposalNullishCoalescingOperator = require("@babel/plugin-proposal-nullish-coalescing-operator");
var _pluginTransformBlockScopedFunctions = _interopRequireDefault(require("@babel/plugin-transform-block-scoped-functions"));
var _pluginProposalNumericSeparator = require("@babel/plugin-proposal-numeric-separator");
var _pluginTransformBlockScoping = _interopRequireDefault(require("@babel/plugin-transform-block-scoping"));
var _pluginProposalObjectRestSpread = require("@babel/plugin-proposal-object-rest-spread");
var _pluginTransformClasses = _interopRequireDefault(require("@babel/plugin-transform-classes"));
var _pluginProposalOptionalCatchBinding = require("@babel/plugin-proposal-optional-catch-binding");
var _pluginTransformComputedProperties = _interopRequireDefault(require("@babel/plugin-transform-computed-properties"));
var _pluginProposalOptionalChaining = require("@babel/plugin-proposal-optional-chaining");
var _pluginTransformDestructuring = _interopRequireDefault(require("@babel/plugin-transform-destructuring"));
var _pluginProposalPrivateMethods = require("@babel/plugin-proposal-private-methods");
var _pluginTransformDotallRegex = _interopRequireDefault(require("@babel/plugin-transform-dotall-regex"));
var _pluginProposalPrivatePropertyInObject = require("@babel/plugin-proposal-private-property-in-object");
var _pluginTransformDuplicateKeys = _interopRequireDefault(require("@babel/plugin-transform-duplicate-keys"));
var _pluginProposalUnicodePropertyRegex = require("@babel/plugin-proposal-unicode-property-regex");
var _pluginTransformExponentiationOperator = _interopRequireDefault(require("@babel/plugin-transform-exponentiation-operator"));
var _pluginTransformAsyncToGenerator = require("@babel/plugin-transform-async-to-generator");
var _pluginTransformForOf = _interopRequireDefault(require("@babel/plugin-transform-for-of"));
var _pluginTransformArrowFunctions = require("@babel/plugin-transform-arrow-functions");
var _pluginTransformFunctionName = _interopRequireDefault(require("@babel/plugin-transform-function-name"));
var _pluginTransformBlockScopedFunctions = require("@babel/plugin-transform-block-scoped-functions");
var _pluginTransformLiterals = _interopRequireDefault(require("@babel/plugin-transform-literals"));
var _pluginTransformBlockScoping = require("@babel/plugin-transform-block-scoping");
var _pluginTransformMemberExpressionLiterals = _interopRequireDefault(require("@babel/plugin-transform-member-expression-literals"));
var _pluginTransformClasses = require("@babel/plugin-transform-classes");
var _pluginTransformModulesAmd = _interopRequireDefault(require("@babel/plugin-transform-modules-amd"));
var _pluginTransformComputedProperties = require("@babel/plugin-transform-computed-properties");
var _pluginTransformModulesCommonjs = _interopRequireDefault(require("@babel/plugin-transform-modules-commonjs"));
var _pluginTransformDestructuring = require("@babel/plugin-transform-destructuring");
var _pluginTransformModulesSystemjs = _interopRequireDefault(require("@babel/plugin-transform-modules-systemjs"));
var _pluginTransformDotallRegex = require("@babel/plugin-transform-dotall-regex");
var _pluginTransformModulesUmd = _interopRequireDefault(require("@babel/plugin-transform-modules-umd"));
var _pluginTransformDuplicateKeys = require("@babel/plugin-transform-duplicate-keys");
var _pluginTransformNamedCapturingGroupsRegex = _interopRequireDefault(require("@babel/plugin-transform-named-capturing-groups-regex"));
var _pluginTransformExponentiationOperator = require("@babel/plugin-transform-exponentiation-operator");
var _pluginTransformNewTarget = _interopRequireDefault(require("@babel/plugin-transform-new-target"));
var _pluginTransformForOf = require("@babel/plugin-transform-for-of");
var _pluginTransformObjectSuper = _interopRequireDefault(require("@babel/plugin-transform-object-super"));
var _pluginTransformFunctionName = require("@babel/plugin-transform-function-name");
var _pluginTransformParameters = _interopRequireDefault(require("@babel/plugin-transform-parameters"));
var _pluginTransformLiterals = require("@babel/plugin-transform-literals");
var _pluginTransformPropertyLiterals = _interopRequireDefault(require("@babel/plugin-transform-property-literals"));
var _pluginTransformMemberExpressionLiterals = require("@babel/plugin-transform-member-expression-literals");
var _pluginTransformRegenerator = _interopRequireDefault(require("@babel/plugin-transform-regenerator"));
var _pluginTransformModulesAmd = require("@babel/plugin-transform-modules-amd");
var _pluginTransformReservedWords = _interopRequireDefault(require("@babel/plugin-transform-reserved-words"));
var _pluginTransformModulesCommonjs = require("@babel/plugin-transform-modules-commonjs");
var _pluginTransformShorthandProperties = _interopRequireDefault(require("@babel/plugin-transform-shorthand-properties"));
var _pluginTransformModulesSystemjs = require("@babel/plugin-transform-modules-systemjs");
var _pluginTransformSpread = _interopRequireDefault(require("@babel/plugin-transform-spread"));
var _pluginTransformModulesUmd = require("@babel/plugin-transform-modules-umd");
var _pluginTransformStickyRegex = _interopRequireDefault(require("@babel/plugin-transform-sticky-regex"));
var _pluginTransformNamedCapturingGroupsRegex = require("@babel/plugin-transform-named-capturing-groups-regex");
var _pluginTransformTemplateLiterals = _interopRequireDefault(require("@babel/plugin-transform-template-literals"));
var _pluginTransformNewTarget = require("@babel/plugin-transform-new-target");
var _pluginTransformTypeofSymbol = _interopRequireDefault(require("@babel/plugin-transform-typeof-symbol"));
var _pluginTransformObjectSuper = require("@babel/plugin-transform-object-super");
var _pluginTransformUnicodeEscapes = _interopRequireDefault(require("@babel/plugin-transform-unicode-escapes"));
var _pluginTransformParameters = require("@babel/plugin-transform-parameters");
var _pluginTransformUnicodeRegex = _interopRequireDefault(require("@babel/plugin-transform-unicode-regex"));
var _pluginTransformPropertyLiterals = require("@babel/plugin-transform-property-literals");
var _transformAsyncArrowsInClass = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-async-arrows-in-class"));
var _pluginTransformRegenerator = require("@babel/plugin-transform-regenerator");
var _transformEdgeDefaultParameters = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-edge-default-parameters"));
var _pluginTransformReservedWords = require("@babel/plugin-transform-reserved-words");
var _transformEdgeFunctionName = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-edge-function-name"));
var _pluginTransformShorthandProperties = require("@babel/plugin-transform-shorthand-properties");
var _transformTaggedTemplateCaching = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-tagged-template-caching"));
var _pluginTransformSpread = require("@babel/plugin-transform-spread");
var _transformSafariBlockShadowing = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-safari-block-shadowing"));
var _pluginTransformStickyRegex = require("@babel/plugin-transform-sticky-regex");
var _transformSafariForShadowing = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-safari-for-shadowing"));
var _pluginTransformTemplateLiterals = require("@babel/plugin-transform-template-literals");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _pluginTransformTypeofSymbol = require("@babel/plugin-transform-typeof-symbol");
var _pluginTransformUnicodeEscapes = require("@babel/plugin-transform-unicode-escapes");
var _pluginTransformUnicodeRegex = require("@babel/plugin-transform-unicode-regex");
var _transformAsyncArrowsInClass = require("@babel/preset-modules/lib/plugins/transform-async-arrows-in-class");
var _transformEdgeDefaultParameters = require("@babel/preset-modules/lib/plugins/transform-edge-default-parameters");
var _transformEdgeFunctionName = require("@babel/preset-modules/lib/plugins/transform-edge-function-name");
var _transformTaggedTemplateCaching = require("@babel/preset-modules/lib/plugins/transform-tagged-template-caching");
var _transformSafariBlockShadowing = require("@babel/preset-modules/lib/plugins/transform-safari-block-shadowing");
var _transformSafariForShadowing = require("@babel/preset-modules/lib/plugins/transform-safari-for-shadowing");
var _pluginBugfixSafariIdDestructuringCollisionInFunctionExpression = require("@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression");
var _pluginBugfixV8SpreadParametersInOptionalChaining = require("@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining");
var _default = {
"bugfix/transform-async-arrows-in-class": _transformAsyncArrowsInClass.default,
"bugfix/transform-edge-default-parameters": _transformEdgeDefaultParameters.default,
"bugfix/transform-edge-function-name": _transformEdgeFunctionName.default,
"bugfix/transform-safari-block-shadowing": _transformSafariBlockShadowing.default,
"bugfix/transform-safari-for-shadowing": _transformSafariForShadowing.default,
"bugfix/transform-tagged-template-caching": _transformTaggedTemplateCaching.default,
"proposal-async-generator-functions": _pluginProposalAsyncGeneratorFunctions.default,
"proposal-class-properties": _pluginProposalClassProperties.default,
"proposal-dynamic-import": _pluginProposalDynamicImport.default,
"proposal-json-strings": _pluginProposalJsonStrings.default,
"proposal-nullish-coalescing-operator": _pluginProposalNullishCoalescingOperator.default,
"proposal-numeric-separator": _pluginProposalNumericSeparator.default,
"proposal-object-rest-spread": _pluginProposalObjectRestSpread.default,
"proposal-optional-catch-binding": _pluginProposalOptionalCatchBinding.default,
"proposal-optional-chaining": _pluginProposalOptionalChaining.default,
"proposal-private-methods": _pluginProposalPrivateMethods.default,
"proposal-unicode-property-regex": _pluginProposalUnicodePropertyRegex.default,
"syntax-async-generators": _pluginSyntaxAsyncGenerators.default,
"syntax-class-properties": _pluginSyntaxClassProperties.default,
"syntax-dynamic-import": _pluginSyntaxDynamicImport.default,
"syntax-json-strings": _pluginSyntaxJsonStrings.default,
"syntax-nullish-coalescing-operator": _pluginSyntaxNullishCoalescingOperator.default,
"syntax-numeric-separator": _pluginSyntaxNumericSeparator.default,
"syntax-object-rest-spread": _pluginSyntaxObjectRestSpread.default,
"syntax-optional-catch-binding": _pluginSyntaxOptionalCatchBinding.default,
"syntax-optional-chaining": _pluginSyntaxOptionalChaining.default,
"syntax-top-level-await": _pluginSyntaxTopLevelAwait.default,
"transform-arrow-functions": _pluginTransformArrowFunctions.default,
"transform-async-to-generator": _pluginTransformAsyncToGenerator.default,
"transform-block-scoped-functions": _pluginTransformBlockScopedFunctions.default,
"transform-block-scoping": _pluginTransformBlockScoping.default,
"transform-classes": _pluginTransformClasses.default,
"transform-computed-properties": _pluginTransformComputedProperties.default,
"transform-destructuring": _pluginTransformDestructuring.default,
"transform-dotall-regex": _pluginTransformDotallRegex.default,
"transform-duplicate-keys": _pluginTransformDuplicateKeys.default,
"transform-exponentiation-operator": _pluginTransformExponentiationOperator.default,
"transform-for-of": _pluginTransformForOf.default,
"transform-function-name": _pluginTransformFunctionName.default,
"transform-literals": _pluginTransformLiterals.default,
"transform-member-expression-literals": _pluginTransformMemberExpressionLiterals.default,
"transform-modules-amd": _pluginTransformModulesAmd.default,
"transform-modules-commonjs": _pluginTransformModulesCommonjs.default,
"transform-modules-systemjs": _pluginTransformModulesSystemjs.default,
"transform-modules-umd": _pluginTransformModulesUmd.default,
"transform-named-capturing-groups-regex": _pluginTransformNamedCapturingGroupsRegex.default,
"transform-new-target": _pluginTransformNewTarget.default,
"transform-object-super": _pluginTransformObjectSuper.default,
"transform-parameters": _pluginTransformParameters.default,
"transform-property-literals": _pluginTransformPropertyLiterals.default,
"transform-regenerator": _pluginTransformRegenerator.default,
"transform-reserved-words": _pluginTransformReservedWords.default,
"transform-shorthand-properties": _pluginTransformShorthandProperties.default,
"transform-spread": _pluginTransformSpread.default,
"transform-sticky-regex": _pluginTransformStickyRegex.default,
"transform-template-literals": _pluginTransformTemplateLiterals.default,
"transform-typeof-symbol": _pluginTransformTypeofSymbol.default,
"transform-unicode-escapes": _pluginTransformUnicodeEscapes.default,
"transform-unicode-regex": _pluginTransformUnicodeRegex.default
"bugfix/transform-async-arrows-in-class": () => _transformAsyncArrowsInClass,
"bugfix/transform-edge-default-parameters": () => _transformEdgeDefaultParameters,
"bugfix/transform-edge-function-name": () => _transformEdgeFunctionName,
"bugfix/transform-safari-block-shadowing": () => _transformSafariBlockShadowing,
"bugfix/transform-safari-for-shadowing": () => _transformSafariForShadowing,
"bugfix/transform-safari-id-destructuring-collision-in-function-expression": () => _pluginBugfixSafariIdDestructuringCollisionInFunctionExpression.default,
"bugfix/transform-tagged-template-caching": () => _transformTaggedTemplateCaching,
"bugfix/transform-v8-spread-parameters-in-optional-chaining": () => _pluginBugfixV8SpreadParametersInOptionalChaining.default,
"proposal-async-generator-functions": () => _pluginProposalAsyncGeneratorFunctions.default,
"proposal-class-properties": () => _pluginProposalClassProperties.default,
"proposal-class-static-block": () => _pluginProposalClassStaticBlock.default,
"proposal-dynamic-import": () => _pluginProposalDynamicImport.default,
"proposal-export-namespace-from": () => _pluginProposalExportNamespaceFrom.default,
"proposal-json-strings": () => _pluginProposalJsonStrings.default,
"proposal-logical-assignment-operators": () => _pluginProposalLogicalAssignmentOperators.default,
"proposal-nullish-coalescing-operator": () => _pluginProposalNullishCoalescingOperator.default,
"proposal-numeric-separator": () => _pluginProposalNumericSeparator.default,
"proposal-object-rest-spread": () => _pluginProposalObjectRestSpread.default,
"proposal-optional-catch-binding": () => _pluginProposalOptionalCatchBinding.default,
"proposal-optional-chaining": () => _pluginProposalOptionalChaining.default,
"proposal-private-methods": () => _pluginProposalPrivateMethods.default,
"proposal-private-property-in-object": () => _pluginProposalPrivatePropertyInObject.default,
"proposal-unicode-property-regex": () => _pluginProposalUnicodePropertyRegex.default,
"syntax-async-generators": () => _pluginSyntaxAsyncGenerators,
"syntax-class-properties": () => _pluginSyntaxClassProperties,
"syntax-class-static-block": () => _pluginSyntaxClassStaticBlock,
"syntax-dynamic-import": () => _pluginSyntaxDynamicImport,
"syntax-export-namespace-from": () => _pluginSyntaxExportNamespaceFrom,
"syntax-import-assertions": () => _pluginSyntaxImportAssertions.default,
"syntax-json-strings": () => _pluginSyntaxJsonStrings,
"syntax-logical-assignment-operators": () => _pluginSyntaxLogicalAssignmentOperators,
"syntax-nullish-coalescing-operator": () => _pluginSyntaxNullishCoalescingOperator,
"syntax-numeric-separator": () => _pluginSyntaxNumericSeparator,
"syntax-object-rest-spread": () => _pluginSyntaxObjectRestSpread,
"syntax-optional-catch-binding": () => _pluginSyntaxOptionalCatchBinding,
"syntax-optional-chaining": () => _pluginSyntaxOptionalChaining,
"syntax-private-property-in-object": () => _pluginSyntaxPrivatePropertyInObject,
"syntax-top-level-await": () => _pluginSyntaxTopLevelAwait,
"transform-arrow-functions": () => _pluginTransformArrowFunctions.default,
"transform-async-to-generator": () => _pluginTransformAsyncToGenerator.default,
"transform-block-scoped-functions": () => _pluginTransformBlockScopedFunctions.default,
"transform-block-scoping": () => _pluginTransformBlockScoping.default,
"transform-classes": () => _pluginTransformClasses.default,
"transform-computed-properties": () => _pluginTransformComputedProperties.default,
"transform-destructuring": () => _pluginTransformDestructuring.default,
"transform-dotall-regex": () => _pluginTransformDotallRegex.default,
"transform-duplicate-keys": () => _pluginTransformDuplicateKeys.default,
"transform-exponentiation-operator": () => _pluginTransformExponentiationOperator.default,
"transform-for-of": () => _pluginTransformForOf.default,
"transform-function-name": () => _pluginTransformFunctionName.default,
"transform-literals": () => _pluginTransformLiterals.default,
"transform-member-expression-literals": () => _pluginTransformMemberExpressionLiterals.default,
"transform-modules-amd": () => _pluginTransformModulesAmd.default,
"transform-modules-commonjs": () => _pluginTransformModulesCommonjs.default,
"transform-modules-systemjs": () => _pluginTransformModulesSystemjs.default,
"transform-modules-umd": () => _pluginTransformModulesUmd.default,
"transform-named-capturing-groups-regex": () => _pluginTransformNamedCapturingGroupsRegex.default,
"transform-new-target": () => _pluginTransformNewTarget.default,
"transform-object-super": () => _pluginTransformObjectSuper.default,
"transform-parameters": () => _pluginTransformParameters.default,
"transform-property-literals": () => _pluginTransformPropertyLiterals.default,
"transform-regenerator": () => _pluginTransformRegenerator.default,
"transform-reserved-words": () => _pluginTransformReservedWords.default,
"transform-shorthand-properties": () => _pluginTransformShorthandProperties.default,
"transform-spread": () => _pluginTransformSpread.default,
"transform-sticky-regex": () => _pluginTransformStickyRegex.default,
"transform-template-literals": () => _pluginTransformTemplateLiterals.default,
"transform-typeof-symbol": () => _pluginTransformTypeofSymbol.default,
"transform-unicode-escapes": () => _pluginTransformUnicodeEscapes.default,
"transform-unicode-regex": () => _pluginTransformUnicodeRegex.default
};
exports.default = _default;
exports.default = _default;
const minVersions = {
"bugfix/transform-safari-id-destructuring-collision-in-function-expression": "7.16.0",
"proposal-class-static-block": "7.12.0",
"proposal-private-property-in-object": "7.10.0"
};
exports.minVersions = minVersions;
+21 -51
View File
@@ -3,61 +3,31 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.logUsagePolyfills = exports.logEntryPolyfills = exports.logPluginOrPolyfill = void 0;
exports.logPlugin = void 0;
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
const wordEnds = size => {
return size > 1 ? "s" : "";
};
const logPluginOrPolyfill = (item, targetVersions, list) => {
const logPlugin = (item, targetVersions, list) => {
const filteredList = (0, _helperCompilationTargets.getInclusionReasons)(item, targetVersions, list);
const formattedTargets = JSON.stringify(filteredList).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
const support = list[item];
if (!support) {
console.log(` ${item}`);
return;
}
let formattedTargets = `{`;
let first = true;
for (const target of Object.keys(filteredList)) {
if (!first) formattedTargets += `,`;
first = false;
formattedTargets += ` ${target}`;
if (support[target]) formattedTargets += ` < ${support[target]}`;
}
formattedTargets += ` }`;
console.log(` ${item} ${formattedTargets}`);
};
exports.logPluginOrPolyfill = logPluginOrPolyfill;
const logEntryPolyfills = (polyfillName, importPolyfillIncluded, polyfills, filename, polyfillTargets, allBuiltInsList) => {
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!importPolyfillIncluded) {
console.log(`\n[${filename}] Import of ${polyfillName} was not found.`);
return;
}
if (!polyfills.size) {
console.log(`\n[${filename}] Based on your targets, polyfills were not added.`);
return;
}
console.log(`\n[${filename}] Replaced ${polyfillName} entries with the following polyfill${wordEnds(polyfills.size)}:`);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
}
};
exports.logEntryPolyfills = logEntryPolyfills;
const logUsagePolyfills = (polyfills, filename, polyfillTargets, allBuiltInsList) => {
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!polyfills.size) {
console.log(`\n[${filename}] Based on your code and targets, core-js polyfills were not added.`);
return;
}
console.log(`\n[${filename}] Added following core-js polyfill${wordEnds(polyfills.size)}:`);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
}
};
exports.logUsagePolyfills = logUsagePolyfills;
exports.logPlugin = logPlugin;
+22
View File
@@ -3,7 +3,21 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addProposalSyntaxPlugins = addProposalSyntaxPlugins;
exports.removeUnnecessaryItems = removeUnnecessaryItems;
exports.removeUnsupportedItems = removeUnsupportedItems;
var _semver = require("semver");
var _availablePlugins = require("./available-plugins");
const has = Function.call.bind(Object.hasOwnProperty);
function addProposalSyntaxPlugins(items, proposalSyntaxPlugins) {
proposalSyntaxPlugins.forEach(plugin => {
items.add(plugin);
});
}
function removeUnnecessaryItems(items, overlapping) {
items.forEach(item => {
@@ -11,4 +25,12 @@ function removeUnnecessaryItems(items, overlapping) {
(_overlapping$item = overlapping[item]) == null ? void 0 : _overlapping$item.forEach(name => items.delete(name));
});
}
function removeUnsupportedItems(items, babelVersion) {
items.forEach(item => {
if (has(_availablePlugins.minVersions, item) && _semver.lt(babelVersion, _availablePlugins.minVersions[item])) {
items.delete(item);
}
});
}
+116 -66
View File
@@ -3,52 +3,47 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPolyfillPlugins = exports.getModulesPluginNames = exports.default = void 0;
exports.isPluginRequired = isPluginRequired;
exports.default = exports.getPolyfillPlugins = exports.getModulesPluginNames = exports.transformIncludesAndExcludes = void 0;
exports.transformIncludesAndExcludes = void 0;
var _semver = require("semver");
var _debug = require("./debug");
var _getOptionSpecificExcludes = _interopRequireDefault(require("./get-option-specific-excludes"));
var _getOptionSpecificExcludes = require("./get-option-specific-excludes");
var _filterItems = require("./filter-items");
var _moduleTransformations = _interopRequireDefault(require("./module-transformations"));
var _moduleTransformations = require("./module-transformations");
var _normalizeOptions = _interopRequireDefault(require("./normalize-options"));
var _normalizeOptions = require("./normalize-options");
var _shippedProposals = require("../data/shipped-proposals");
var _shippedProposals = require("./shipped-proposals");
var _pluginsCompatData = require("./plugins-compat-data");
var _overlappingPlugins = _interopRequireDefault(require("@babel/compat-data/overlapping-plugins"));
var _overlappingPlugins = require("@babel/compat-data/overlapping-plugins");
var _usagePlugin = _interopRequireDefault(require("./polyfills/corejs2/usage-plugin"));
var _regenerator = require("./polyfills/regenerator");
var _usagePlugin2 = _interopRequireDefault(require("./polyfills/corejs3/usage-plugin"));
var _babelPolyfill = require("./polyfills/babel-polyfill");
var _usagePlugin3 = _interopRequireDefault(require("./polyfills/regenerator/usage-plugin"));
var _babelPluginPolyfillCorejs = require("babel-plugin-polyfill-corejs2");
var _entryPlugin = _interopRequireDefault(require("./polyfills/corejs2/entry-plugin"));
var _babelPluginPolyfillCorejs2 = require("babel-plugin-polyfill-corejs3");
var _entryPlugin2 = _interopRequireDefault(require("./polyfills/corejs3/entry-plugin"));
var _babelPluginPolyfillRegenerator = require("babel-plugin-polyfill-regenerator");
var _entryPlugin3 = _interopRequireDefault(require("./polyfills/regenerator/entry-plugin"));
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _helperCompilationTargets = _interopRequireWildcard(require("@babel/helper-compilation-targets"));
var _availablePlugins = _interopRequireDefault(require("./available-plugins"));
var _utils = require("./utils");
var _availablePlugins = require("./available-plugins");
var _helperPluginUtils = require("@babel/helper-plugin-utils");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const pluginCoreJS2 = _babelPluginPolyfillCorejs.default || _babelPluginPolyfillCorejs;
const pluginCoreJS3 = _babelPluginPolyfillCorejs2.default || _babelPluginPolyfillCorejs2;
const pluginRegenerator = _babelPluginPolyfillRegenerator.default || _babelPluginPolyfillRegenerator;
function isPluginRequired(targets, support) {
return (0, _helperCompilationTargets.isRequired)("fake-name", targets, {
@@ -58,14 +53,24 @@ function isPluginRequired(targets, support) {
});
}
function filterStageFromList(list, stageList) {
return Object.keys(list).reduce((result, item) => {
if (!stageList.has(item)) {
result[item] = list[item];
}
return result;
}, {});
}
const pluginLists = {
withProposals: {
withoutBugfixes: _pluginsCompatData.plugins,
withBugfixes: Object.assign({}, _pluginsCompatData.plugins, _pluginsCompatData.pluginsBugfixes)
},
withoutProposals: {
withoutBugfixes: (0, _utils.filterStageFromList)(_pluginsCompatData.plugins, _shippedProposals.proposalPlugins),
withBugfixes: (0, _utils.filterStageFromList)(Object.assign({}, _pluginsCompatData.plugins, _pluginsCompatData.pluginsBugfixes), _shippedProposals.proposalPlugins)
withoutBugfixes: filterStageFromList(_pluginsCompatData.plugins, _shippedProposals.proposalPlugins),
withBugfixes: filterStageFromList(Object.assign({}, _pluginsCompatData.plugins, _pluginsCompatData.pluginsBugfixes), _shippedProposals.proposalPlugins)
}
};
@@ -78,7 +83,7 @@ function getPluginList(proposals, bugfixes) {
}
const getPlugin = pluginName => {
const plugin = _availablePlugins.default[pluginName];
const plugin = _availablePlugins.default[pluginName]();
if (!plugin) {
throw new Error(`Could not find plugin "${pluginName}". Ensure there is an entry in ./available-plugins.js for it.`);
@@ -106,6 +111,7 @@ const getModulesPluginNames = ({
transformations,
shouldTransformESM,
shouldTransformDynamicImport,
shouldTransformExportNamespaceFrom,
shouldParseTopLevelAwait
}) => {
const modulesPluginNames = [];
@@ -128,6 +134,12 @@ const getModulesPluginNames = ({
modulesPluginNames.push("syntax-dynamic-import");
}
if (shouldTransformExportNamespaceFrom) {
modulesPluginNames.push("proposal-export-namespace-from");
} else {
modulesPluginNames.push("syntax-export-namespace-from");
}
if (shouldParseTopLevelAwait) {
modulesPluginNames.push("syntax-top-level-await");
}
@@ -152,35 +164,47 @@ const getPolyfillPlugins = ({
if (useBuiltIns === "usage" || useBuiltIns === "entry") {
const pluginOptions = {
corejs,
polyfillTargets,
method: `${useBuiltIns}-global`,
version: corejs ? corejs.toString() : undefined,
targets: polyfillTargets,
include,
exclude,
proposals,
shippedProposals,
regenerator,
debug
};
if (corejs) {
if (useBuiltIns === "usage") {
if (corejs.major === 2) {
polyfillPlugins.push([_usagePlugin.default, pluginOptions]);
polyfillPlugins.push([pluginCoreJS2, pluginOptions], [_babelPolyfill.default, {
usage: true
}]);
} else {
polyfillPlugins.push([_usagePlugin2.default, pluginOptions]);
polyfillPlugins.push([pluginCoreJS3, pluginOptions], [_babelPolyfill.default, {
usage: true,
deprecated: true
}]);
}
if (regenerator) {
polyfillPlugins.push([_usagePlugin3.default, pluginOptions]);
polyfillPlugins.push([pluginRegenerator, {
method: "usage-global",
debug
}]);
}
} else {
if (corejs.major === 2) {
polyfillPlugins.push([_entryPlugin.default, pluginOptions]);
polyfillPlugins.push([_babelPolyfill.default, {
regenerator
}], [pluginCoreJS2, pluginOptions]);
} else {
polyfillPlugins.push([_entryPlugin2.default, pluginOptions]);
polyfillPlugins.push([pluginCoreJS3, pluginOptions], [_babelPolyfill.default, {
deprecated: true
}]);
if (!regenerator) {
polyfillPlugins.push([_entryPlugin3.default, pluginOptions]);
polyfillPlugins.push([_regenerator.default, pluginOptions]);
}
}
}
@@ -192,20 +216,40 @@ const getPolyfillPlugins = ({
exports.getPolyfillPlugins = getPolyfillPlugins;
function getLocalTargets(optionsTargets, ignoreBrowserslistConfig, configPath, browserslistEnv) {
if (optionsTargets != null && optionsTargets.esmodules && optionsTargets.browsers) {
console.warn(`
@babel/preset-env: esmodules and browsers targets have been specified together.
\`browsers\` target, \`${optionsTargets.browsers.toString()}\` will be ignored.
`);
}
return (0, _helperCompilationTargets.default)(optionsTargets, {
ignoreBrowserslistConfig,
configPath,
browserslistEnv
});
}
function supportsStaticESM(caller) {
return !!(caller == null ? void 0 : caller.supportsStaticESM);
return !!(caller != null && caller.supportsStaticESM);
}
function supportsDynamicImport(caller) {
return !!(caller == null ? void 0 : caller.supportsDynamicImport);
return !!(caller != null && caller.supportsDynamicImport);
}
function supportsExportNamespaceFrom(caller) {
return !!(caller != null && caller.supportsExportNamespaceFrom);
}
function supportsTopLevelAwait(caller) {
return !!(caller == null ? void 0 : caller.supportsTopLevelAwait);
return !!(caller != null && caller.supportsTopLevelAwait);
}
var _default = (0, _helperPluginUtils.declare)((api, opts) => {
var _default = (0, _helperPluginUtils.declarePreset)((api, opts) => {
api.assertVersion(7);
const babelTargets = api.targets();
const {
bugfixes,
configPath,
@@ -226,43 +270,51 @@ var _default = (0, _helperPluginUtils.declare)((api, opts) => {
},
browserslistEnv
} = (0, _normalizeOptions.default)(opts);
let hasUglifyTarget = false;
let targets = babelTargets;
if (optionsTargets == null ? void 0 : optionsTargets.uglify) {
hasUglifyTarget = true;
delete optionsTargets.uglify;
console.log("");
console.log("The uglify target has been deprecated. Set the top level");
console.log("option `forceAllTransforms: true` instead.");
console.log("");
if (_semver.lt(api.version, "7.13.0") || opts.targets || opts.configPath || opts.browserslistEnv || opts.ignoreBrowserslistConfig) {
{
var hasUglifyTarget = false;
if (optionsTargets != null && optionsTargets.uglify) {
hasUglifyTarget = true;
delete optionsTargets.uglify;
console.warn(`
The uglify target has been deprecated. Set the top level
option \`forceAllTransforms: true\` instead.
`);
}
}
targets = getLocalTargets(optionsTargets, ignoreBrowserslistConfig, configPath, browserslistEnv);
}
if ((optionsTargets == null ? void 0 : optionsTargets.esmodules) && optionsTargets.browsers) {
console.log("");
console.log("@babel/preset-env: esmodules and browsers targets have been specified together.");
console.log(`\`browsers\` target, \`${optionsTargets.browsers}\` will be ignored.`);
console.log("");
}
const targets = (0, _helperCompilationTargets.default)(optionsTargets, {
ignoreBrowserslistConfig,
configPath,
browserslistEnv
});
const transformTargets = forceAllTransforms || hasUglifyTarget ? {} : targets;
const include = transformIncludesAndExcludes(optionsInclude);
const exclude = transformIncludesAndExcludes(optionsExclude);
const transformTargets = forceAllTransforms || hasUglifyTarget ? {} : targets;
const compatData = getPluginList(shippedProposals, bugfixes);
const shouldSkipExportNamespaceFrom = modules === "auto" && (api.caller == null ? void 0 : api.caller(supportsExportNamespaceFrom)) || modules === false && !(0, _helperCompilationTargets.isRequired)("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins
});
const modulesPluginNames = getModulesPluginNames({
modules,
transformations: _moduleTransformations.default,
shouldTransformESM: modules !== "auto" || !(api.caller == null ? void 0 : api.caller(supportsStaticESM)),
shouldTransformDynamicImport: modules !== "auto" || !(api.caller == null ? void 0 : api.caller(supportsDynamicImport)),
shouldTransformESM: modules !== "auto" || !(api.caller != null && api.caller(supportsStaticESM)),
shouldTransformDynamicImport: modules !== "auto" || !(api.caller != null && api.caller(supportsDynamicImport)),
shouldTransformExportNamespaceFrom: !shouldSkipExportNamespaceFrom,
shouldParseTopLevelAwait: !api.caller || api.caller(supportsTopLevelAwait)
});
const pluginNames = (0, _helperCompilationTargets.filterItems)(getPluginList(shippedProposals, bugfixes), include.plugins, exclude.plugins, transformTargets, modulesPluginNames, (0, _getOptionSpecificExcludes.default)({
const pluginNames = (0, _helperCompilationTargets.filterItems)(compatData, include.plugins, exclude.plugins, transformTargets, modulesPluginNames, (0, _getOptionSpecificExcludes.default)({
loose
}), _shippedProposals.pluginSyntaxMap);
(0, _filterItems.removeUnnecessaryItems)(pluginNames, _overlappingPlugins.default);
(0, _filterItems.removeUnnecessaryItems)(pluginNames, _overlappingPlugins);
(0, _filterItems.removeUnsupportedItems)(pluginNames, api.version);
if (shippedProposals) {
(0, _filterItems.addProposalSyntaxPlugins)(pluginNames, _shippedProposals.proposalSyntaxPlugins);
}
const polyfillPlugins = getPolyfillPlugins({
useBuiltIns,
corejs,
@@ -296,13 +348,11 @@ var _default = (0, _helperPluginUtils.declare)((api, opts) => {
console.log(`\nUsing modules transform: ${modules.toString()}`);
console.log("\nUsing plugins:");
pluginNames.forEach(pluginName => {
(0, _debug.logPluginOrPolyfill)(pluginName, targets, _pluginsCompatData.plugins);
(0, _debug.logPlugin)(pluginName, targets, compatData);
});
if (!useBuiltIns) {
console.log("\nUsing polyfills: No polyfills were added, since the `useBuiltIns` option was not set.");
} else {
console.log(`\nUsing polyfills with \`${useBuiltIns}\` option:`);
}
}
+28 -80
View File
@@ -3,45 +3,31 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normalizeCoreJSOption = normalizeCoreJSOption;
exports.checkDuplicateIncludeExcludes = void 0;
exports.default = normalizeOptions;
exports.validateUseBuiltInsOption = exports.validateModulesOption = exports.validateIgnoreBrowserslistConfig = exports.validateStringOption = exports.validateBoolOption = exports.validateConfigPathOption = exports.checkDuplicateIncludeExcludes = exports.normalizePluginName = void 0;
var _data = _interopRequireDefault(require("core-js-compat/data"));
var _levenary = _interopRequireDefault(require("levenary"));
var _invariant = _interopRequireDefault(require("invariant"));
exports.normalizeCoreJSOption = normalizeCoreJSOption;
exports.validateUseBuiltInsOption = exports.validateModulesOption = exports.normalizePluginName = void 0;
var _semver = require("semver");
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
var _corejs2BuiltIns = require("@babel/compat-data/corejs2-built-ins");
var _coreJsCompat = require("../data/core-js-compat");
var _pluginsCompatData = require("./plugins-compat-data");
var _moduleTransformations = _interopRequireDefault(require("./module-transformations"));
var _moduleTransformations = require("./module-transformations");
var _options = require("./options");
var _getPlatformSpecificDefault = require("./polyfills/corejs2/get-platform-specific-default");
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)}'?`);
}
}
};
var _helperValidatorOption = require("@babel/helper-validator-option");
const corejs2DefaultWebIncludes = ["web.timers", "web.immediate", "web.dom.iterable"];
const v = new _helperValidatorOption.OptionValidator("@babel/preset-env");
const allPluginsList = Object.keys(_pluginsCompatData.plugins);
const modulePlugins = ["proposal-dynamic-import", ...Object.keys(_moduleTransformations.default).map(m => _moduleTransformations.default[m])];
const getValidIncludesAndExcludes = (type, corejs) => new Set([...allPluginsList, ...(type === "exclude" ? modulePlugins : []), ...(corejs ? corejs == 2 ? [...Object.keys(_corejs2BuiltIns.default), ..._getPlatformSpecificDefault.defaultWebIncludes] : Object.keys(_data.default) : [])]);
const getValidIncludesAndExcludes = (type, corejs) => new Set([...allPluginsList, ...(type === "exclude" ? modulePlugins : []), ...(corejs ? corejs == 2 ? [...Object.keys(_corejs2BuiltIns), ...corejs2DefaultWebIncludes] : Object.keys(_coreJsCompat) : [])]);
const pluginToRegExp = plugin => {
if (plugin instanceof RegExp) return plugin;
@@ -61,7 +47,7 @@ const expandIncludesAndExcludes = (plugins = [], type, corejs) => {
if (plugins.length === 0) return [];
const selectedPlugins = plugins.map(plugin => selectPlugins(pluginToRegExp(plugin), type, corejs));
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`);
return flatten(selectedPlugins);
};
@@ -72,7 +58,7 @@ exports.normalizePluginName = normalizePluginName;
const checkDuplicateIncludeExcludes = (include = [], exclude = []) => {
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.`);
};
@@ -88,52 +74,15 @@ const normalizeTargets = targets => {
return Object.assign({}, targets);
};
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;
};
exports.validateModulesOption = validateModulesOption;
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,
'"entry"' to indicate replacing the entry polyfill, or
'"usage"' to import only used polyfills per file`);
@@ -148,7 +97,7 @@ function normalizeCoreJSOption(corejs, useBuiltIns) {
if (useBuiltIns && corejs === undefined) {
rawVersion = 2;
console.warn("\nWARNING: We noticed you're using the `useBuiltIns` option without declaring a " + "core-js version. Currently, we assume version 2.x when no version " + "is passed. Since this default version will likely change in future " + "versions of Babel, we recommend explicitly setting the core-js version " + "you are using via the `corejs` option.\n" + "\nYou should also be sure that the version you pass to the `corejs` " + "option matches the version specified in your `package.json`'s " + "`dependencies` section. If it doesn't, you need to run one of the " + "following commands:\n\n" + " npm install --save core-js@2 npm install --save core-js@3\n" + " yarn add core-js@2 yarn add core-js@3\n");
console.warn("\nWARNING (@babel/preset-env): We noticed you're using the `useBuiltIns` option without declaring a " + "core-js version. Currently, we assume version 2.x when no version " + "is passed. Since this default version will likely change in future " + "versions of Babel, we recommend explicitly setting the core-js version " + "you are using via the `corejs` option.\n" + "\nYou should also be sure that the version you pass to the `corejs` " + "option matches the version specified in your `package.json`'s " + "`dependencies` section. If it doesn't, you need to run one of the " + "following commands:\n\n" + " npm install --save core-js@2 npm install --save core-js@3\n" + " yarn add core-js@2 yarn add core-js@3\n\n" + "More info about useBuiltIns: https://babeljs.io/docs/en/babel-preset-env#usebuiltins\n" + "More info about core-js: https://babeljs.io/docs/en/babel-preset-env#corejs");
} else if (typeof corejs === "object" && corejs !== null) {
rawVersion = corejs.version;
proposals = Boolean(corejs.proposals);
@@ -156,10 +105,10 @@ function normalizeCoreJSOption(corejs, useBuiltIns) {
rawVersion = corejs;
}
const version = rawVersion ? (0, _semver.coerce)(String(rawVersion)) : false;
const version = rawVersion ? _semver.coerce(String(rawVersion)) : false;
if (!useBuiltIns && version) {
console.log("\nThe `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n");
console.warn("\nWARNING (@babel/preset-env): The `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n");
}
if (useBuiltIns && (!version || version.major < 2 || version.major > 3)) {
@@ -173,28 +122,27 @@ function normalizeCoreJSOption(corejs, useBuiltIns) {
}
function normalizeOptions(opts) {
validateTopLevelOptions(opts);
v.validateTopLevelOptions(opts, _options.TopLevelOptions);
const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns);
const corejs = normalizeCoreJSOption(opts.corejs, useBuiltIns);
const include = expandIncludesAndExcludes(opts.include, _options.TopLevelOptions.include, !!corejs.version && corejs.version.major);
const exclude = expandIncludesAndExcludes(opts.exclude, _options.TopLevelOptions.exclude, !!corejs.version && corejs.version.major);
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),
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)
};
}
+1 -1
View File
@@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UseBuiltInsOption = exports.ModulesOption = exports.TopLevelOptions = void 0;
exports.UseBuiltInsOption = exports.TopLevelOptions = exports.ModulesOption = void 0;
const TopLevelOptions = {
bugfixes: "bugfixes",
configPath: "configPath",
+8 -12
View File
@@ -5,29 +5,25 @@ Object.defineProperty(exports, "__esModule", {
});
exports.pluginsBugfixes = exports.plugins = void 0;
var _plugins = _interopRequireDefault(require("@babel/compat-data/plugins"));
var _plugins = require("@babel/compat-data/plugins");
var _pluginBugfixes = _interopRequireDefault(require("@babel/compat-data/plugin-bugfixes"));
var _pluginBugfixes = require("@babel/compat-data/plugin-bugfixes");
var _availablePlugins = _interopRequireDefault(require("./available-plugins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _availablePlugins = require("./available-plugins");
const pluginsFiltered = {};
exports.plugins = pluginsFiltered;
const bugfixPluginsFiltered = {};
exports.pluginsBugfixes = bugfixPluginsFiltered;
for (const plugin of Object.keys(_plugins.default)) {
for (const plugin of Object.keys(_plugins)) {
if (Object.hasOwnProperty.call(_availablePlugins.default, plugin)) {
pluginsFiltered[plugin] = _plugins.default[plugin];
pluginsFiltered[plugin] = _plugins[plugin];
}
}
for (const plugin of Object.keys(_pluginBugfixes.default)) {
for (const plugin of Object.keys(_pluginBugfixes)) {
if (Object.hasOwnProperty.call(_availablePlugins.default, plugin)) {
bugfixPluginsFiltered[plugin] = _pluginBugfixes.default[plugin];
bugfixPluginsFiltered[plugin] = _pluginBugfixes[plugin];
}
}
pluginsFiltered["proposal-class-properties"] = pluginsFiltered["proposal-private-methods"];
}
+75
View File
@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _utils = require("./utils");
const BABEL_POLYFILL_DEPRECATION = `
\`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
and \`regenerator-runtime/runtime\` separately`;
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the direct import of \`SPECIFIER\` or use \`useBuiltIns: 'entry'\` instead.`;
function _default({
template
}, {
regenerator,
deprecated,
usage
}) {
return {
name: "preset-env/replace-babel-polyfill",
visitor: {
ImportDeclaration(path) {
const src = (0, _utils.getImportSource)(path);
if (usage && (0, _utils.isPolyfillSource)(src)) {
console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src));
if (!deprecated) path.remove();
} else if (src === "@babel/polyfill") {
if (deprecated) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else if (regenerator) {
path.replaceWithMultiple(template.ast`
import "core-js";
import "regenerator-runtime/runtime.js";
`);
} else {
path.replaceWith(template.ast`
import "core-js";
`);
}
}
},
Program(path) {
path.get("body").forEach(bodyPath => {
const src = (0, _utils.getRequireSource)(bodyPath);
if (usage && (0, _utils.isPolyfillSource)(src)) {
console.warn(NO_DIRECT_POLYFILL_IMPORT.replace("SPECIFIER", src));
if (!deprecated) bodyPath.remove();
} else if (src === "@babel/polyfill") {
if (deprecated) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else if (regenerator) {
bodyPath.replaceWithMultiple(template.ast`
require("core-js");
require("regenerator-runtime/runtime.js");
`);
} else {
bodyPath.replaceWith(template.ast`
require("core-js");
`);
}
}
});
}
}
};
}
+54
View File
@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _utils = require("./utils");
function isRegeneratorSource(source) {
return source === "regenerator-runtime/runtime" || source === "regenerator-runtime/runtime.js";
}
function _default() {
const visitor = {
ImportDeclaration(path) {
if (isRegeneratorSource((0, _utils.getImportSource)(path))) {
this.regeneratorImportExcluded = true;
path.remove();
}
},
Program(path) {
path.get("body").forEach(bodyPath => {
if (isRegeneratorSource((0, _utils.getRequireSource)(bodyPath))) {
this.regeneratorImportExcluded = true;
bodyPath.remove();
}
});
}
};
return {
name: "preset-env/remove-regenerator",
visitor,
pre() {
this.regeneratorImportExcluded = false;
},
post() {
if (this.opts.debug && this.regeneratorImportExcluded) {
let filename = this.file.opts.filename;
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log(`\n[${filename}] Based on your targets, regenerator-runtime import excluded.`);
}
}
};
}
+40
View File
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getImportSource = getImportSource;
exports.getRequireSource = getRequireSource;
exports.isPolyfillSource = isPolyfillSource;
var _t = require("@babel/types");
const {
isCallExpression,
isExpressionStatement,
isIdentifier,
isStringLiteral
} = _t;
function getImportSource({
node
}) {
if (node.specifiers.length === 0) return node.source.value;
}
function getRequireSource({
node
}) {
if (!isExpressionStatement(node)) return;
const {
expression
} = node;
if (isCallExpression(expression) && isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && isStringLiteral(expression.arguments[0])) {
return expression.arguments[0].value;
}
}
function isPolyfillSource(source) {
return source === "@babel/polyfill" || source === "core-js";
}
+29
View File
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.proposalSyntaxPlugins = exports.proposalPlugins = exports.pluginSyntaxMap = void 0;
const proposalPlugins = new Set();
exports.proposalPlugins = proposalPlugins;
const proposalSyntaxPlugins = ["syntax-import-assertions"];
exports.proposalSyntaxPlugins = proposalSyntaxPlugins;
const pluginSyntaxObject = {
"proposal-async-generator-functions": "syntax-async-generators",
"proposal-class-properties": "syntax-class-properties",
"proposal-class-static-block": "syntax-class-static-block",
"proposal-json-strings": "syntax-json-strings",
"proposal-nullish-coalescing-operator": "syntax-nullish-coalescing-operator",
"proposal-numeric-separator": "syntax-numeric-separator",
"proposal-object-rest-spread": "syntax-object-rest-spread",
"proposal-optional-catch-binding": "syntax-optional-catch-binding",
"proposal-optional-chaining": "syntax-optional-chaining",
"proposal-private-methods": "syntax-class-properties",
"proposal-private-property-in-object": "syntax-private-property-in-object",
"proposal-unicode-property-regex": null
};
const pluginSyntaxEntries = Object.keys(pluginSyntaxObject).map(function (key) {
return [key, pluginSyntaxObject[key]];
});
const pluginSyntaxMap = new Map(pluginSyntaxEntries);
exports.pluginSyntaxMap = pluginSyntaxMap;
+1 -11
View File
@@ -15,15 +15,5 @@ Object.defineProperty(exports, "isBrowsersQueryValid", {
return _helperCompilationTargets.isBrowsersQueryValid;
}
});
Object.defineProperty(exports, "semverMin", {
enumerable: true,
get: function () {
return _helperCompilationTargets.semverMin;
}
});
var _helperCompilationTargets = _interopRequireWildcard(require("@babel/helper-compilation-targets"));
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; }
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
+1 -1
View File
@@ -1 +1 @@
../semver/bin/semver
../semver/bin/semver.js
+31
View File
@@ -1,5 +1,36 @@
# changes log
## 6.2.0
* Coerce numbers to strings when passed to semver.coerce()
* Add `rtl` option to coerce from right to left
## 6.1.3
* Handle X-ranges properly in includePrerelease mode
## 6.1.2
* Do not throw when testing invalid version strings
## 6.1.1
* Add options support for semver.coerce()
* Handle undefined version passed to Range.test
## 6.1.0
* Add semver.compareBuild function
* Support `*` in semver.intersects
## 6.0
* Fix `intersects` logic.
This is technically a bug fix, but since it is also a change to behavior
that may require users updating their code, it is marked as a major
version increment.
## 5.7
* Add `minVersion` method
+35 -4
View File
@@ -4,7 +4,7 @@ semver(1) -- The semantic versioner for npm
## Install
```bash
npm install --save semver
npm install semver
````
## Usage
@@ -60,6 +60,12 @@ Options:
Coerce a string into SemVer if possible
(does not imply --loose)
--rtl
Coerce version strings right to left
--ltr
Coerce version strings left to right (default)
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
@@ -231,7 +237,7 @@ comparator. Allows minor-level changes if not.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero digit in the
Allows changes that do not modify the left-most non-zero element in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
@@ -354,6 +360,9 @@ strings that they parse.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
are equal. Sorts in ascending order if passed to `Array.sort()`.
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
@@ -396,7 +405,7 @@ range, use the `satisfies(version, range)` function.
### Coercion
* `coerce(version)`: Coerces a string to semver if possible
* `coerce(version, options)`: Coerces a string to semver if possible
This aims to provide a very forgiving translation of a non-semver string to
semver. It looks for the first digit in a string, and consumes all
@@ -408,5 +417,27 @@ surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
is not valid). The maximum length for any semver component considered for
coercion is 16 characters; longer components will be ignored
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
components are invalid (`9999999999999999.4.7.4` is likely invalid).
If the `options.rtl` flag is set, then `coerce` will return the right-most
coercible tuple that does not share an ending index with a longer coercible
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
any other overlapping SemVer tuple.
### Clean
* `clean(version)`: Clean a string to be a valid semver if possible
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
ex.
* `s.clean(' = v 2.1.5foo')`: `null`
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean(' = v 2.1.5-foo')`: `null`
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
* `s.clean('=v2.1.5')`: `'2.1.5'`
* `s.clean(' =v2.1.5')`: `2.1.5`
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
* `s.clean('~1.0.0')`: `null`
+174
View File
@@ -0,0 +1,174 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
var argv = process.argv.slice(2)
var versions = []
var range = []
var inc = null
var version = require('../package.json').version
var loose = false
var includePrerelease = false
var coerce = false
var rtl = false
var identifier
var semver = require('../semver')
var reverse = false
var options = {}
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
switch (a) {
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case '-l': case '--loose':
loose = true
break
case '-p': case '--include-prerelease':
includePrerelease = true
break
case '-v': case '--version':
versions.push(argv.shift())
break
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
inc = argv.shift()
break
default:
inc = 'patch'
break
}
break
case '--preid':
identifier = argv.shift()
break
case '-r': case '--range':
range.push(argv.shift())
break
case '-c': case '--coerce':
coerce = true
break
case '--rtl':
rtl = true
break
case '--ltr':
rtl = false
break
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
break
}
}
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
versions = versions.map(function (v) {
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error('--inc can only be used on a single version with no range')
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v, i, _) { console.log(v) })
}
function help () {
console.log(['SemVer ' + version,
'',
'A JavaScript implementation of the https://semver.org/ specification',
'Copyright Isaac Z. Schlueter',
'',
'Usage: semver [options] <version> [<version> [...]]',
'Prints valid versions sorted by SemVer precedence',
'',
'Options:',
'-r --range <range>',
' Print versions that match the specified range.',
'',
'-i --increment [<level>]',
' Increment a version by the specified level. Level can',
' be one of: major, minor, patch, premajor, preminor,',
" prepatch, or prerelease. Default level is 'patch'.",
' Only one version may be specified.',
'',
'--preid <identifier>',
' Identifier to be used to prefix premajor, preminor,',
' prepatch or prerelease version increments.',
'',
'-l --loose',
' Interpret versions and ranges loosely',
'',
'-p --include-prerelease',
' Always include prerelease versions in range matching',
'',
'-c --coerce',
' Coerce a string into SemVer if possible',
' (does not imply --loose)',
'',
'--rtl',
' Coerce version strings right to left',
'',
'--ltr',
' Coerce version strings left to right (default)',
'',
'Program exits successfully if any valid version satisfies',
'all supplied ranges, and prints all satisfying versions.',
'',
'If no satisfying versions are found, then exits failure.',
'',
'Versions are printed in ascending order, so supplying',
'multiple versions to the utility will just sort them.'
].join('\n'))
}
+15 -15
View File
@@ -1,41 +1,41 @@
{
"_args": [
[
"semver@5.7.1",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"semver@6.3.0",
"/home/node/nuxt"
]
],
"_from": "semver@5.7.1",
"_id": "semver@5.7.1",
"_from": "semver@6.3.0",
"_id": "semver@6.3.0",
"_inBundle": false,
"_integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"_integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"_location": "/@babel/preset-env/semver",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "semver@5.7.1",
"raw": "semver@6.3.0",
"name": "semver",
"escapedName": "semver",
"rawSpec": "5.7.1",
"rawSpec": "6.3.0",
"saveSpec": null,
"fetchSpec": "5.7.1"
"fetchSpec": "6.3.0"
},
"_requiredBy": [
"/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"_spec": "5.7.1",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"_spec": "6.3.0",
"_where": "/home/node/nuxt",
"bin": {
"semver": "bin/semver"
"semver": "bin/semver.js"
},
"bugs": {
"url": "https://github.com/npm/node-semver/issues"
},
"description": "The semantic version parser used by npm.",
"devDependencies": {
"tap": "^13.0.0-rc.18"
"tap": "^14.3.1"
},
"files": [
"bin",
@@ -51,7 +51,7 @@
"url": "git+https://github.com/npm/node-semver.git"
},
"scripts": {
"postpublish": "git push origin --all; git push origin --tags",
"postpublish": "git push origin --follow-tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap"
@@ -59,5 +59,5 @@
"tap": {
"check-coverage": true
},
"version": "5.7.1"
"version": "6.3.0"
}
+248 -135
View File
@@ -29,75 +29,80 @@ var MAX_SAFE_COMPONENT_LENGTH = 16
// The actual regexps go on exports.re
var re = exports.re = []
var src = exports.src = []
var t = exports.tokens = {}
var R = 0
function tok (n) {
t[n] = R++
}
// The following Regular Expressions can be used for tokenizing,
// validating, and parsing SemVer version strings.
// ## Numeric Identifier
// A single `0`, or a non-zero digit followed by zero or more digits.
var NUMERICIDENTIFIER = R++
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
var NUMERICIDENTIFIERLOOSE = R++
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
tok('NUMERICIDENTIFIER')
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
tok('NUMERICIDENTIFIERLOOSE')
src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+'
// ## Non-numeric Identifier
// Zero or more digits, followed by a letter or hyphen, and then zero or
// more letters, digits, or hyphens.
var NONNUMERICIDENTIFIER = R++
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
tok('NONNUMERICIDENTIFIER')
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
// ## Main Version
// Three dot-separated numeric identifiers.
var MAINVERSION = R++
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
'(' + src[NUMERICIDENTIFIER] + ')'
tok('MAINVERSION')
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
'(' + src[t.NUMERICIDENTIFIER] + ')'
var MAINVERSIONLOOSE = R++
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
tok('MAINVERSIONLOOSE')
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
// ## Pre-release Version Identifier
// A numeric identifier, or a non-numeric identifier.
var PRERELEASEIDENTIFIER = R++
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
'|' + src[NONNUMERICIDENTIFIER] + ')'
tok('PRERELEASEIDENTIFIER')
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
var PRERELEASEIDENTIFIERLOOSE = R++
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
'|' + src[NONNUMERICIDENTIFIER] + ')'
tok('PRERELEASEIDENTIFIERLOOSE')
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
// ## Pre-release Version
// Hyphen, followed by one or more dot-separated pre-release version
// identifiers.
var PRERELEASE = R++
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
tok('PRERELEASE')
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
var PRERELEASELOOSE = R++
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
tok('PRERELEASELOOSE')
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
// ## Build Metadata Identifier
// Any combination of digits, letters, or hyphens.
var BUILDIDENTIFIER = R++
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
tok('BUILDIDENTIFIER')
src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
// ## Build Metadata
// Plus sign, followed by one or more period-separated build metadata
// identifiers.
var BUILD = R++
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
tok('BUILD')
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
// ## Full Version String
// A main version, followed optionally by a pre-release version and
@@ -108,129 +113,133 @@ src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
// capturing group, because it should not ever be used in version
// comparison.
var FULL = R++
var FULLPLAIN = 'v?' + src[MAINVERSION] +
src[PRERELEASE] + '?' +
src[BUILD] + '?'
tok('FULL')
tok('FULLPLAIN')
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
src[t.PRERELEASE] + '?' +
src[t.BUILD] + '?'
src[FULL] = '^' + FULLPLAIN + '$'
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
// common in the npm registry.
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
src[PRERELEASELOOSE] + '?' +
src[BUILD] + '?'
tok('LOOSEPLAIN')
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
src[t.PRERELEASELOOSE] + '?' +
src[t.BUILD] + '?'
var LOOSE = R++
src[LOOSE] = '^' + LOOSEPLAIN + '$'
tok('LOOSE')
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
var GTLT = R++
src[GTLT] = '((?:<|>)?=?)'
tok('GTLT')
src[t.GTLT] = '((?:<|>)?=?)'
// Something like "2.*" or "1.2.x".
// Note that "x.x" is a valid xRange identifer, meaning "any version"
// Only the first item is strictly required.
var XRANGEIDENTIFIERLOOSE = R++
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
var XRANGEIDENTIFIER = R++
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
tok('XRANGEIDENTIFIERLOOSE')
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
tok('XRANGEIDENTIFIER')
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
var XRANGEPLAIN = R++
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
'(?:' + src[PRERELEASE] + ')?' +
src[BUILD] + '?' +
tok('XRANGEPLAIN')
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
'(?:' + src[t.PRERELEASE] + ')?' +
src[t.BUILD] + '?' +
')?)?'
var XRANGEPLAINLOOSE = R++
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
'(?:' + src[PRERELEASELOOSE] + ')?' +
src[BUILD] + '?' +
tok('XRANGEPLAINLOOSE')
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
src[t.BUILD] + '?' +
')?)?'
var XRANGE = R++
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
var XRANGELOOSE = R++
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
tok('XRANGE')
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
tok('XRANGELOOSE')
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
// Coercion.
// Extract anything that could conceivably be a part of a valid semver
var COERCE = R++
src[COERCE] = '(?:^|[^\\d])' +
tok('COERCE')
src[t.COERCE] = '(^|[^\\d])' +
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
'(?:$|[^\\d])'
tok('COERCERTL')
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
// Tilde ranges.
// Meaning is "reasonably at or greater than"
var LONETILDE = R++
src[LONETILDE] = '(?:~>?)'
tok('LONETILDE')
src[t.LONETILDE] = '(?:~>?)'
var TILDETRIM = R++
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
tok('TILDETRIM')
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
var tildeTrimReplace = '$1~'
var TILDE = R++
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
var TILDELOOSE = R++
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
tok('TILDE')
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
tok('TILDELOOSE')
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
// Caret ranges.
// Meaning is "at least and backwards compatible with"
var LONECARET = R++
src[LONECARET] = '(?:\\^)'
tok('LONECARET')
src[t.LONECARET] = '(?:\\^)'
var CARETTRIM = R++
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
tok('CARETTRIM')
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
var caretTrimReplace = '$1^'
var CARET = R++
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
var CARETLOOSE = R++
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
tok('CARET')
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
tok('CARETLOOSE')
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
// A simple gt/lt/eq thing, or just "" to indicate "any version"
var COMPARATORLOOSE = R++
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
var COMPARATOR = R++
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
tok('COMPARATORLOOSE')
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
tok('COMPARATOR')
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
// An expression to strip any whitespace between the gtlt and the thing
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
var COMPARATORTRIM = R++
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
tok('COMPARATORTRIM')
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
// this one has to use the /g flag
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
var comparatorTrimReplace = '$1$2$3'
// Something like `1.2.3 - 1.2.4`
// Note that these all use the loose form, because they'll be
// checked against either the strict or loose comparator form
// later.
var HYPHENRANGE = R++
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
tok('HYPHENRANGE')
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
'\\s+-\\s+' +
'(' + src[XRANGEPLAIN] + ')' +
'(' + src[t.XRANGEPLAIN] + ')' +
'\\s*$'
var HYPHENRANGELOOSE = R++
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
tok('HYPHENRANGELOOSE')
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
'\\s+-\\s+' +
'(' + src[XRANGEPLAINLOOSE] + ')' +
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
'\\s*$'
// Star ranges basically just allow anything at all.
var STAR = R++
src[STAR] = '(<|>)?=?\\s*\\*'
tok('STAR')
src[t.STAR] = '(<|>)?=?\\s*\\*'
// Compile to actual regexp objects.
// All are flag-free, unless they were created above with a flag.
@@ -262,7 +271,7 @@ function parse (version, options) {
return null
}
var r = options.loose ? re[LOOSE] : re[FULL]
var r = options.loose ? re[t.LOOSE] : re[t.FULL]
if (!r.test(version)) {
return null
}
@@ -317,7 +326,7 @@ function SemVer (version, options) {
this.options = options
this.loose = !!options.loose
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
if (!m) {
throw new TypeError('Invalid Version: ' + version)
@@ -425,6 +434,30 @@ SemVer.prototype.comparePre = function (other) {
} while (++i)
}
SemVer.prototype.compareBuild = function (other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options)
}
var i = 0
do {
var a = this.build[i]
var b = other.build[i]
debug('prerelease compare', i, a, b)
if (a === undefined && b === undefined) {
return 0
} else if (b === undefined) {
return 1
} else if (a === undefined) {
return -1
} else if (a === b) {
continue
} else {
return compareIdentifiers(a, b)
}
} while (++i)
}
// preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way.
SemVer.prototype.inc = function (release, identifier) {
@@ -619,6 +652,13 @@ function compareLoose (a, b) {
return compare(a, b, true)
}
exports.compareBuild = compareBuild
function compareBuild (a, b, loose) {
var versionA = new SemVer(a, loose)
var versionB = new SemVer(b, loose)
return versionA.compare(versionB) || versionA.compareBuild(versionB)
}
exports.rcompare = rcompare
function rcompare (a, b, loose) {
return compare(b, a, loose)
@@ -627,14 +667,14 @@ function rcompare (a, b, loose) {
exports.sort = sort
function sort (list, loose) {
return list.sort(function (a, b) {
return exports.compare(a, b, loose)
return exports.compareBuild(a, b, loose)
})
}
exports.rsort = rsort
function rsort (list, loose) {
return list.sort(function (a, b) {
return exports.rcompare(a, b, loose)
return exports.compareBuild(b, a, loose)
})
}
@@ -747,14 +787,14 @@ function Comparator (comp, options) {
var ANY = {}
Comparator.prototype.parse = function (comp) {
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
var m = comp.match(r)
if (!m) {
throw new TypeError('Invalid comparator: ' + comp)
}
this.operator = m[1]
this.operator = m[1] !== undefined ? m[1] : ''
if (this.operator === '=') {
this.operator = ''
}
@@ -774,12 +814,16 @@ Comparator.prototype.toString = function () {
Comparator.prototype.test = function (version) {
debug('Comparator.test', version, this.options.loose)
if (this.semver === ANY) {
if (this.semver === ANY || version === ANY) {
return true
}
if (typeof version === 'string') {
version = new SemVer(version, this.options)
try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
}
return cmp(version, this.operator, this.semver, this.options)
@@ -800,9 +844,15 @@ Comparator.prototype.intersects = function (comp, options) {
var rangeTmp
if (this.operator === '') {
if (this.value === '') {
return true
}
rangeTmp = new Range(comp.value, options)
return satisfies(this.value, rangeTmp, options)
} else if (comp.operator === '') {
if (comp.value === '') {
return true
}
rangeTmp = new Range(this.value, options)
return satisfies(comp.semver, rangeTmp, options)
}
@@ -892,18 +942,18 @@ Range.prototype.parseRange = function (range) {
var loose = this.options.loose
range = range.trim()
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
range = range.replace(hr, hyphenReplace)
debug('hyphen replace', range)
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
debug('comparator trim', range, re[COMPARATORTRIM])
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
debug('comparator trim', range, re[t.COMPARATORTRIM])
// `~ 1.2.3` => `~1.2.3`
range = range.replace(re[TILDETRIM], tildeTrimReplace)
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
// `^ 1.2.3` => `^1.2.3`
range = range.replace(re[CARETTRIM], caretTrimReplace)
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
// normalize spaces
range = range.split(/\s+/).join(' ')
@@ -911,7 +961,7 @@ Range.prototype.parseRange = function (range) {
// At this point, the range is completely trimmed and
// ready to be split into comparators.
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
var set = range.split(' ').map(function (comp) {
return parseComparator(comp, this.options)
}, this).join(' ').split(/\s+/)
@@ -934,16 +984,40 @@ Range.prototype.intersects = function (range, options) {
}
return this.set.some(function (thisComparators) {
return thisComparators.every(function (thisComparator) {
return range.set.some(function (rangeComparators) {
return rangeComparators.every(function (rangeComparator) {
return thisComparator.intersects(rangeComparator, options)
})
return (
isSatisfiable(thisComparators, options) &&
range.set.some(function (rangeComparators) {
return (
isSatisfiable(rangeComparators, options) &&
thisComparators.every(function (thisComparator) {
return rangeComparators.every(function (rangeComparator) {
return thisComparator.intersects(rangeComparator, options)
})
})
)
})
})
)
})
}
// take a set of comparators and determine whether there
// exists a version which can satisfy it
function isSatisfiable (comparators, options) {
var result = true
var remainingComparators = comparators.slice()
var testComparator = remainingComparators.pop()
while (result && remainingComparators.length) {
result = remainingComparators.every(function (otherComparator) {
return testComparator.intersects(otherComparator, options)
})
testComparator = remainingComparators.pop()
}
return result
}
// Mostly just for testing and legacy API reasons
exports.toComparators = toComparators
function toComparators (range, options) {
@@ -987,7 +1061,7 @@ function replaceTildes (comp, options) {
}
function replaceTilde (comp, options) {
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
return comp.replace(r, function (_, M, m, p, pr) {
debug('tilde', comp, _, M, m, p, pr)
var ret
@@ -1028,7 +1102,7 @@ function replaceCarets (comp, options) {
function replaceCaret (comp, options) {
debug('caret', comp, options)
var r = options.loose ? re[CARETLOOSE] : re[CARET]
var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
return comp.replace(r, function (_, M, m, p, pr) {
debug('caret', comp, _, M, m, p, pr)
var ret
@@ -1087,7 +1161,7 @@ function replaceXRanges (comp, options) {
function replaceXRange (comp, options) {
comp = comp.trim()
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
debug('xRange', comp, ret, gtlt, M, m, p, pr)
var xM = isX(M)
@@ -1099,10 +1173,14 @@ function replaceXRange (comp, options) {
gtlt = ''
}
// if we're including prereleases in the match, then we need
// to fix this to -0, the lowest possible prerelease value
pr = options.includePrerelease ? '-0' : ''
if (xM) {
if (gtlt === '>' || gtlt === '<') {
// nothing is allowed
ret = '<0.0.0'
ret = '<0.0.0-0'
} else {
// nothing is forbidden
ret = '*'
@@ -1139,11 +1217,12 @@ function replaceXRange (comp, options) {
}
}
ret = gtlt + M + '.' + m + '.' + p
ret = gtlt + M + '.' + m + '.' + p + pr
} else if (xm) {
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
} else if (xp) {
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
ret = '>=' + M + '.' + m + '.0' + pr +
' <' + M + '.' + (+m + 1) + '.0' + pr
}
debug('xRange return', ret)
@@ -1157,10 +1236,10 @@ function replaceXRange (comp, options) {
function replaceStars (comp, options) {
debug('replaceStars', comp, options)
// Looseness is ignored here. star is always as loose as it gets!
return comp.trim().replace(re[STAR], '')
return comp.trim().replace(re[t.STAR], '')
}
// This function is passed to string.replace(re[HYPHENRANGE])
// This function is passed to string.replace(re[t.HYPHENRANGE])
// M, m, patch, prerelease, build
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
@@ -1200,7 +1279,11 @@ Range.prototype.test = function (version) {
}
if (typeof version === 'string') {
version = new SemVer(version, this.options)
try {
version = new SemVer(version, this.options)
} catch (er) {
return false
}
}
for (var i = 0; i < this.set.length; i++) {
@@ -1462,22 +1545,52 @@ function intersects (r1, r2, options) {
}
exports.coerce = coerce
function coerce (version) {
function coerce (version, options) {
if (version instanceof SemVer) {
return version
}
if (typeof version === 'number') {
version = String(version)
}
if (typeof version !== 'string') {
return null
}
var match = version.match(re[COERCE])
options = options || {}
if (match == null) {
var match = null
if (!options.rtl) {
match = version.match(re[t.COERCE])
} else {
// Find the right-most coercible string that does not share
// a terminus with a more left-ward coercible string.
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
//
// Walk through the string checking with a /g regexp
// Manually set the index so as to pick up overlapping matches.
// Stop when we get a match that ends at the string end, since no
// coercible string can be more right-ward without the same terminus.
var next
while ((next = re[t.COERCERTL].exec(version)) &&
(!match || match.index + match[0].length !== version.length)
) {
if (!match ||
next.index + next[0].length !== match.index + match[0].length) {
match = next
}
re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
}
// leave it in a clean state
re[t.COERCERTL].lastIndex = -1
}
if (match === null) {
return null
}
return parse(match[1] +
'.' + (match[2] || '0') +
'.' + (match[3] || '0'))
return parse(match[2] +
'.' + (match[3] || '0') +
'.' + (match[4] || '0'), options)
}
+99 -86
View File
@@ -1,118 +1,130 @@
{
"_args": [
[
"@babel/preset-env@7.10.4",
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
"@babel/preset-env@7.18.6",
"/home/node/nuxt"
]
],
"_from": "@babel/preset-env@7.10.4",
"_id": "@babel/preset-env@7.10.4",
"_from": "@babel/preset-env@7.18.6",
"_id": "@babel/preset-env@7.18.6",
"_inBundle": false,
"_integrity": "sha512-tcmuQ6vupfMZPrLrc38d0sF2OjLT3/bZ0dry5HchNCQbrokoQi4reXqclvkkAT5b+gWc23meVWpve5P/7+w/zw==",
"_integrity": "sha512-WrthhuIIYKrEFAwttYzgRNQ5hULGmwTj+D6l7Zdfsv5M7IWV/OZbUfbeL++Qrzx1nVJwWROIFhCHRYQV4xbPNw==",
"_location": "/@babel/preset-env",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/preset-env@7.10.4",
"raw": "@babel/preset-env@7.18.6",
"name": "@babel/preset-env",
"escapedName": "@babel%2fpreset-env",
"scope": "@babel",
"rawSpec": "7.10.4",
"rawSpec": "7.18.6",
"saveSpec": null,
"fetchSpec": "7.10.4"
"fetchSpec": "7.18.6"
},
"_requiredBy": [
"/@nuxt/babel-preset-app"
],
"_resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.10.4.tgz",
"_spec": "7.10.4",
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
"_resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.18.6.tgz",
"_spec": "7.18.6",
"_where": "/home/node/nuxt",
"author": {
"name": "Henry Zhu",
"email": "hi@henryzoo.com"
"name": "The Babel Team",
"url": "https://babel.dev/team"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
"url": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20preset-env%22+is%3Aopen"
},
"dependencies": {
"@babel/compat-data": "^7.10.4",
"@babel/helper-compilation-targets": "^7.10.4",
"@babel/helper-module-imports": "^7.10.4",
"@babel/helper-plugin-utils": "^7.10.4",
"@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-json-strings": "^7.10.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-proposal-numeric-separator": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.10.4",
"@babel/plugin-proposal-optional-catch-binding": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.10.4",
"@babel/plugin-proposal-private-methods": "^7.10.4",
"@babel/plugin-proposal-unicode-property-regex": "^7.10.4",
"@babel/plugin-syntax-async-generators": "^7.8.0",
"@babel/plugin-syntax-class-properties": "^7.10.4",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-syntax-json-strings": "^7.8.0",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0",
"@babel/compat-data": "^7.18.6",
"@babel/helper-compilation-targets": "^7.18.6",
"@babel/helper-plugin-utils": "^7.18.6",
"@babel/helper-validator-option": "^7.18.6",
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.18.6",
"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.18.6",
"@babel/plugin-proposal-async-generator-functions": "^7.18.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-class-static-block": "^7.18.6",
"@babel/plugin-proposal-dynamic-import": "^7.18.6",
"@babel/plugin-proposal-export-namespace-from": "^7.18.6",
"@babel/plugin-proposal-json-strings": "^7.18.6",
"@babel/plugin-proposal-logical-assignment-operators": "^7.18.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-numeric-separator": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.18.6",
"@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.18.6",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
"@babel/plugin-proposal-unicode-property-regex": "^7.18.6",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-syntax-class-static-block": "^7.14.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3",
"@babel/plugin-syntax-import-assertions": "^7.18.6",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-syntax-numeric-separator": "^7.10.4",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.0",
"@babel/plugin-syntax-optional-chaining": "^7.8.0",
"@babel/plugin-syntax-top-level-await": "^7.10.4",
"@babel/plugin-transform-arrow-functions": "^7.10.4",
"@babel/plugin-transform-async-to-generator": "^7.10.4",
"@babel/plugin-transform-block-scoped-functions": "^7.10.4",
"@babel/plugin-transform-block-scoping": "^7.10.4",
"@babel/plugin-transform-classes": "^7.10.4",
"@babel/plugin-transform-computed-properties": "^7.10.4",
"@babel/plugin-transform-destructuring": "^7.10.4",
"@babel/plugin-transform-dotall-regex": "^7.10.4",
"@babel/plugin-transform-duplicate-keys": "^7.10.4",
"@babel/plugin-transform-exponentiation-operator": "^7.10.4",
"@babel/plugin-transform-for-of": "^7.10.4",
"@babel/plugin-transform-function-name": "^7.10.4",
"@babel/plugin-transform-literals": "^7.10.4",
"@babel/plugin-transform-member-expression-literals": "^7.10.4",
"@babel/plugin-transform-modules-amd": "^7.10.4",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-modules-systemjs": "^7.10.4",
"@babel/plugin-transform-modules-umd": "^7.10.4",
"@babel/plugin-transform-named-capturing-groups-regex": "^7.10.4",
"@babel/plugin-transform-new-target": "^7.10.4",
"@babel/plugin-transform-object-super": "^7.10.4",
"@babel/plugin-transform-parameters": "^7.10.4",
"@babel/plugin-transform-property-literals": "^7.10.4",
"@babel/plugin-transform-regenerator": "^7.10.4",
"@babel/plugin-transform-reserved-words": "^7.10.4",
"@babel/plugin-transform-shorthand-properties": "^7.10.4",
"@babel/plugin-transform-spread": "^7.10.4",
"@babel/plugin-transform-sticky-regex": "^7.10.4",
"@babel/plugin-transform-template-literals": "^7.10.4",
"@babel/plugin-transform-typeof-symbol": "^7.10.4",
"@babel/plugin-transform-unicode-escapes": "^7.10.4",
"@babel/plugin-transform-unicode-regex": "^7.10.4",
"@babel/preset-modules": "^0.1.3",
"@babel/types": "^7.10.4",
"browserslist": "^4.12.0",
"core-js-compat": "^3.6.2",
"invariant": "^2.2.2",
"levenary": "^1.1.1",
"semver": "^5.5.0"
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-syntax-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-private-property-in-object": "^7.14.5",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/plugin-transform-arrow-functions": "^7.18.6",
"@babel/plugin-transform-async-to-generator": "^7.18.6",
"@babel/plugin-transform-block-scoped-functions": "^7.18.6",
"@babel/plugin-transform-block-scoping": "^7.18.6",
"@babel/plugin-transform-classes": "^7.18.6",
"@babel/plugin-transform-computed-properties": "^7.18.6",
"@babel/plugin-transform-destructuring": "^7.18.6",
"@babel/plugin-transform-dotall-regex": "^7.18.6",
"@babel/plugin-transform-duplicate-keys": "^7.18.6",
"@babel/plugin-transform-exponentiation-operator": "^7.18.6",
"@babel/plugin-transform-for-of": "^7.18.6",
"@babel/plugin-transform-function-name": "^7.18.6",
"@babel/plugin-transform-literals": "^7.18.6",
"@babel/plugin-transform-member-expression-literals": "^7.18.6",
"@babel/plugin-transform-modules-amd": "^7.18.6",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@babel/plugin-transform-modules-systemjs": "^7.18.6",
"@babel/plugin-transform-modules-umd": "^7.18.6",
"@babel/plugin-transform-named-capturing-groups-regex": "^7.18.6",
"@babel/plugin-transform-new-target": "^7.18.6",
"@babel/plugin-transform-object-super": "^7.18.6",
"@babel/plugin-transform-parameters": "^7.18.6",
"@babel/plugin-transform-property-literals": "^7.18.6",
"@babel/plugin-transform-regenerator": "^7.18.6",
"@babel/plugin-transform-reserved-words": "^7.18.6",
"@babel/plugin-transform-shorthand-properties": "^7.18.6",
"@babel/plugin-transform-spread": "^7.18.6",
"@babel/plugin-transform-sticky-regex": "^7.18.6",
"@babel/plugin-transform-template-literals": "^7.18.6",
"@babel/plugin-transform-typeof-symbol": "^7.18.6",
"@babel/plugin-transform-unicode-escapes": "^7.18.6",
"@babel/plugin-transform-unicode-regex": "^7.18.6",
"@babel/preset-modules": "^0.1.5",
"@babel/types": "^7.18.6",
"babel-plugin-polyfill-corejs2": "^0.3.1",
"babel-plugin-polyfill-corejs3": "^0.5.2",
"babel-plugin-polyfill-regenerator": "^0.3.1",
"core-js-compat": "^3.22.1",
"semver": "^6.3.0"
},
"description": "A Babel preset for each environment.",
"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/helper-fixtures": "^7.10.4",
"@babel/helper-plugin-test-runner": "^7.10.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0"
"@babel/core": "^7.18.6",
"@babel/core-7.12": "npm:@babel/core@7.12.9",
"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.6"
},
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df",
"homepage": "https://babeljs.io/",
"engines": {
"node": ">=6.9.0"
},
"homepage": "https://babel.dev/docs/en/next/babel-preset-env",
"license": "MIT",
"main": "lib/index.js",
"main": "./lib/index.js",
"name": "@babel/preset-env",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
@@ -125,5 +137,6 @@
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-preset-env"
},
"version": "7.10.4"
"type": "commonjs",
"version": "7.18.6"
}