Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
Maintainers
4
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.17.12 to 7.18.0

24

lib/decorators.js

@@ -54,7 +54,3 @@ "use strict";

function extractElementDescriptor(classRef, superRef, path) {
const {
node,
scope
} = path;
function extractElementDescriptor(file, classRef, superRef, path) {
const isMethod = path.isClassMethod();

@@ -66,2 +62,14 @@

if (path.node.type === "ClassAccessorProperty") {
throw path.buildCodeFrameError(`Accessor properties are not supported in 2018-09 decorator transform, please specify { "version": "2021-12" } instead.`);
}
if (path.node.type === "StaticBlock") {
throw path.buildCodeFrameError(`Static blocks are not supported in 2018-09 decorator transform, please specify { "version": "2021-12" } instead.`);
}
const {
node,
scope
} = path;
new _helperReplaceSupers.default({

@@ -71,6 +79,6 @@ methodPath: path,

superRef,
file: this,
file,
refToPreserve: classRef
}).replace();
const properties = [prop("kind", _core.types.stringLiteral(_core.types.isClassMethod(node) ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", !(_core.types.isStaticBlock != null && _core.types.isStaticBlock(node)) && node.static && _core.types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean);
const properties = [prop("kind", _core.types.stringLiteral(_core.types.isClassMethod(node) ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", node.static && _core.types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean);

@@ -131,3 +139,3 @@ if (_core.types.isClassMethod(node)) {

const definitions = _core.types.arrayExpression(elements.filter(element => !element.node.abstract).map(extractElementDescriptor.bind(file, node.id, superId)));
const definitions = _core.types.arrayExpression(elements.filter(element => !element.node.abstract && element.node.type !== "TSIndexSignature").map(path => extractElementDescriptor(file, node.id, superId, path)));

@@ -134,0 +142,0 @@ const wrapperCall = _core.template.expression.ast`

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

if (privateMethodPath && !hasFeature(file, FEATURES.privateMethods)) {
throw privateMethodPath.buildCodeFrameError("Class private methods are not enabled. " + "Please add `@babel/plugin-proposal-private-method` to your configuration.");
throw privateMethodPath.buildCodeFrameError("Class private methods are not enabled. " + "Please add `@babel/plugin-proposal-private-methods` to your configuration.");
}

@@ -134,0 +134,0 @@

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

if ((_state$classRef = state.classRef) != null && _state$classRef.name && state.classRef.name !== (innerBindingRef == null ? void 0 : innerBindingRef.name)) {
if (innerBindingRef != null && (_state$classRef = state.classRef) != null && _state$classRef.name && state.classRef.name !== (innerBindingRef == null ? void 0 : innerBindingRef.name)) {
path.traverse(innerReferencesVisitor, state);

@@ -772,0 +772,0 @@ }

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

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

@@ -82,7 +82,7 @@

pre() {
(0, _features.enableFeature)(this.file, feature, loose);
pre(file) {
(0, _features.enableFeature)(file, feature, loose);
if (!this.file.get(versionKey) || this.file.get(versionKey) < version) {
this.file.set(versionKey, version);
if (!file.get(versionKey) || file.get(versionKey) < version) {
file.set(versionKey, version);
}

@@ -92,7 +92,9 @@ },

visitor: {
Class(path, state) {
if (this.file.get(versionKey) !== version) return;
if (!(0, _features.shouldTransform)(path, this.file)) return;
Class(path, {
file
}) {
if (file.get(versionKey) !== version) return;
if (!(0, _features.shouldTransform)(path, file)) return;
if (path.isClassDeclaration()) (0, _typescript.assertFieldTransformed)(path);
const loose = (0, _features.isLoose)(this.file, feature);
const loose = (0, _features.isLoose)(file, feature);
let constructor;

@@ -166,3 +168,3 @@ const isDecorated = (0, _decorators.hasDecorators)(path.node);

const privateNamesMap = (0, _fields.buildPrivateNamesMap)(props);
const privateNamesNodes = (0, _fields.buildPrivateNamesNodes)(privateNamesMap, privateFieldsAsProperties != null ? privateFieldsAsProperties : loose, state);
const privateNamesNodes = (0, _fields.buildPrivateNamesNodes)(privateNamesMap, privateFieldsAsProperties != null ? privateFieldsAsProperties : loose, file);
(0, _fields.transformPrivateNamesUsage)(ref, path, privateNamesMap, {

@@ -172,3 +174,3 @@ privateFieldsAsProperties: privateFieldsAsProperties != null ? privateFieldsAsProperties : loose,

innerBinding
}, state);
}, file);
let keysNodes, staticNodes, instanceNodes, pureStaticNodes, wrapClass;

@@ -181,5 +183,5 @@

wrapClass
} = (0, _decorators.buildDecoratedClass)(ref, path, elements, this.file));
} = (0, _decorators.buildDecoratedClass)(ref, path, elements, file));
} else {
keysNodes = (0, _misc.extractComputedKeys)(ref, path, computedPaths, this.file);
keysNodes = (0, _misc.extractComputedKeys)(path, computedPaths, file);
({

@@ -190,3 +192,3 @@ staticNodes,

wrapClass
} = (0, _fields.buildFieldsInitNodes)(ref, path.node.superClass, props, privateNamesMap, state, setPublicClassFields != null ? setPublicClassFields : loose, privateFieldsAsProperties != null ? privateFieldsAsProperties : loose, constantSuper != null ? constantSuper : loose, innerBinding));
} = (0, _fields.buildFieldsInitNodes)(ref, path.node.superClass, props, privateNamesMap, file, setPublicClassFields != null ? setPublicClassFields : loose, privateFieldsAsProperties != null ? privateFieldsAsProperties : loose, constantSuper != null ? constantSuper : loose, innerBinding));
}

@@ -217,4 +219,6 @@

ExportDefaultDeclaration(path) {
if (this.file.get(versionKey) !== version) return;
ExportDefaultDeclaration(path, {
file
}) {
if (file.get(versionKey) !== version) return;
const decl = path.get("declaration");

@@ -221,0 +225,0 @@

@@ -34,5 +34,7 @@ "use strict";

ReferencedIdentifier(path) {
if (this.scope.hasOwnBinding(path.node.name)) {
this.scope.rename(path.node.name);
ReferencedIdentifier(path, {
scope
}) {
if (scope.hasOwnBinding(path.node.name)) {
scope.rename(path.node.name);
path.skip();

@@ -98,3 +100,3 @@ }

function extractComputedKeys(ref, path, computedPaths, file) {
function extractComputedKeys(path, computedPaths, file) {
const declarations = [];

@@ -101,0 +103,0 @@ const state = {

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

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

"devDependencies": {
"@babel/core": "^7.17.12",
"@babel/core": "^7.18.0",
"@babel/helper-plugin-test-runner": "^7.16.7",
"@babel/plugin-syntax-class-static-block": "^7.14.5",
"@babel/preset-env": "^7.17.12"
"@babel/preset-env": "^7.18.0"
},

@@ -39,0 +39,0 @@ "engines": {

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