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

babel-plugin-transform-class-properties

Package Overview
Dependencies
Maintainers
4
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-class-properties - npm Package Compare versions

Comparing version 7.0.0-alpha.15 to 7.0.0-alpha.16

86

lib/index.js

@@ -7,6 +7,7 @@ "use strict";

var t = _ref.types;
var findBareSupers = {
Super: function Super(path) {
if (path.parentPath.isCallExpression({ callee: path.node })) {
if (path.parentPath.isCallExpression({
callee: path.node
})) {
this.push(path.parentPath);

@@ -16,3 +17,2 @@ }

};
var referenceVisitor = {

@@ -26,3 +26,2 @@ ReferencedIdentifier: function ReferencedIdentifier(path) {

};
var buildObjectDefineProperty = (0, _babelTemplate2.default)("\n Object.defineProperty(REF, KEY, {\n // configurable is false by default\n enumerable: true,\n writable: true,\n value: VALUE\n });\n ");

@@ -50,3 +49,2 @@

inherits: _babelPluginSyntaxClassProperties2.default,
visitor: {

@@ -76,3 +74,5 @@ Class: function Class(path, state) {

props.push(_path);
} else if (_path.isClassMethod({ kind: "constructor" })) {
} else if (_path.isClassMethod({
kind: "constructor"
})) {
constructor = _path;

@@ -83,3 +83,2 @@ }

if (!props.length) return;
var nodes = [];

@@ -97,21 +96,7 @@ var ref = void 0;

for (var _iterator2 = props, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
var _ref5;
if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref5 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref5 = _i2.value;
}
var prop = _ref5;
for (var _i2 = 0; _i2 < props.length; _i2++) {
var prop = props[_i2];
var propNode = prop.node;
if (propNode.decorators && propNode.decorators.length > 0) continue;
if (!state.opts.spec && !propNode.value) continue;
var isStatic = propNode.static;

@@ -130,2 +115,3 @@

var newConstructor = t.classMethod("constructor", t.identifier("constructor"), [], t.blockStatement([]));
if (isDerived) {

@@ -146,17 +132,7 @@ newConstructor.params = [t.restElement(t.identifier("args"))];

for (var _iterator3 = props, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
var _ref6;
for (var _i3 = 0; _i3 < props.length; _i3++) {
var _prop = props[_i3];
if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref6 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref6 = _i3.value;
}
_prop.traverse(referenceVisitor, collisionState);
var _prop = _ref6;
_prop.traverse(referenceVisitor, collisionState);
if (collisionState.collision) break;

@@ -167,5 +143,3 @@ }

var initialisePropsRef = path.scope.generateUidIdentifier("initialiseProps");
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(initialisePropsRef, t.functionExpression(null, [], t.blockStatement(instanceBody)))]));
instanceBody = [t.expressionStatement(t.callExpression(t.memberExpression(initialisePropsRef, t.identifier("call")), [t.thisExpression()]))];

@@ -177,16 +151,5 @@ }

constructor.traverse(findBareSupers, bareSupers);
for (var _iterator4 = bareSupers, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) {
var _ref7;
if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref7 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref7 = _i4.value;
}
var bareSuper = _ref7;
for (var _i4 = 0; _i4 < bareSupers.length; _i4++) {
var bareSuper = bareSupers[_i4];
bareSuper.insertAfter(instanceBody);

@@ -199,16 +162,5 @@ }

for (var _iterator5 = props, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : _iterator5[Symbol.iterator]();;) {
var _ref8;
for (var _i5 = 0; _i5 < props.length; _i5++) {
var _prop2 = props[_i5];
if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref8 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref8 = _i5.value;
}
var _prop2 = _ref8;
_prop2.remove();

@@ -220,3 +172,5 @@ }

if (path.isClassExpression()) {
path.scope.push({ id: ref });
path.scope.push({
id: ref
});
path.replaceWith(t.assignmentExpression("=", ref, path.node));

@@ -238,5 +192,5 @@ } else {

if (!classExp.isClassExpression()) return;
var body = classExp.get("body");
var members = body.get("body");
if (members.some(function (member) {

@@ -243,0 +197,0 @@ return member.isClassProperty();

{
"name": "babel-plugin-transform-class-properties",
"version": "7.0.0-alpha.15",
"version": "7.0.0-alpha.16",
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",

@@ -12,9 +12,9 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-class-properties",

"dependencies": {
"babel-helper-function-name": "7.0.0-alpha.15",
"babel-plugin-syntax-class-properties": "7.0.0-alpha.15",
"babel-template": "7.0.0-alpha.15"
"babel-helper-function-name": "7.0.0-alpha.16",
"babel-plugin-syntax-class-properties": "7.0.0-alpha.16",
"babel-template": "7.0.0-alpha.16"
},
"devDependencies": {
"babel-helper-plugin-test-runner": "7.0.0-alpha.15"
"babel-helper-plugin-test-runner": "7.0.0-alpha.16"
}
}
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