{"action":"closed","issue":{"url":"https://api.github.com/repos/esperantojs/esperanto/issues/37","labels_url":"https://api.github.com/repos/esperantojs/esperanto/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/esperantojs/esperanto/issues/37/comments","events_url":"https://api.github.com/repos/esperantojs/esperanto/issues/37/events","html_url":"https://github.com/esperantojs/esperanto/issues/37","id":53510478,"number":37,"title":"Functions are not always exported early","user":{"login":"Rich-Harris","id":1162160,"avatar_url":"https://avatars.githubusercontent.com/u/1162160?v=3","gravatar_id":"","url":"https://api.github.com/users/Rich-Harris","html_url":"https://github.com/Rich-Harris","followers_url":"https://api.github.com/users/Rich-Harris/followers","following_url":"https://api.github.com/users/Rich-Harris/following{/other_user}","gists_url":"https://api.github.com/users/Rich-Harris/gists{/gist_id}","starred_url":"https://api.github.com/users/Rich-Harris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rich-Harris/subscriptions","organizations_url":"https://api.github.com/users/Rich-Harris/orgs","repos_url":"https://api.github.com/users/Rich-Harris/repos","events_url":"https://api.github.com/users/Rich-Harris/events{/privacy}","received_events_url":"https://api.github.com/users/Rich-Harris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/esperantojs/esperanto/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-06T12:32:36Z","updated_at":"2015-01-06T21:28:38Z","closed_at":"2015-01-06T21:28:38Z","body":"This only really applies to CJS modules, because AMD can't handle cyclic dependencies at this level, but if you have an `export { foo }` statement, where `foo` is a function, it should be exported early. It *does* happen in the `export function foo () {}` case:\r\n\r\n```js\r\nexport { bar, baz };\r\n\r\nexport function foo() {}\r\nfunction bar() {}\r\nfunction baz() {}\r\n\r\n// becomes...\r\n(function () {\r\n\r\n  'use strict';\r\n\r\n  exports.foo = foo;\r\n  \r\n  function foo() {}\r\n  function bar() {}\r\n  function baz() {}\r\n  \r\n  exports.bar = bar;\r\n  exports.baz = baz;\r\n\r\n}).call(global);\r\n```\r\n\r\nAll three functions should be exported at the top."}}