Just to be sure... Does a get printed only the first time the module A is
imported somewhere, or every time?

On Tue, Oct 16, 2012 at 3:57 PM, Patrick Mueller <[email protected]> wrote:

> On Mon, Oct 15, 2012 at 9:45 AM, Kevin Smith <[email protected]> wrote:
>
>> OK, so:
>>
>>     module A { console.log("a"); export var x; }
>>     console.log("$");
>>     import x from A;
>>
>> Does this print:
>>     $
>>     a
>> or
>>     a
>>     $
>>
>
> The first - "$", then "a".
>
> At least, that's how most module systems I've played with seem to work -
> CommonJS-ish ones I've written and used, and mostly AMD; there was an issue
> with the AMD almond loader that it would execute a "module factory" when
> the module was define()'d, not when it was first require()'d.  Can't
> remember the final stand on that one.  I think most of the AMD loaders will
> ensure that factories are not run until needed.
>
> This has worked out quite well, as it means ordering of modules doesn't
> matter - Browserify is a good example of this.  It means you don't HAVE to
> arrange your modules in any particular order, just make sure they are all
> defined before you do your first require().  MUCH, MUCH easier to build
> concatenators if you don't care what the order is.
>
> --
> Patrick Mueller
> [email protected]
>
> _______________________________________________
> 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

Reply via email to