Conflicts using export *

Andreas Rossberg rossberg at
Fri Jun 14 06:27:10 PDT 2013

On 14 June 2013 15:00, Kevin Smith <zenparsing at> wrote:
>>     // M.js
>>     export * from "foo";
>>     export * from "bar";
>>     // foo.js
>>     export * from "foobar";
>>     // bar.js
>>     export * from "foobar";
>>     // foobar.js
>>     export var x = 1;
>> I just want to make sure that using M.x in any of these cases is an
>> error likewise.
> Is there a particular reason?  I feel indifferent so far, and it wouldn't be
> difficult to put an additional check on the binding target during linking.

It would introduce an observable difference between

  export * from "foo"  // where foo exports x, y, z


  import {x, y, z} from "foo"
  export {x, y, z}

which I think is bad for modularity and refactoring.

Also, it would require name resolution to keep track of where every
export is originally coming from, which is kind of nasty. I'm not
sure, but it might even make resolution somewhat harder, because you
need more (potentially recursive) information to distinguish errors
from non-errors -- i.e., you might have to delay certain checks to a
separate pass.


More information about the es-discuss mailing list