[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports.hasMinVersion = hasMinVersion;
|
---|
| 5 | var _semver = _interopRequireDefault(require("semver"));
|
---|
| 6 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 7 | function hasMinVersion(minVersion, runtimeVersion) {
|
---|
| 8 | // If the range is unavailable, we're running the script during Babel's
|
---|
| 9 | // build process, and we want to assume that all versions are satisfied so
|
---|
| 10 | // that the built output will include all definitions.
|
---|
| 11 | if (!runtimeVersion || !minVersion) return true;
|
---|
| 12 | runtimeVersion = String(runtimeVersion);
|
---|
| 13 |
|
---|
| 14 | // semver.intersects() has some surprising behavior with comparing ranges
|
---|
| 15 | // with preprelease versions. We add '^' to ensure that we are always
|
---|
| 16 | // comparing ranges with ranges, which sidesteps this logic.
|
---|
| 17 | // For example:
|
---|
| 18 | //
|
---|
| 19 | // semver.intersects(`<7.0.1`, "7.0.0-beta.0") // false - surprising
|
---|
| 20 | // semver.intersects(`<7.0.1`, "^7.0.0-beta.0") // true - expected
|
---|
| 21 | //
|
---|
| 22 | // This is because the first falls back to
|
---|
| 23 | //
|
---|
| 24 | // semver.satisfies("7.0.0-beta.0", `<7.0.1`) // false - surprising
|
---|
| 25 | //
|
---|
| 26 | // and this fails because a prerelease version can only satisfy a range
|
---|
| 27 | // if it is a prerelease within the same major/minor/patch range.
|
---|
| 28 | //
|
---|
| 29 | // Note: If this is found to have issues, please also revist the logic in
|
---|
| 30 | // babel-core's availableHelper() API.
|
---|
| 31 | if (_semver.default.valid(runtimeVersion)) runtimeVersion = `^${runtimeVersion}`;
|
---|
| 32 | return !_semver.default.intersects(`<${minVersion}`, runtimeVersion) && !_semver.default.intersects(`>=8.0.0`, runtimeVersion);
|
---|
| 33 | } |
---|