You seem to be assuming CommonJS semantics (require, exports, module),
which was never part of the ECMAScript specification.
Instead, ECMAScript has exactly the syntax you're looking for:
```js
export function fnName() {...}
fnName();
```
P.S. We say "hoisted" rather than "yanked" these days. In fact, I've never
heard of yanking before.
Ben
His errors are volitional and are the portals of discovery.
-- James Joyce
On Wed, Mar 21, 2018 at 5:54 PM, Sebastian Malton <[email protected]>
wrote:
> So function definitions are currently yanked to the top. This includes
> named functions.
>
> However if a function is set to a variable, even if it is named, it is not
> yanked. Nor is the name exposed. My suggestion is that it is.
>
> Namely, currently the following errors:
> ```js
> module.exports.fnName2 = function fnName (){...}
>
> fnName()
> ```
>
> But I propose that it would not. Currently this can be gotten around by
> making it two lines, one to define the function and another to export it
> but that seems clunky
>
> Sebastian Malton
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss