Closed timrwood closed 9 years ago
Why'd you pick top exports and not bottom? I've mostly seen bottom exports in the wild.
Because its kind of the metadata of the file, and it makes sense to be easily visible immediately when you open the file.
Not to mention that some files just have a random export here and there, which is worse that being always at the top or always at the bottom.
When I looked more deeply -- most function definitions (because they bubble to the top) are exported at the top, but the variables and classes don't bubble (appear to be defined at the top), so they're not exported at the top (there is no way :))
I think it's kinda nice to split up the private/public interfaces in a module.
// Public
export { foo, bar };
import { baz } from "baz";
// Private
var bar = "Bar";
function foo () {}
function privateFoo () {}
Unfortunately, when transpiling to other formats, because vars are not hoisted like functions, they end up being undefined. This is why I exported all vars inline, but functions at the top.
I guess if we are looking for a consistent export style, all inline as export function bar () {}
or all as an object at the bottom of the file would be better.
Switched all exports to inline export function foo () {}
style.
via @ichernev