Static Module Resolution

Aymeric Vitte vitteaymeric at
Wed Jul 4 03:12:01 PDT 2012

This is not exactly what I would like to do, I would like to decide 
where I want to run it and when (whether it's sync or async), the global 
environment can be protected by strict mode now if you don't eval within it.

Basically I would like to have :

var code=download(url); //download("./my_server_secret_script.js")

eval(code); //sync or asynch

The problem with the loader proposal is that you need a callback and it 
only extends the global scope, so the loader does not know the 
surrounding environment where it is called, example :


var callback=function() {
     var window=some window; //not a global var
     System.load('script.js',function() {console.log(res)}; //script.js 
--> var res=window.document.body

Real example here: , section :

document.onload=function() {
var EWA = require('ewa').EWA;
var ewa = new 

'ewa' was a normal script that was transformed into a module (even if on 
server side I could have loaded it and eval it (but with a callback), 
let's consider the same case where I need a public script into the 
browser), and 'window' and 'document' had to become "super" global vars 
to make it work

Using System.load I don't have to transform the script into a module but 
I still need to make 'window' and 'document' global vars, and I have now 
to use a callback

Then why not just a ?

Note : the above case is the exact real life representation of what I am 
trying to describe here :

Le 03/07/2012 21:06, Jason Orendorff a écrit :
> On Tue, Jul 3, 2012 at 2:29 AM, Aymeric Vitte <vitteaymeric at 
> <mailto:vitteaymeric at>> wrote:
>     why can't we have in the module proposal (or somewhere) just the
>     possibility to load code and eval it (in browsers and server side
>     environments) ? ie why should I be obliged to transform my script
>     into a module and have to maintain both, or more if I want to
>     insure perfect compatibility ? The question is trivial and not
>     entirely related to modules or ES but since modules are
>     considered, why not adding this possibility now ?
> Well, under the current proposal, you can say:
>   System.load(url, function () {}, function () {});
> This will basically just load the given url and run it, 
> asynchronously. (The code is treated as a module, but IIUC the only 
> difference that makes is that global variables and functions it 
> defines won't pollute the global environment by default -- which seems 
> like a good thing.)
> -j

Email :  avitte at
Web :
Webble :
Extract Widget Mobile :
BlimpMe! :

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list