Annotating transformed classes with #__PURE__ comment (#6209)

This commit is contained in:
Mateusz Burzyński
2017-09-11 17:18:37 +02:00
committed by Henry Zhu
parent c4f6a7a06f
commit c47258d68c
81 changed files with 299 additions and 112 deletions

View File

@@ -2,6 +2,8 @@ import LooseTransformer from "./loose";
import VanillaTransformer from "./vanilla";
import nameFunction from "babel-helper-function-name";
const PURE_ANNOTATION = "#__PURE__";
export default function({ types: t }) {
// todo: investigate traversal requeueing
const VISITED = Symbol();
@@ -51,11 +53,11 @@ export default function({ types: t }) {
path.replaceWith(new Constructor(path, state.file).run());
if (
path.isCallExpression() &&
path.get("callee").isArrowFunctionExpression()
) {
path.get("callee").arrowFunctionToExpression();
if (path.isCallExpression()) {
path.addComment("leading", PURE_ANNOTATION);
if (path.get("callee").isArrowFunctionExpression()) {
path.get("callee").arrowFunctionToExpression();
}
}
},
},

View File

@@ -2,7 +2,9 @@ let A = function A() {
console.log('a');
};
let B = function () {
let B =
/*#__PURE__*/
function () {
function B() {}
var _proto = B.prototype;

View File

@@ -2,7 +2,9 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.crea
let B = function B() {};
let A = function (_B) {
let A =
/*#__PURE__*/
function (_B) {
_inheritsLoose(A, _B);
function A(track) {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var x = function () {
var x =
/*#__PURE__*/
function () {
var _proto = x.prototype;
_proto.f = function f() {

View File

@@ -1,4 +1,6 @@
var Child = function (_Base) {
var Child =
/*#__PURE__*/
function (_Base) {
babelHelpers.inheritsLoose(Child, _Base);
function Child() {

View File

@@ -1,4 +1,6 @@
var Child = function (_Base) {
var Child =
/*#__PURE__*/
function (_Base) {
babelHelpers.inheritsLoose(Child, _Base);
function Child() {

View File

@@ -1,4 +1,6 @@
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo() {}
var _proto = Foo.prototype;
@@ -6,4 +8,4 @@ var Foo = function () {
_proto["bar"] = function bar() {};
return Foo;
}();
}();

View File

@@ -1,5 +1,7 @@
// @flow
var C = function () {
var C =
/*#__PURE__*/
function () {
function C() {}
var _proto = C.prototype;
@@ -9,4 +11,4 @@ var C = function () {
};
return C;
}();
}();

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {}
var _proto = Test.prototype;
@@ -10,4 +12,4 @@ var Test = function () {
_proto.c = function c() {};
return Test;
}();
}();

View File

@@ -1,4 +1,6 @@
var BaseController = function (_Chaplin$Controller) {
var BaseController =
/*#__PURE__*/
function (_Chaplin$Controller) {
babelHelpers.inheritsLoose(BaseController, _Chaplin$Controller);
function BaseController() {
@@ -8,7 +10,9 @@ var BaseController = function (_Chaplin$Controller) {
return BaseController;
}(Chaplin.Controller);
var BaseController2 = function (_Chaplin$Controller$A) {
var BaseController2 =
/*#__PURE__*/
function (_Chaplin$Controller$A) {
babelHelpers.inheritsLoose(BaseController2, _Chaplin$Controller$A);
function BaseController2() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inheritsLoose(Test, _Foo);
function Test() {

View File

@@ -16,7 +16,9 @@ var _binarySerializer = require("./helpers/binary-serializer");
var _binarySerializer2 = babelHelpers.interopRequireDefault(_binarySerializer);
// import ...
var Connection = function (_EventEmitter) {
var Connection =
/*#__PURE__*/
function (_EventEmitter) {
babelHelpers.inherits(Connection, _EventEmitter);
function Connection(endpoint, joinKey, joinData, roomId) {

View File

@@ -9,7 +9,9 @@ var _BaseFoo2 = require("./BaseFoo");
var _BaseFoo3 = babelHelpers.interopRequireDefault(_BaseFoo2);
var SubFoo = function (_BaseFoo) {
var SubFoo =
/*#__PURE__*/
function (_BaseFoo) {
babelHelpers.inherits(SubFoo, _BaseFoo);
function SubFoo() {

View File

@@ -9,7 +9,9 @@ var _react = require("react");
var _react2 = babelHelpers.interopRequireDefault(_react);
var RandomComponent = function (_Component) {
var RandomComponent =
/*#__PURE__*/
function (_Component) {
babelHelpers.inherits(RandomComponent, _Component);
function RandomComponent() {

View File

@@ -8,7 +8,9 @@ var b = function b() {
babelHelpers.classCallCheck(this, b);
};
var a1 = function (_b) {
var a1 =
/*#__PURE__*/
function (_b) {
babelHelpers.inherits(a1, _b);
function a1() {
@@ -27,7 +29,9 @@ var a1 = function (_b) {
return a1;
}(b);
var a2 = function (_b2) {
var a2 =
/*#__PURE__*/
function (_b2) {
babelHelpers.inherits(a2, _b2);
function a2() {

View File

@@ -1,6 +1,8 @@
"use strict";
var A = function (_B) {
var A =
/*#__PURE__*/
function (_B) {
babelHelpers.inherits(A, _B);
function A() {

View File

@@ -1,7 +1,9 @@
"use strict";
var x = {
Foo: function (_Foo) {
Foo:
/*#__PURE__*/
function (_Foo) {
babelHelpers.inherits(_class, _Foo);
function _class() {

View File

@@ -4,7 +4,9 @@ var A = function A() {
babelHelpers.classCallCheck(this, A);
};
var B = function (_A) {
var B =
/*#__PURE__*/
function (_A) {
babelHelpers.inherits(B, _A);
function B() {

View File

@@ -1,6 +1,8 @@
"use strict";
var A = function () {
var A =
/*#__PURE__*/
function () {
function A() {
babelHelpers.classCallCheck(this, A);
}

View File

@@ -5,17 +5,20 @@ Object.defineProperty(exports, "__esModule", {
});
function _default() {
return function () {
function Select() {
babelHelpers.classCallCheck(this, Select);
}
return (
/*#__PURE__*/
function () {
function Select() {
babelHelpers.classCallCheck(this, Select);
}
babelHelpers.createClass(Select, [{
key: "query",
value: function query(_query) {}
}]);
return Select;
}();
babelHelpers.createClass(Select, [{
key: "query",
value: function query(_query) {}
}]);
return Select;
}()
);
}
exports.default = _default;

View File

@@ -1,6 +1,8 @@
"use strict";
var Example = function () {
var Example =
/*#__PURE__*/
function () {
function Example() {}
var _proto = Example.prototype;

View File

@@ -1,6 +1,8 @@
"use strict";
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo(val) {
babelHelpers.classCallCheck(this, Foo);
this._val = val;

View File

@@ -12,7 +12,9 @@ var B = function B() {
_classCallCheck(this, B);
};
var A = function (_B) {
var A =
/*#__PURE__*/
function (_B) {
_inherits(A, _B);
function A(track) {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}

View File

@@ -3,7 +3,9 @@ var Test = function Test() {
this.state = "test";
};
var Foo = function (_Bar) {
var Foo =
/*#__PURE__*/
function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,4 +1,6 @@
var Foo = function (_Bar) {
var Foo =
/*#__PURE__*/
function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,4 +1,6 @@
var Child = function (_Base) {
var Child =
/*#__PURE__*/
function (_Base) {
babelHelpers.inherits(Child, _Base);
function Child() {

View File

@@ -1,4 +1,6 @@
var Child = function (_Base) {
var Child =
/*#__PURE__*/
function (_Base) {
babelHelpers.inherits(Child, _Base);
function Child() {

View File

@@ -1,4 +1,6 @@
var _class = function (_A) {
var _class =
/*#__PURE__*/
function (_A) {
babelHelpers.inherits(_class, _A);
function _class() {

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -1,5 +1,7 @@
// @flow
var C = function () {
var C =
/*#__PURE__*/
function () {
function C() {
babelHelpers.classCallCheck(this, C);
}

View File

@@ -2,7 +2,9 @@
var _a2 = require("./a");
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}

View File

@@ -1,5 +1,7 @@
// #1649
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
}

View File

@@ -8,7 +8,9 @@ var BaseView = function BaseView() {
this.autoRender = true;
};
var BaseView = function () {
var BaseView =
/*#__PURE__*/
function () {
function BaseView() {
babelHelpers.classCallCheck(this, BaseView);
}

View File

@@ -1,4 +1,6 @@
var A = function () {
var A =
/*#__PURE__*/
function () {
function A() {
babelHelpers.classCallCheck(this, A);
}

View File

@@ -1,4 +1,6 @@
var TestEmpty = function (_ref) {
var TestEmpty =
/*#__PURE__*/
function (_ref) {
babelHelpers.inherits(TestEmpty, _ref);
function TestEmpty() {
@@ -7,7 +9,9 @@ var TestEmpty = function (_ref) {
}
return TestEmpty;
}(function () {
}(
/*#__PURE__*/
function () {
function _class() {
babelHelpers.classCallCheck(this, _class);
}
@@ -15,7 +19,9 @@ var TestEmpty = function (_ref) {
return _class;
}());
var TestConstructorOnly = function (_ref2) {
var TestConstructorOnly =
/*#__PURE__*/
function (_ref2) {
babelHelpers.inherits(TestConstructorOnly, _ref2);
function TestConstructorOnly() {
@@ -24,7 +30,9 @@ var TestConstructorOnly = function (_ref2) {
}
return TestConstructorOnly;
}(function () {
}(
/*#__PURE__*/
function () {
function _class2() {
babelHelpers.classCallCheck(this, _class2);
}
@@ -32,7 +40,9 @@ var TestConstructorOnly = function (_ref2) {
return _class2;
}());
var TestMethodOnly = function (_ref3) {
var TestMethodOnly =
/*#__PURE__*/
function (_ref3) {
babelHelpers.inherits(TestMethodOnly, _ref3);
function TestMethodOnly() {
@@ -41,7 +51,9 @@ var TestMethodOnly = function (_ref3) {
}
return TestMethodOnly;
}(function () {
}(
/*#__PURE__*/
function () {
function _class3() {
babelHelpers.classCallCheck(this, _class3);
}
@@ -53,7 +65,9 @@ var TestMethodOnly = function (_ref3) {
return _class3;
}());
var TestConstructorAndMethod = function (_ref4) {
var TestConstructorAndMethod =
/*#__PURE__*/
function (_ref4) {
babelHelpers.inherits(TestConstructorAndMethod, _ref4);
function TestConstructorAndMethod() {
@@ -62,7 +76,9 @@ var TestConstructorAndMethod = function (_ref4) {
}
return TestConstructorAndMethod;
}(function () {
}(
/*#__PURE__*/
function () {
function _class4() {
babelHelpers.classCallCheck(this, _class4);
}
@@ -74,7 +90,9 @@ var TestConstructorAndMethod = function (_ref4) {
return _class4;
}());
var TestMultipleMethods = function (_ref5) {
var TestMultipleMethods =
/*#__PURE__*/
function (_ref5) {
babelHelpers.inherits(TestMultipleMethods, _ref5);
function TestMultipleMethods() {
@@ -83,7 +101,9 @@ var TestMultipleMethods = function (_ref5) {
}
return TestMultipleMethods;
}(function () {
}(
/*#__PURE__*/
function () {
function _class5() {
babelHelpers.classCallCheck(this, _class5);
}

View File

@@ -1,4 +1,6 @@
var BaseController = function (_Chaplin$Controller) {
var BaseController =
/*#__PURE__*/
function (_Chaplin$Controller) {
babelHelpers.inherits(BaseController, _Chaplin$Controller);
function BaseController() {
@@ -9,7 +11,9 @@ var BaseController = function (_Chaplin$Controller) {
return BaseController;
}(Chaplin.Controller);
var BaseController2 = function (_Chaplin$Controller$A) {
var BaseController2 =
/*#__PURE__*/
function (_Chaplin$Controller$A) {
babelHelpers.inherits(BaseController2, _Chaplin$Controller$A);
function BaseController2() {

View File

@@ -1,4 +1,6 @@
var Test = function (_Foo) {
var Test =
/*#__PURE__*/
function (_Foo) {
babelHelpers.inherits(Test, _Foo);
function Test() {

View File

@@ -1,4 +1,6 @@
var Foo = function (_Bar) {
var Foo =
/*#__PURE__*/
function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {

View File

@@ -1,4 +1,6 @@
var Foo = function (_Bar) {
var Foo =
/*#__PURE__*/
function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo() {