yes, they will work. "hoisting of function initialization happens across the
whole module linkage graph before any module initialization code starts
executing." quoting @dherman.
there is one thing to keep in mind though: many edge cases cannot be transpile
into CJS, AMD, etc., the only format that preserves all the semantics of the
module system is the `system` format, which is an experimental format we came
up with a while ago. those two examples might fail in babeljs, but they
definitely work on esnext module transpiler (which is already deprecated), but
at least will give you an idea of how things work internally:
http://bit.ly/1ETGVDA
/caridy
> On Mar 20, 2015, at 2:20 PM, Axel Rauschmayer wrote:
>
> As far as I can tell, `import` is hoisted (due to
> `ModuleDeclarationInstantiation`). Is the following code OK, then? No
> temporal dead zone?
>
> ```js
> bar();
>
> import {foo} from 'mymodule';
>
> function bar() { // hoisted!
> foo(); // already initialized?
> }
> ```
>
> How about this code?
>
> ```js
> foo();
>
> import {foo} from 'mymodule';
> ```
>
> Thanks!
>
> Axel
>
> --
> Dr. Axel Rauschmayer
> a...@rauschma.de
> rauschma.de
>
>
>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss