On Thu, Jul 5, 2012 at 5:19 PM, Claus Reinke <[email protected]> wrote:
>>> To outline the disconnect, consider this simple static module
>>> chain for a dummy project ab I might like to use:
>>>
>>> // a.js
>>> export var a = "a";
>>>
>>> // b.js
>>> import {a} from 'a';
>>> export var b = a+"b";
>>>
>>> To use this in my main code, I again use static import
>>>
>>> // main.js (or perhaps a script element in index.html)
>>> import {b} from 'b'; // early failure-protection here
>>> .. other imports .. // executed in sequence, but
>>> // can be loaded in parallel
>>> .. lots of code that uses imports ..
>>> // if this code is part of a HTML
>>> // source, we can use imports
>>> // to fill static HTML syntax here
>>>
>>> Now, if I need to use module loader hooks while importing
>>> the ab project, I thought there would be a way to extend
>>> the default loader, then keep the rest of main.js unchanged.
>>
>>
>> In what way do you want to extend the default loader?
>
>
> Similar to the dummy project sources, the nature of the loader
> is not important to the concerns expressed in my message (in
> the comments).
I disagree -- it's not possible to know what the requirements are, how
else they could be solved, what the current state-of-the-art is, and
how common this will be without further details.
> Meanwhile, a third variant occurred to me: we might be
> able to make use of the staged loading to limit the impact
> of the rewrite, and to recover from asynchronous loading
> and dynamic usage back to synchronous loading and module
> syntax. This is going to be a variant of my second example, in
> a web page context:
>
>
> // old-main.js
> import {b} from 'b';
> .. other imports ..
>
> .. lots of code that uses imports ..
> export ...
>
> // index.html
> <script>
>
> let myLoader = new Loader(...);
> myLoader.load('old-main',function(mainMO){
> System.set('main',mainMO),
> });
> </script>
> <script>
> // this second script element will be resolved in a
> // separate 'phase', with 'main' available, right?
> import {...} from 'main';
> </script>
> .. can we now use imports from 'main' in the <body>?
>
> But even if this works out in a web page (does it?),
Yes, this should work fine.
> what is
> the equivalent mechanism server-side?
That's a choice that the designers of server-side JS frameworks can
make. The boundary between script tags could be translated into the
boundary between files, or statements, or forms typed into the REPL,
or something else.
--
sam th
[email protected]
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss