Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
Maintainers
6
Versions
108
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.14.2 to 7.14.3

11

lib/features.js

@@ -17,3 +17,4 @@ "use strict";

decorators: 1 << 3,
privateIn: 1 << 4
privateIn: 1 << 4,
staticBlocks: 1 << 5
});

@@ -96,3 +97,3 @@ exports.FEATURES = FEATURES;

if (path.isPrivate() && path.isMethod()) {
if (path.isPrivateMethod != null && path.isPrivateMethod()) {
if (!hasFeature(file, FEATURES.privateMethods)) {

@@ -117,2 +118,8 @@ throw path.buildCodeFrameError("Class private methods are not enabled.");

}
if (path.isStaticBlock != null && path.isStaticBlock()) {
if (!hasFeature(file, FEATURES.staticBlocks)) {
throw path.buildCodeFrameError("Static class blocks are not enabled. " + "Please add `@babel/plugin-proposal-class-static-block` to your configuration.");
}
}
}

@@ -644,3 +644,3 @@ "use strict";

function replaceThisContext(path, ref, superRef, file, constantSuper) {
function replaceThisContext(path, ref, getSuperRef, file, isStaticBlock, constantSuper) {
const state = {

@@ -653,9 +653,9 @@ classRef: ref,

constantSuper,
superRef,
file,
refToPreserve: ref,
getSuperRef,
getObjectRef() {
state.needsClassRef = true;
return path.node.static ? ref : _core.types.memberExpression(ref, _core.types.identifier("prototype"));
return isStaticBlock || path.node.static ? ref : _core.types.memberExpression(ref, _core.types.identifier("prototype"));
}

@@ -666,3 +666,3 @@

if (path.isProperty()) {
if (isStaticBlock || path.isProperty()) {
path.traverse(thisContextVisitor, state);

@@ -676,6 +676,13 @@ }

let needsClassRef = false;
let injectSuperRef;
const staticNodes = [];
const instanceNodes = [];
const pureStaticNodes = [];
const getSuperRef = _core.types.isIdentifier(superRef) ? () => superRef : () => {
var _injectSuperRef;
(_injectSuperRef = injectSuperRef) != null ? _injectSuperRef : injectSuperRef = props[0].scope.generateUidIdentifierBasedOnNode(superRef);
return injectSuperRef;
};
for (const prop of props) {

@@ -689,5 +696,6 @@ ts.assertFieldTransformed(prop);

const isMethod = !isField;
const isStaticBlock = prop.isStaticBlock == null ? void 0 : prop.isStaticBlock();
if (isStatic || isMethod && isPrivate) {
const replaced = replaceThisContext(prop, ref, superRef, state, constantSuper);
if (isStatic || isMethod && isPrivate || isStaticBlock) {
const replaced = replaceThisContext(prop, ref, getSuperRef, state, isStaticBlock, constantSuper);
needsClassRef = needsClassRef || replaced;

@@ -697,2 +705,6 @@ }

switch (true) {
case isStaticBlock:
staticNodes.push(_core.template.statement.ast`(() => ${_core.types.blockStatement(prop.node.body)})()`);
break;
case isStatic && isPrivate && isField && privateFieldsAsProperties:

@@ -771,2 +783,9 @@ needsClassRef = true;

if (injectSuperRef) {
path.scope.push({
id: _core.types.cloneNode(injectSuperRef)
});
path.set("superClass", _core.types.assignmentExpression("=", injectSuperRef, path.node.superClass));
}
if (!needsClassRef) return path;

@@ -773,0 +792,0 @@

16

lib/index.js

@@ -40,3 +40,3 @@ "use strict";

const version = "7.14.2".split(".").reduce((v, x) => v * 1e5 + +x, 0);
const version = "7.14.3".split(".").reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-class-features/version";

@@ -141,3 +141,3 @@

if (path.isProperty() || path.isPrivate()) {
if (path.isProperty() || path.isPrivate() || path.isStaticBlock != null && path.isStaticBlock()) {
props.push(path);

@@ -148,14 +148,2 @@ }

if (!isDecorated) isDecorated = (0, _decorators.hasOwnDecorators)(path.node);
if (path.isStaticBlock != null && path.isStaticBlock()) {
throw path.buildCodeFrameError(`Incorrect plugin order, \`@babel/plugin-proposal-class-static-block\` should be placed before class features plugins
{
"plugins": [
"@babel/plugin-proposal-class-static-block",
"@babel/plugin-proposal-private-property-in-object",
"@babel/plugin-proposal-private-methods",
"@babel/plugin-proposal-class-properties",
]
}`);
}
}

@@ -162,0 +150,0 @@

{
"name": "@babel/helper-create-class-features-plugin",
"version": "7.14.2",
"version": "7.14.3",
"author": "The Babel Team (https://babel.dev/team)",

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

"@babel/helper-optimise-call-expression": "^7.12.13",
"@babel/helper-replace-supers": "^7.13.12",
"@babel/helper-replace-supers": "^7.14.3",
"@babel/helper-split-export-declaration": "^7.12.13"

@@ -33,3 +33,3 @@ },

"devDependencies": {
"@babel/core": "7.14.2",
"@babel/core": "7.14.3",
"@babel/helper-plugin-test-runner": "7.13.10",

@@ -36,0 +36,0 @@ "@babel/preset-env": "7.14.2"

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