{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/1659","labels_url":"https://api.github.com/repos/babel/babel/issues/1659/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/1659/comments","events_url":"https://api.github.com/repos/babel/babel/issues/1659/events","html_url":"https://github.com/babel/babel/issues/1659","id":83275843,"number":1659,"title":"Idea: Eliminating unnecessary IIFEs","user":{"login":"spicyj","id":6820,"avatar_url":"https://avatars.githubusercontent.com/u/6820?v=3","gravatar_id":"","url":"https://api.github.com/users/spicyj","html_url":"https://github.com/spicyj","followers_url":"https://api.github.com/users/spicyj/followers","following_url":"https://api.github.com/users/spicyj/following{/other_user}","gists_url":"https://api.github.com/users/spicyj/gists{/gist_id}","starred_url":"https://api.github.com/users/spicyj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spicyj/subscriptions","organizations_url":"https://api.github.com/users/spicyj/orgs","repos_url":"https://api.github.com/users/spicyj/repos","events_url":"https://api.github.com/users/spicyj/events{/privacy}","received_events_url":"https://api.github.com/users/spicyj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-01T02:38:31Z","updated_at":"2015-06-01T02:42:57Z","closed_at":null,"body":"Currently,\r\n\r\n```js\r\na(b(), class { z() {} }, c());\r\n```\r\n\r\ncompiles to\r\n\r\n```js\r\na(b(), (function () {\r\n  var _class = function () {\r\n    _classCallCheck(this, _class);\r\n  };\r\n\r\n  _createClass(_class, [{\r\n    key: \"z\",\r\n    value: function z() {}\r\n  }]);\r\n\r\n  return _class;\r\n})(), c());\r\n```\r\n\r\nbut it seems like it could compile to something like\r\n\r\n```js\r\nvar _b = b();\r\n  var _class = function () {\r\n    _classCallCheck(this, _class);\r\n  };\r\n\r\n  _createClass(_class, [{\r\n    key: \"z\",\r\n    value: function z() {}\r\n  }]);\r\n\r\n  var _ref = _class;\r\nvar _c = c();\r\na(_b, _ref, _c);\r\n```\r\n\r\nwhich would (presumably) be more efficient at runtime. This could be a general optimization whenever a node transforms into more than one statement. (And a transformer to get rid of user-defined IIFEs could be possible too, though I imagine that wouldn't go in Babel core.)\r\n\r\nIs this feasible? If you point me in the right direction maybe I could look into adding this…"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/107288397","html_url":"https://github.com/babel/babel/issues/1659#issuecomment-107288397","issue_url":"https://api.github.com/repos/babel/babel/issues/1659","id":107288397,"user":{"login":"sebmck","id":853712,"avatar_url":"https://avatars.githubusercontent.com/u/853712?v=3","gravatar_id":"","url":"https://api.github.com/users/sebmck","html_url":"https://github.com/sebmck","followers_url":"https://api.github.com/users/sebmck/followers","following_url":"https://api.github.com/users/sebmck/following{/other_user}","gists_url":"https://api.github.com/users/sebmck/gists{/gist_id}","starred_url":"https://api.github.com/users/sebmck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebmck/subscriptions","organizations_url":"https://api.github.com/users/sebmck/orgs","repos_url":"https://api.github.com/users/sebmck/repos","events_url":"https://api.github.com/users/sebmck/events{/privacy}","received_events_url":"https://api.github.com/users/sebmck/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T02:42:57Z","updated_at":"2015-06-01T02:42:57Z","body":"Sure, this could only be done for anonymous class expressions though. You could short circuit it [here](https://github.com/babel/babel/blob/master/src/babel/transformation/transformers/es6/classes.js#L219) if it's a `ClassExpression` with no `id` then push an `ExpressionStatement` onto it with the class ref and then just return a list of statements (When replacing an expression with a list of statements Babel explodes it into an expression). You'd have to special case super classes though and assign it to a temporary variable as you couldn't rely on the [closures parameters](https://github.com/babel/babel/blob/master/src/babel/transformation/transformers/es6/classes.js#L148-149)."}}