Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/helper-compilation-targets

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-compilation-targets - npm Package Compare versions

Comparing version 7.22.9 to 8.0.0-alpha.0

26

lib/debug.js

@@ -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,25 +16,25 @@ 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,
excludes
} = {}) {
if (excludes != null && excludes.has(name)) return false;
if (includes != null && includes.has(name)) return true;
if (excludes?.has(name)) return false;
if (includes?.has(name)) return true;
return !targetsSupported(targets, compatData[name]);
}
function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) {
export default function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) {
const result = new Set();

@@ -64,4 +56,4 @@ const options = {

}
defaultIncludes == null ? void 0 : defaultIncludes.forEach(item => !excludes.has(item) && result.add(item));
defaultExcludes == null ? void 0 : defaultExcludes.forEach(item => !includes.has(item) && result.delete(item));
defaultIncludes?.forEach(item => !excludes.has(item) && result.add(item));
defaultExcludes?.forEach(item => !includes.has(item) && result.delete(item));
return result;

@@ -68,0 +60,0 @@ }

@@ -1,62 +0,200 @@

"use strict";
import browserslist from 'browserslist';
import { OptionValidator, findSuggestion } from '@babel/helper-validator-option';
import browserModulesData from '@babel/compat-data/native-modules';
import LruCache from 'lru-cache';
import semver from 'semver';
import pluginsCompatData from '@babel/compat-data/plugins';
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "TargetNames", {
enumerable: true,
get: function () {
return _options.TargetNames;
const unreleasedLabels = {
safari: "tp"
};
const browserNameMap = {
and_chr: "chrome",
and_ff: "firefox",
android: "android",
chrome: "chrome",
edge: "edge",
firefox: "firefox",
ie: "ie",
ie_mob: "ie",
ios_saf: "ios",
node: "node",
deno: "deno",
op_mob: "opera_mobile",
opera: "opera",
safari: "safari",
samsung: "samsung"
};
const versionRegExp = /^(\d+|\d+.\d+)$/;
const v$1 = new OptionValidator("@babel/helper-compilation-targets");
function semverMin(first, second) {
return first && semver.lt(first, second) ? first : second;
}
function semverify(version) {
if (typeof version === "string" && semver.valid(version)) {
return version;
}
});
exports.default = getTargets;
Object.defineProperty(exports, "filterItems", {
enumerable: true,
get: function () {
return _filterItems.default;
v$1.invariant(typeof version === "number" || typeof version === "string" && versionRegExp.test(version), `'${version}' is not a valid version`);
version = version.toString();
let pos = 0;
let num = 0;
while ((pos = version.indexOf(".", pos + 1)) > 0) {
num++;
}
});
Object.defineProperty(exports, "getInclusionReasons", {
enumerable: true,
get: function () {
return _debug.getInclusionReasons;
return version + ".0".repeat(2 - num);
}
function isUnreleasedVersion(version, env) {
const unreleasedLabel = unreleasedLabels[env];
return !!unreleasedLabel && unreleasedLabel === version.toString().toLowerCase();
}
function getLowestUnreleased(a, b, env) {
const unreleasedLabel = unreleasedLabels[env];
if (a === unreleasedLabel) {
return b;
}
});
exports.isBrowsersQueryValid = isBrowsersQueryValid;
Object.defineProperty(exports, "isRequired", {
enumerable: true,
get: function () {
return _filterItems.isRequired;
if (b === unreleasedLabel) {
return a;
}
});
Object.defineProperty(exports, "prettifyTargets", {
enumerable: true,
get: function () {
return _pretty.prettifyTargets;
return semverMin(a, b);
}
function getHighestUnreleased(a, b, env) {
return getLowestUnreleased(a, b, env) === a ? b : a;
}
function getLowestImplementedVersion(plugin, environment) {
const result = plugin[environment];
if (!result && environment === "android") {
return plugin.chrome;
}
});
Object.defineProperty(exports, "unreleasedLabels", {
enumerable: true,
get: function () {
return _targets.unreleasedLabels;
return result;
}
const TargetNames = {
node: "node",
deno: "deno",
chrome: "chrome",
opera: "opera",
edge: "edge",
firefox: "firefox",
safari: "safari",
ie: "ie",
ios: "ios",
android: "android",
electron: "electron",
samsung: "samsung",
rhino: "rhino",
opera_mobile: "opera_mobile"
};
function prettifyVersion(version) {
if (typeof version !== "string") {
return version;
}
});
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");
const {
major,
minor,
patch
} = semver.parse(version);
const parts = [major];
if (minor || patch) {
parts.push(minor);
}
if (patch) {
parts.push(patch);
}
return parts.join(".");
}
function prettifyTargets(targets) {
return Object.keys(targets).reduce((results, target) => {
let value = targets[target];
const unreleasedLabel = unreleasedLabels[target];
if (typeof value === "string" && unreleasedLabel !== value) {
value = prettifyVersion(value);
}
results[target] = value;
return results;
}, {});
}
function getInclusionReasons(item, targetVersions, list) {
const minVersions = list[item] || {};
return Object.keys(targetVersions).reduce((result, env) => {
const minVersion = getLowestImplementedVersion(minVersions, env);
const targetVersion = targetVersions[env];
if (!minVersion) {
result[env] = prettifyVersion(targetVersion);
} else {
const minIsUnreleased = isUnreleasedVersion(minVersion, env);
const targetIsUnreleased = isUnreleasedVersion(targetVersion, env);
if (!targetIsUnreleased && (minIsUnreleased || semver.lt(targetVersion.toString(), semverify(minVersion)))) {
result[env] = prettifyVersion(targetVersion);
}
}
return result;
}, {});
}
function targetsSupported(target, support) {
const targetEnvironments = Object.keys(target);
if (targetEnvironments.length === 0) {
return false;
}
const unsupportedEnvironments = targetEnvironments.filter(environment => {
const lowestImplementedVersion = getLowestImplementedVersion(support, environment);
if (!lowestImplementedVersion) {
return true;
}
const lowestTargetedVersion = target[environment];
if (isUnreleasedVersion(lowestTargetedVersion, environment)) {
return false;
}
if (isUnreleasedVersion(lowestImplementedVersion, environment)) {
return true;
}
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(semverify(lowestImplementedVersion), lowestTargetedVersion.toString());
});
return unsupportedEnvironments.length === 0;
}
function isRequired(name, targets, {
compatData = pluginsCompatData,
includes,
excludes
} = {}) {
if (excludes?.has(name)) return false;
if (includes?.has(name)) return true;
return !targetsSupported(targets, compatData[name]);
}
function filterItems(list, includes, excludes, targets, defaultIncludes, defaultExcludes, pluginSyntaxMap) {
const result = new Set();
const options = {
compatData: list,
includes,
excludes
};
for (const item in list) {
if (isRequired(item, targets, options)) {
result.add(item);
} else if (pluginSyntaxMap) {
const shippedProposalsSyntax = pluginSyntaxMap.get(item);
if (shippedProposalsSyntax) {
result.add(shippedProposalsSyntax);
}
}
}
defaultIncludes?.forEach(item => !excludes.has(item) && result.add(item));
defaultExcludes?.forEach(item => !includes.has(item) && result.delete(item));
return result;
}
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)}'?`));
}

@@ -76,3 +214,3 @@ }

const [browserName, browserVersion] = browser.split(" ");
const target = _targets.browserNameMap[browserName];
const target = browserNameMap[browserName];
if (!target) {

@@ -83,16 +221,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);
}

@@ -119,3 +257,3 @@ } catch (e) {}

try {
return (0, _utils.semverify)(value);
return semverify(value);
} catch (error) {

@@ -130,3 +268,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];

@@ -141,3 +279,3 @@ }

function resolveTargets(queries, env) {
const resolved = _browserslist(queries, {
const resolved = browserslist(queries, {
mobileToDesktop: true,

@@ -148,3 +286,3 @@ env

}
const targetsCache = new _lruCache({
const targetsCache = new LruCache({
max: 64

@@ -162,3 +300,2 @@ });

function getTargets(inputTargets = {}, options = {}) {
var _browsers, _browsers2;
let {

@@ -178,3 +315,3 @@ browsers,

if (!browsers && shouldSearchForConfig) {
browsers = _browserslist.loadConfig({
browsers = browserslist.loadConfig({
config: options.configFile,

@@ -186,11 +323,11 @@ path: configPath,

{
browsers = [];
browsers = ["defaults"];
}
}
}
if (esmodules && (esmodules !== "intersect" || !((_browsers = browsers) != null && _browsers.length))) {
if (esmodules && (esmodules !== "intersect" || !browsers?.length)) {
browsers = Object.keys(ESM_SUPPORT).map(browser => `${browser} >= ${ESM_SUPPORT[browser]}`).join(", ");
esmodules = false;
}
if ((_browsers2 = browsers) != null && _browsers2.length) {
if (browsers?.length) {
const queryBrowsers = resolveTargetsCached(browsers, options.browserslistEnv);

@@ -203,3 +340,3 @@ if (esmodules === "intersect") {

const version = queryBrowsers[browser];
queryBrowsers[browser] = (0, _utils.getHighestUnreleased)(version, (0, _utils.semverify)(esmSupportVersion), browser);
queryBrowsers[browser] = getHighestUnreleased(version, semverify(esmSupportVersion), browser);
} else {

@@ -234,2 +371,3 @@ delete queryBrowsers[browser];

export { TargetNames, getTargets as default, filterItems, getInclusionReasons, isBrowsersQueryValid, isRequired, prettifyTargets, unreleasedLabels };
//# sourceMappingURL=index.js.map

@@ -1,8 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.TargetNames = void 0;
const TargetNames = {
export const TargetNames = {
node: "node",

@@ -23,4 +17,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.22.9",
"version": "8.0.0-alpha.0",
"author": "The Babel Team (https://babel.dev/team)",

@@ -25,14 +25,14 @@ "license": "MIT",

"dependencies": {
"@babel/compat-data": "^7.22.9",
"@babel/helper-validator-option": "^7.22.5",
"@babel/compat-data": "^8.0.0-alpha.0",
"@babel/helper-validator-option": "^8.0.0-alpha.0",
"browserslist": "^4.21.9",
"lru-cache": "^5.1.1",
"semver": "^6.3.1"
"lru-cache": "^7.14.1",
"semver": "^7.3.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
"@babel/core": "^8.0.0-alpha.0"
},
"devDependencies": {
"@babel/core": "^7.22.9",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/core": "^8.0.0-alpha.0",
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.0",
"@types/lru-cache": "^5.1.1",

@@ -42,5 +42,5 @@ "@types/semver": "^5.5.0"

"engines": {
"node": ">=6.9.0"
"node": "^16.20.0 || ^18.16.0 || >=20.0.0"
},
"type": "commonjs"
"type": "module"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc