ModuleImport

Brian Di Palma offler at gmail.com
Wed Jul 2 15:29:54 PDT 2014


> The arguments for and against supporting cyclic dependencies seem to be academic. I'm yet to see any evidence of their importance in practice nor proof they they are fundamental ... or not.

Transitive cyclic dependencies. I'd say that's the case that was in
the minds of the authors of the module system.
In large codebases those can happen and a module system that does not
handle them gracefully would be poor.

Support for them is needed, and what CommonJS has is not good enough.
They are acknowledged in the modules documentation for node
http://nodejs.org/api/all.html#all_cycles
This does not mean they are recommended, the same holds true for ES6 modules.

It is an acceptance of the reality of complex and large codebases that
sometimes cyclic dependencies can occur.

It boils down to this.

You can import a dependency in three ways

import MyClass from 'MyClass';
import {MyClass} from 'MyClass';
module myClass from 'MyClass';

That's one too many ways for the simplest module system that fulfills
all requirements.

import MyClass from 'MyClass';
import {MyClass} from 'MyClass';
import * as myClass from 'MyClass';

Is not the fix.

The confusion stemmed from the first production not the last.

"Perfection is achieved, not when there is nothing more to add, but
when there is nothing left to take away."

B.


More information about the es-discuss mailing list