Simple Modules: lazy dependency evaluation

David Herman dherman at mozilla.com
Wed Jan 26 14:44:43 PST 2011


> I assume you mean m.load("la1").

No, that doesn't follow James's example at all. I'm not sure what you're talking about here.

> So what is the behavior if you do new m.load("la1").Foo() if you know Foo is an exported object?

I'm not really sure what you're asking here either.

> Is there a module API that allows one to introspect a modules content?

Yes, very easily -- modules can be reflected as first-class objects. Whenever a module is in scope, you can simple refer to it in an expression and you get an object whose properties are the exports of the module. For example:

    module M {
        export var foo = 42;
        export function bar() { return foo; }
    }

    var obj = M;
    alert(Object.getOwnPropertyNames(obj)); // "foo, bar"

Dave



More information about the es-discuss mailing list