How to solve this basic ES6-module circular dependency problem?

Logan Smyth loganfsmyth at
Fri Aug 12 00:44:13 UTC 2016

Actively thinking about "live bindings" may honestly confuse the way you
think about imports. When you do

    export var foo = "value";


    import {foo} from "./foo";

Every time you access `foo` in the second module, you are literally
reaching into the first module to grab the current value of `foo`. You can
think of it like this, in CommonJS terms:

    var foo = "value";

    Object.defineProperty(exports, 'foo', { get(){ return foo; } }


    var fooMod = require('./foo');

so accessing the 'foo' export calls a getter method to access the current
value of `foo`, so any change to the value inside the first module will
immediately change the next time you trigger the getter.

On Thu, Aug 11, 2016 at 5:35 PM, /#!/JoePea <joe at> wrote:

> Are bindings live across all modules at the same time, as if the
> identifier were defined in an outer scope common to all the modules that
> import it?
> */#!/*JoePea
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list