Modules: Curly Free

David Herman dherman at mozilla.com
Mon Apr 22 13:10:21 PDT 2013


On Apr 22, 2013, at 6:48 AM, Andreas Rossberg <rossberg at google.com> wrote:

> (And semantics, I presume, because
> Dave hasn't actually told us how the "anonymous" export would be
> distinguished internally.)

Yes I have! I've explained it before, at least at the March meeting and again in passing in this thread. The anonymous export would be available on the module instance object under a standard unique symbol.

For example, you could reflect it from a module instance object like so. I'll arbitrarily use Kevin's syntax for the moment because, well, I have to pick one to make an example.

  module "foo" {
    export default 17;
  }

  import defaultExport from "js/reflect/module"; // presumably the symbol would be available in a stdlib like this
  import module "foo" as foo;                    // bind foo to the module instance object of "foo"

  console.log(foo[defaultExport])                // 17

Dave



More information about the es-discuss mailing list