babel-plugin-transform-class-properties
Advanced tools
Comparing version 7.0.0-alpha.15 to 7.0.0-alpha.16
@@ -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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9203
164
+ Addedansi-styles@3.2.1(transitive)
+ Addedbabel-code-frame@7.0.0-alpha.16(transitive)
+ Addedbabel-helper-function-name@7.0.0-alpha.16(transitive)
+ Addedbabel-helper-get-function-arity@7.0.0-alpha.16(transitive)
+ Addedbabel-messages@7.0.0-alpha.16(transitive)
+ Addedbabel-plugin-syntax-class-properties@7.0.0-alpha.16(transitive)
+ Addedbabel-template@7.0.0-alpha.16(transitive)
+ Addedbabel-traverse@7.0.0-alpha.16(transitive)
+ Addedbabel-types@7.0.0-alpha.16(transitive)
+ Addedbabylon@7.0.0-beta.17(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedglobals@10.4.0(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedto-fast-properties@2.0.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@7.0.0-alpha.15(transitive)
- Removedbabel-helper-function-name@7.0.0-alpha.15(transitive)
- Removedbabel-helper-get-function-arity@7.0.0-alpha.15(transitive)
- Removedbabel-messages@7.0.0-alpha.15(transitive)
- Removedbabel-plugin-syntax-class-properties@7.0.0-alpha.15(transitive)
- Removedbabel-template@7.0.0-alpha.15(transitive)
- Removedbabel-traverse@7.0.0-alpha.15(transitive)
- Removedbabel-types@7.0.0-alpha.15(transitive)
- Removedbabylon@7.0.0-beta.13(transitive)
- Removedchalk@1.1.3(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)