Fixed semver coercing

This commit is contained in:
Miel Truyen 2019-11-14 23:00:40 +01:00
parent 08550a076c
commit 4fd9f6e6a2
6 changed files with 16 additions and 6 deletions

View File

@ -35,7 +35,7 @@
"dependencies": { "dependencies": {
"@babel/code-frame": "^7.5.5", "@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.7.2", "@babel/generator": "^7.7.2",
"@babel/helpers": "csx", "@babel/helpers": "^7.7.0",
"@babel/parser": "^7.7.2", "@babel/parser": "^7.7.2",
"@babel/template": "^7.7.0", "@babel/template": "^7.7.0",
"@babel/traverse": "^7.7.2", "@babel/traverse": "^7.7.2",

View File

@ -70,7 +70,7 @@ function assertVersion(range: string | number): void {
throw new Error("Expected string or integer value."); throw new Error("Expected string or integer value.");
} }
if (semver.satisfies(semver.coerce(coreVersion), range)) return; if (semver.satisfies(semver.coerce(coreVersion).raw, range)) return;
const limit = Error.stackTraceLimit; const limit = Error.stackTraceLimit;

View File

@ -19,7 +19,8 @@
"@babel/helper-optimise-call-expression": "^7.7.0", "@babel/helper-optimise-call-expression": "^7.7.0",
"@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0",
"@babel/helper-replace-supers": "^7.7.0", "@babel/helper-replace-supers": "^7.7.0",
"@babel/helper-split-export-declaration": "^7.7.0" "@babel/helper-split-export-declaration": "^7.7.0",
"semver": "^5.5.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0 || csx" "@babel/core": "^7.0.0 || csx"

View File

@ -1,5 +1,6 @@
import nameFunction from "@babel/helper-function-name"; import nameFunction from "@babel/helper-function-name";
import splitExportDeclaration from "@babel/helper-split-export-declaration"; import splitExportDeclaration from "@babel/helper-split-export-declaration";
import semver from "semver";
import { import {
buildPrivateNamesNodes, buildPrivateNamesNodes,
buildPrivateNamesMap, buildPrivateNamesMap,
@ -27,7 +28,10 @@ export { FEATURES, injectInitialization };
// as 70000100005. This method is easier than using a semver-parsing // as 70000100005. This method is easier than using a semver-parsing
// package, but it breaks if we release x.y.z where x, y or z are // package, but it breaks if we release x.y.z where x, y or z are
// greater than 99_999. // greater than 99_999.
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0); const version = semver
.coerce(pkg.version)
.raw.split(".")
.reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-class-features/version"; const versionKey = "@babel/plugin-class-features/version";
export function createClassFeaturePlugin({ export function createClassFeaturePlugin({

View File

@ -19,7 +19,8 @@
], ],
"dependencies": { "dependencies": {
"@babel/helper-regex": "^7.4.4", "@babel/helper-regex": "^7.4.4",
"regexpu-core": "^4.6.0" "regexpu-core": "^4.6.0",
"semver": "^5.5.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0 || csx" "@babel/core": "^7.0.0 || csx"

View File

@ -1,3 +1,4 @@
import semver from "semver";
import rewritePattern from "regexpu-core"; import rewritePattern from "regexpu-core";
import { import {
featuresKey, featuresKey,
@ -16,7 +17,10 @@ import { pullFlag } from "@babel/helper-regex";
// as 70000100005. This method is easier than using a semver-parsing // as 70000100005. This method is easier than using a semver-parsing
// package, but it breaks if we release x.y.z where x, y or z are // package, but it breaks if we release x.y.z where x, y or z are
// greater than 99_999. // greater than 99_999.
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0); const version = semver
.coerce(pkg.version)
.raw.split(".")
.reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-regexp-features/version"; const versionKey = "@babel/plugin-regexp-features/version";
export function createRegExpFeaturePlugin({ name, feature, options = {} }) { export function createRegExpFeaturePlugin({ name, feature, options = {} }) {