Nested modules clarification

Erik Arvidsson erik.arvidsson at gmail.com
Thu Jul 19 16:36:07 PDT 2012


On Thu, Jul 19, 2012 at 2:58 PM, ๏̯͡๏ Jasvir Nagra <jas at nagras.com> wrote:
> Here's the modified test case from earlier:
>
> outer.js
> ----------
> module outer {
>   let Object = {};
>   export module inner = "http://m/inner.js";
> }
>
> inner.js
> ----------
> Object.prototype.myMarker = 3;
> assert( ({}).myMarker === 3 )

A better inlining mechanism is:

compiled.js
--------------
module $temp {
  Object.prototype.myMarker = 3;
  assert( ({}).myMarker === 3 )
}
module outer {
  let Object = {};
  export module inner = $temp;
}

This way multiple module foo = "http://m/inner.js" only leads to one
module and you get less scope issues.

-- 
erik


More information about the es-discuss mailing list