How to solve this basic ES6-module circular dependency problem?
Tab Atkins Jr.
jackalmage at gmail.com
Tue Aug 9 23:11:21 UTC 2016
On Tue, Aug 9, 2016 at 4:00 PM, /#!/JoePea <joe at trusktr.io> wrote:
> True, and so that's why I'm wondering if the module system can see that it
> can satisfy all module requirements if it simply evaluates module C first,
> followed by A or B in any order. It is easy for us humans to see that. It
> would be nice for the module system to see that as well (I'm not sure if
> that is spec'd or not).
That knowledge requires, at minimum, evaluating the rest of each
module, beyond what is expressed in the `import` statements. That's
assuming there's no dynamic trickery going on that would invalidate
whatever assumptions it can draw from surface-level analysis.
Because of this, only the `import` statements are declaratively
available to the module system to work with. Based on that, it
definitely can't make any ordering assumptions; all it knows is that A
imports C, B imports C, and C imports both A and B, making a circular
import.
~TJ
More information about the es-discuss
mailing list