Static Module Resolution

Sam Tobin-Hochstadt samth at ccs.neu.edu
Thu Jul 5 10:47:04 PDT 2012


On Wed, Jul 4, 2012 at 10:08 AM, Aymeric Vitte <vitteaymeric at gmail.com> wrote:
> It's confusing maybe because what I am requesting is very very basic
> compared to modules/loader complexity and maybe I did mix it with an example
> not so basic.
>
> I just want something that loads the code and then I decide what to do with
> it. Indeed on browser's side it would be like a cross-domain xhr, this does
> not exist but since modules will exist into browsers too, why not including
> this possibility ?
>
> You are right, System.load("ewa.js", ...) would work, I did not say the
> contrary but to make it work I need to define 'window' and 'document' as
> global vars, I don't like it a lot if I care about separating contexts and
> then I have a problem if I want to have several 'window' and 'document', and
> I have to use a callback (I know everything is based on async but in some
> cases it's quite complicate to handle, then if things can be sync that's not
> a bad thing)

I don't understand your comment about `window` and `document`.  They
are already globals in browser JS environments.

As for async, there are a variety of ways to make it easier, but we
are *not* going to add synchronous IO as part of the module system.
The run-to-completion semantics of JS are non-negotiable.

> Simply, something like :
>
> {
>     var window=window1;
>     var code=System.download('ewa.js');
>     eval(code); //or whatever I like to do
> }
>
>
> {
>     var window=window2;
>     var code=System.download('ewa.js');
>     eval(code); //or whatever I like to do
> }
>
>
>
> Le 04/07/2012 15:39, Sam Tobin-Hochstadt a écrit :
>
>> I'm slightly confused about what you want here. If you just want the
>> ability to download code, and then eval it using the loader mechanism,
>> that's already there -- just use XHR to get the code, and then call
>> `System.eval(...)`. If you want the ability to fetch the source the way that
>> the loader would do it, and then not actually *load* the code, we could
>> potentially add that, but it's tricky for recursive cases -- would you want
>> all the relevant code, or just the specified module? Or do you want
>> something else than this? Finally, I don't see why your example doesn't work
>> exactly as: document.onload(function() { System.load("ewa.js", ...); })
>
>
> --
> jCore
> Email :  avitte at jcore.fr
> Web :    www.jcore.fr
> Webble : www.webble.it
> Extract Widget Mobile : www.extractwidget.com
> BlimpMe! : www.blimpme.com
>
>
>



-- 
sam th
samth at ccs.neu.edu


More information about the es-discuss mailing list