@babel/helper-compilation-targets
Advanced tools
Comparing version 7.21.4-esm.3 to 7.21.4-esm.4
@@ -1,22 +0,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getInclusionReasons = getInclusionReasons; | ||
var _semver = require("semver"); | ||
var _pretty = require("./pretty"); | ||
var _utils = require("./utils"); | ||
function getInclusionReasons(item, targetVersions, list) { | ||
import semver from "semver"; | ||
import { prettifyVersion } from "./pretty.js"; | ||
import { semverify, isUnreleasedVersion, getLowestImplementedVersion } from "./utils.js"; | ||
export function getInclusionReasons(item, targetVersions, list) { | ||
const minVersions = list[item] || {}; | ||
return Object.keys(targetVersions).reduce((result, env) => { | ||
const minVersion = (0, _utils.getLowestImplementedVersion)(minVersions, env); | ||
const minVersion = getLowestImplementedVersion(minVersions, env); | ||
const targetVersion = targetVersions[env]; | ||
if (!minVersion) { | ||
result[env] = (0, _pretty.prettifyVersion)(targetVersion); | ||
result[env] = prettifyVersion(targetVersion); | ||
} else { | ||
const minIsUnreleased = (0, _utils.isUnreleasedVersion)(minVersion, env); | ||
const targetIsUnreleased = (0, _utils.isUnreleasedVersion)(targetVersion, env); | ||
if (!targetIsUnreleased && (minIsUnreleased || _semver.lt(targetVersion.toString(), (0, _utils.semverify)(minVersion)))) { | ||
result[env] = (0, _pretty.prettifyVersion)(targetVersion); | ||
const minIsUnreleased = isUnreleasedVersion(minVersion, env); | ||
const targetIsUnreleased = isUnreleasedVersion(targetVersion, env); | ||
if (!targetIsUnreleased && (minIsUnreleased || semver.lt(targetVersion.toString(), semverify(minVersion)))) { | ||
result[env] = prettifyVersion(targetVersion); | ||
} | ||
@@ -23,0 +17,0 @@ } |
@@ -1,13 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = filterItems; | ||
exports.isRequired = isRequired; | ||
exports.targetsSupported = targetsSupported; | ||
var _semver = require("semver"); | ||
var _plugins = require("@babel/compat-data/plugins"); | ||
var _utils = require("./utils"); | ||
function targetsSupported(target, support) { | ||
import semver from "semver"; | ||
import pluginsCompatData from "@babel/compat-data/plugins"; | ||
import { getLowestImplementedVersion, isUnreleasedVersion, semverify } from "./utils.js"; | ||
export function targetsSupported(target, support) { | ||
const targetEnvironments = Object.keys(target); | ||
@@ -18,3 +10,3 @@ if (targetEnvironments.length === 0) { | ||
const unsupportedEnvironments = targetEnvironments.filter(environment => { | ||
const lowestImplementedVersion = (0, _utils.getLowestImplementedVersion)(support, environment); | ||
const lowestImplementedVersion = getLowestImplementedVersion(support, environment); | ||
if (!lowestImplementedVersion) { | ||
@@ -24,17 +16,17 @@ return true; | ||
const lowestTargetedVersion = target[environment]; | ||
if ((0, _utils.isUnreleasedVersion)(lowestTargetedVersion, environment)) { | ||
if (isUnreleasedVersion(lowestTargetedVersion, environment)) { | ||
return false; | ||
} | ||
if ((0, _utils.isUnreleasedVersion)(lowestImplementedVersion, environment)) { | ||
if (isUnreleasedVersion(lowestImplementedVersion, environment)) { | ||
return true; | ||
} | ||
if (!_semver.valid(lowestTargetedVersion.toString())) { | ||
if (!semver.valid(lowestTargetedVersion.toString())) { | ||
throw new Error(`Invalid version passed for target "${environment}": "${lowestTargetedVersion}". ` + "Versions must be in semver format (major.minor.patch)"); | ||
} | ||
return _semver.gt((0, _utils.semverify)(lowestImplementedVersion), lowestTargetedVersion.toString()); | ||
return semver.gt(semverify(lowestImplementedVersion), lowestTargetedVersion.toString()); | ||
}); | ||
return unsupportedEnvironments.length === 0; | ||
} | ||
function isRequired(name, targets, { | ||
compatData = _plugins, | ||
export function isRequired(name, targets, { | ||
compatData = pluginsCompatData, | ||
includes, | ||
@@ -47,3 +39,3 @@ excludes | ||
} | ||
function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) { | ||
export default function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) { | ||
const result = new Set(); | ||
@@ -50,0 +42,0 @@ const options = { |
108
lib/index.js
@@ -1,62 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "TargetNames", { | ||
enumerable: true, | ||
get: function () { | ||
return _options.TargetNames; | ||
} | ||
}); | ||
exports.default = getTargets; | ||
Object.defineProperty(exports, "filterItems", { | ||
enumerable: true, | ||
get: function () { | ||
return _filterItems.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getInclusionReasons", { | ||
enumerable: true, | ||
get: function () { | ||
return _debug.getInclusionReasons; | ||
} | ||
}); | ||
exports.isBrowsersQueryValid = isBrowsersQueryValid; | ||
Object.defineProperty(exports, "isRequired", { | ||
enumerable: true, | ||
get: function () { | ||
return _filterItems.isRequired; | ||
} | ||
}); | ||
Object.defineProperty(exports, "prettifyTargets", { | ||
enumerable: true, | ||
get: function () { | ||
return _pretty.prettifyTargets; | ||
} | ||
}); | ||
Object.defineProperty(exports, "unreleasedLabels", { | ||
enumerable: true, | ||
get: function () { | ||
return _targets.unreleasedLabels; | ||
} | ||
}); | ||
var _browserslist = require("browserslist"); | ||
var _helperValidatorOption = require("@babel/helper-validator-option"); | ||
var _nativeModules = require("@babel/compat-data/native-modules"); | ||
var _lruCache = require("lru-cache"); | ||
var _utils = require("./utils"); | ||
var _targets = require("./targets"); | ||
var _options = require("./options"); | ||
var _pretty = require("./pretty"); | ||
var _debug = require("./debug"); | ||
var _filterItems = require("./filter-items"); | ||
const ESM_SUPPORT = _nativeModules["es6.module"]; | ||
const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets"); | ||
import browserslist from "browserslist"; | ||
import { findSuggestion } from "@babel/helper-validator-option"; | ||
import browserModulesData from "@babel/compat-data/native-modules"; | ||
import LruCache from "lru-cache"; | ||
import { semverify, semverMin, isUnreleasedVersion, getLowestUnreleased, getHighestUnreleased } from "./utils.js"; | ||
import { OptionValidator } from "@babel/helper-validator-option"; | ||
import { browserNameMap } from "./targets.js"; | ||
import { TargetNames } from "./options.js"; | ||
export { prettifyTargets } from "./pretty.js"; | ||
export { getInclusionReasons } from "./debug.js"; | ||
export { default as filterItems, isRequired } from "./filter-items.js"; | ||
export { unreleasedLabels } from "./targets.js"; | ||
export { TargetNames }; | ||
const ESM_SUPPORT = browserModulesData["es6.module"]; | ||
const v = new OptionValidator("@babel/helper-compilation-targets"); | ||
function validateTargetNames(targets) { | ||
const validTargets = Object.keys(_options.TargetNames); | ||
const validTargets = Object.keys(TargetNames); | ||
for (const target of Object.keys(targets)) { | ||
if (!(target in _options.TargetNames)) { | ||
if (!(target in TargetNames)) { | ||
throw new Error(v.formatMessage(`'${target}' is not a valid target | ||
- Did you mean '${(0, _helperValidatorOption.findSuggestion)(target, validTargets)}'?`)); | ||
- Did you mean '${findSuggestion(target, validTargets)}'?`)); | ||
} | ||
@@ -66,3 +26,3 @@ } | ||
} | ||
function isBrowsersQueryValid(browsers) { | ||
export function isBrowsersQueryValid(browsers) { | ||
return typeof browsers === "string" || Array.isArray(browsers) && browsers.every(b => typeof b === "string"); | ||
@@ -77,3 +37,3 @@ } | ||
const [browserName, browserVersion] = browser.split(" "); | ||
const target = _targets.browserNameMap[browserName]; | ||
const target = browserNameMap[browserName]; | ||
if (!target) { | ||
@@ -84,16 +44,16 @@ return all; | ||
const splitVersion = browserVersion.split("-")[0].toLowerCase(); | ||
const isSplitUnreleased = (0, _utils.isUnreleasedVersion)(splitVersion, target); | ||
const isSplitUnreleased = isUnreleasedVersion(splitVersion, target); | ||
if (!all[target]) { | ||
all[target] = isSplitUnreleased ? splitVersion : (0, _utils.semverify)(splitVersion); | ||
all[target] = isSplitUnreleased ? splitVersion : semverify(splitVersion); | ||
return all; | ||
} | ||
const version = all[target]; | ||
const isUnreleased = (0, _utils.isUnreleasedVersion)(version, target); | ||
const isUnreleased = isUnreleasedVersion(version, target); | ||
if (isUnreleased && isSplitUnreleased) { | ||
all[target] = (0, _utils.getLowestUnreleased)(version, splitVersion, target); | ||
all[target] = getLowestUnreleased(version, splitVersion, target); | ||
} else if (isUnreleased) { | ||
all[target] = (0, _utils.semverify)(splitVersion); | ||
all[target] = semverify(splitVersion); | ||
} else if (!isUnreleased && !isSplitUnreleased) { | ||
const parsedBrowserVersion = (0, _utils.semverify)(splitVersion); | ||
all[target] = (0, _utils.semverMin)(version, parsedBrowserVersion); | ||
const parsedBrowserVersion = semverify(splitVersion); | ||
all[target] = semverMin(version, parsedBrowserVersion); | ||
} | ||
@@ -120,3 +80,3 @@ } catch (e) {} | ||
try { | ||
return (0, _utils.semverify)(value); | ||
return semverify(value); | ||
} catch (error) { | ||
@@ -131,3 +91,3 @@ throw new Error(v.formatMessage(`'${value}' is not a valid value for 'targets.${target}'.`)); | ||
function defaultTargetParser(target, value) { | ||
const version = (0, _utils.isUnreleasedVersion)(value, target) ? value.toLowerCase() : semverifyTarget(target, value); | ||
const version = isUnreleasedVersion(value, target) ? value.toLowerCase() : semverifyTarget(target, value); | ||
return [target, version]; | ||
@@ -142,3 +102,3 @@ } | ||
function resolveTargets(queries, env) { | ||
const resolved = _browserslist(queries, { | ||
const resolved = browserslist(queries, { | ||
mobileToDesktop: true, | ||
@@ -149,3 +109,3 @@ env | ||
} | ||
const targetsCache = new _lruCache({ | ||
const targetsCache = new LruCache({ | ||
max: 64 | ||
@@ -162,3 +122,3 @@ }); | ||
} | ||
function getTargets(inputTargets = {}, options = {}) { | ||
export default function getTargets(inputTargets = {}, options = {}) { | ||
var _browsers, _browsers2; | ||
@@ -179,3 +139,3 @@ let { | ||
if (!browsers && shouldSearchForConfig) { | ||
browsers = _browserslist.loadConfig({ | ||
browsers = browserslist.loadConfig({ | ||
config: options.configFile, | ||
@@ -202,3 +162,3 @@ path: configPath, | ||
if (esmSupportVersion) { | ||
queryBrowsers[browser] = (0, _utils.getHighestUnreleased)(version, (0, _utils.semverify)(esmSupportVersion), browser); | ||
queryBrowsers[browser] = getHighestUnreleased(version, semverify(esmSupportVersion), browser); | ||
} else { | ||
@@ -205,0 +165,0 @@ delete queryBrowsers[browser]; |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TargetNames = void 0; | ||
const TargetNames = { | ||
export const TargetNames = { | ||
node: "node", | ||
@@ -22,4 +16,3 @@ deno: "deno", | ||
}; | ||
exports.TargetNames = TargetNames; | ||
//# sourceMappingURL=options.js.map |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.prettifyTargets = prettifyTargets; | ||
exports.prettifyVersion = prettifyVersion; | ||
var _semver = require("semver"); | ||
var _targets = require("./targets"); | ||
function prettifyVersion(version) { | ||
import semver from "semver"; | ||
import { unreleasedLabels } from "./targets.js"; | ||
export function prettifyVersion(version) { | ||
if (typeof version !== "string") { | ||
@@ -18,3 +11,3 @@ return version; | ||
patch | ||
} = _semver.parse(version); | ||
} = semver.parse(version); | ||
const parts = [major]; | ||
@@ -29,6 +22,6 @@ if (minor || patch) { | ||
} | ||
function prettifyTargets(targets) { | ||
export function prettifyTargets(targets) { | ||
return Object.keys(targets).reduce((results, target) => { | ||
let value = targets[target]; | ||
const unreleasedLabel = _targets.unreleasedLabels[target]; | ||
const unreleasedLabel = unreleasedLabels[target]; | ||
if (typeof value === "string" && unreleasedLabel !== value) { | ||
@@ -35,0 +28,0 @@ value = prettifyVersion(value); |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.unreleasedLabels = exports.browserNameMap = void 0; | ||
const unreleasedLabels = { | ||
export const unreleasedLabels = { | ||
safari: "tp" | ||
}; | ||
exports.unreleasedLabels = unreleasedLabels; | ||
const browserNameMap = { | ||
export const browserNameMap = { | ||
and_chr: "chrome", | ||
@@ -28,4 +21,3 @@ and_ff: "firefox", | ||
}; | ||
exports.browserNameMap = browserNameMap; | ||
//# sourceMappingURL=targets.js.map |
@@ -1,22 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getHighestUnreleased = getHighestUnreleased; | ||
exports.getLowestImplementedVersion = getLowestImplementedVersion; | ||
exports.getLowestUnreleased = getLowestUnreleased; | ||
exports.isUnreleasedVersion = isUnreleasedVersion; | ||
exports.semverMin = semverMin; | ||
exports.semverify = semverify; | ||
var _semver = require("semver"); | ||
var _helperValidatorOption = require("@babel/helper-validator-option"); | ||
var _targets = require("./targets"); | ||
import semver from "semver"; | ||
import { OptionValidator } from "@babel/helper-validator-option"; | ||
import { unreleasedLabels } from "./targets.js"; | ||
const versionRegExp = /^(\d+|\d+.\d+)$/; | ||
const v = new _helperValidatorOption.OptionValidator("@babel/helper-compilation-targets"); | ||
function semverMin(first, second) { | ||
return first && _semver.lt(first, second) ? first : second; | ||
const v = new OptionValidator("@babel/helper-compilation-targets"); | ||
export function semverMin(first, second) { | ||
return first && semver.lt(first, second) ? first : second; | ||
} | ||
function semverify(version) { | ||
if (typeof version === "string" && _semver.valid(version)) { | ||
export function semverify(version) { | ||
if (typeof version === "string" && semver.valid(version)) { | ||
return version; | ||
@@ -33,8 +22,8 @@ } | ||
} | ||
function isUnreleasedVersion(version, env) { | ||
const unreleasedLabel = _targets.unreleasedLabels[env]; | ||
export function isUnreleasedVersion(version, env) { | ||
const unreleasedLabel = unreleasedLabels[env]; | ||
return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase(); | ||
} | ||
function getLowestUnreleased(a, b, env) { | ||
const unreleasedLabel = _targets.unreleasedLabels[env]; | ||
export function getLowestUnreleased(a, b, env) { | ||
const unreleasedLabel = unreleasedLabels[env]; | ||
if (a === unreleasedLabel) { | ||
@@ -48,6 +37,6 @@ return b; | ||
} | ||
function getHighestUnreleased(a, b, env) { | ||
export function getHighestUnreleased(a, b, env) { | ||
return getLowestUnreleased(a, b, env) === a ? b : a; | ||
} | ||
function getLowestImplementedVersion(plugin, environment) { | ||
export function getLowestImplementedVersion(plugin, environment) { | ||
const result = plugin[environment]; | ||
@@ -54,0 +43,0 @@ if (!result && environment === "android") { |
{ | ||
"name": "@babel/helper-compilation-targets", | ||
"version": "7.21.4-esm.3", | ||
"version": "7.21.4-esm.4", | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
@@ -25,4 +25,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@babel/compat-data": "7.21.4-esm.3", | ||
"@babel/helper-validator-option": "7.21.4-esm.3", | ||
"@babel/compat-data": "7.21.4-esm.4", | ||
"@babel/helper-validator-option": "7.21.4-esm.4", | ||
"browserslist": "^4.21.3", | ||
@@ -36,4 +36,4 @@ "lru-cache": "^5.1.1", | ||
"devDependencies": { | ||
"@babel/core": "7.21.4-esm.3", | ||
"@babel/helper-plugin-test-runner": "7.21.4-esm.3", | ||
"@babel/core": "7.21.4-esm.4", | ||
"@babel/helper-plugin-test-runner": "7.21.4-esm.4", | ||
"@types/lru-cache": "^5.1.1", | ||
@@ -40,0 +40,0 @@ "@types/semver": "^5.5.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18
49510
377
+ Added@babel/compat-data@7.21.4-esm.4(transitive)
+ Added@babel/helper-validator-option@7.21.4-esm.4(transitive)
- Removed@babel/compat-data@7.21.4-esm.3(transitive)
- Removed@babel/helper-validator-option@7.21.4-esm.3(transitive)