Socket
Socket
Sign inDemoInstall

@babel/helper-create-class-features-plugin

Package Overview
Dependencies
Maintainers
5
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-create-class-features-plugin - npm Package Compare versions

Comparing version 7.10.1 to 7.10.2

52

lib/features.js

@@ -20,21 +20,46 @@ "use strict";

exports.FEATURES = FEATURES;
const featuresSameLoose = new Map([[FEATURES.fields, "@babel/plugin-proposal-class-properties"], [FEATURES.privateMethods, "@babel/plugin-proposal-private-methods"], [FEATURES.privateIn, "@babel/plugin-proposal-private-private-property-in-object"]]);
const featuresKey = "@babel/plugin-class-features/featuresKey";
const looseKey = "@babel/plugin-class-features/looseKey";
const looseLowPriorityKey = "@babel/plugin-class-features/looseLowPriorityKey/#__internal__@babel/preset-env__please-overwrite-loose-instead-of-throwing";
function enableFeature(file, feature, loose) {
if (!hasFeature(file, feature)) {
if (!hasFeature(file, feature) || canIgnoreLoose(file, feature)) {
file.set(featuresKey, file.get(featuresKey) | feature);
if (loose) file.set(looseKey, file.get(looseKey) | feature);
}
if (hasFeature(file, FEATURES.fields) && hasFeature(file, FEATURES.privateMethods) && isLoose(file, FEATURES.fields) !== isLoose(file, FEATURES.privateMethods)) {
throw new Error("'loose' mode configuration must be the same for both @babel/plugin-proposal-class-properties " + "and @babel/plugin-proposal-private-methods");
if (loose === "#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, true);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else if (loose === "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error") {
setLoose(file, feature, false);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) | feature);
} else {
setLoose(file, feature, loose);
}
}
if (hasFeature(file, FEATURES.fields) && hasFeature(file, FEATURES.privateIn) && isLoose(file, FEATURES.fields) !== isLoose(file, FEATURES.privateIn)) {
throw new Error("'loose' mode configuration must be the same for both @babel/plugin-proposal-class-properties " + "and @babel/plugin-proposal-private-property-in-object");
let resolvedLoose;
let higherPriorityPluginName;
for (const [mask, name] of featuresSameLoose) {
if (!hasFeature(file, mask)) continue;
const loose = isLoose(file, mask);
if (canIgnoreLoose(file, mask)) {
continue;
} else if (resolvedLoose === !loose) {
throw new Error("'loose' mode configuration must be the same for @babel/plugin-proposal-class-properties, " + "@babel/plugin-proposal-private-methods and " + "@babel/plugin-proposal-private-property-in-object (when they are enabled).");
} else {
resolvedLoose = loose;
higherPriorityPluginName = name;
}
}
if (hasFeature(file, FEATURES.privateMethods) && hasFeature(file, FEATURES.privateIn) && isLoose(file, FEATURES.privateMethods) !== isLoose(file, FEATURES.privateIn)) {
throw new Error("'loose' mode configuration must be the same for both @babel/plugin-proposal-private-methods " + "and @babel/plugin-proposal-private-property-in-object");
if (resolvedLoose !== undefined) {
for (const [mask, name] of featuresSameLoose) {
if (hasFeature(file, mask) && isLoose(file, mask) !== resolvedLoose) {
setLoose(file, mask, resolvedLoose);
console.warn(`Though the "loose" option was set to "${!resolvedLoose}" in your @babel/preset-env ` + `config, it will not be used for ${name} since the "loose" mode option was set to ` + `"${resolvedLoose}" for ${higherPriorityPluginName}.\nThe "loose" option must be the ` + `same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods ` + `and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can ` + `silence this warning by explicitly adding\n` + `\t["${name}", { "loose": ${resolvedLoose} }]\n` + `to the "plugins" section of your Babel config.`);
}
}
}

@@ -51,2 +76,11 @@ }

function setLoose(file, feature, loose) {
if (loose) file.set(looseKey, file.get(looseKey) | feature);else file.set(looseKey, file.get(looseKey) & ~feature);
file.set(looseLowPriorityKey, file.get(looseLowPriorityKey) & ~feature);
}
function canIgnoreLoose(file, feature) {
return !!(file.get(looseLowPriorityKey) & feature);
}
function verifyUsedFeatures(path, file) {

@@ -53,0 +87,0 @@ if ((0, _decorators.hasOwnDecorators)(path.node)) {

6

package.json
{
"name": "@babel/helper-create-class-features-plugin",
"version": "7.10.1",
"version": "7.10.2",
"author": "The Babel Team (https://babeljs.io/team)",

@@ -32,6 +32,6 @@ "license": "MIT",

"devDependencies": {
"@babel/core": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/helper-plugin-test-runner": "^7.10.1"
},
"gitHead": "88f57a7ea659d25232bf62de1efceb5d6299b8cf"
"gitHead": "b0350e5b1e86bd2d53b4a25705e39eb380ec65a2"
}
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