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

/#!/JoePea joe at
Tue Aug 9 20:03:25 UTC 2016

I have the very basic problem detailed at, but thought I'd bring it up
here because it makes me wonder about the ES6 Module system.

Why is it that the body of module C is not evaluated before the bodies of
modules A and B? I'm just wondering, because if that were the case, then it
would work and the entrypoint would eventually be evaluated without errors.

A possibility could be that maybe it *should* work, and that my ES6 module
environment simply doesn't handle it as it should? (But I'm not familiar
enough with the spec, so that's why I'm not sure about that.)

These are the modules, posted here for convenience:

// --- Entrypoint

import A from './app/A'
console.log('Entrypoint', A)

// --- Module A

import C from './C'

console.log('Module A', C)

class A extends C {
    // ...

export {A as default}

// --- Module B

import C from './C'

console.log('Module B', C)

class B extends C {
    // ...

export {B as default}

// --- Module C

import A from './A'
import B from './B'

console.log('Module C', A, B)

class C {
    constructor() {
        // this may run later, after all three modules are evaluated, or
        // possibly never.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list