ModuleImport

Jussi Kalliokoski jussi.kalliokoski at gmail.com
Thu Jul 3 00:30:11 PDT 2014


On Thu, Jul 3, 2014 at 1:29 AM, Brian Di Palma <offler at gmail.com> wrote:

> > 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.
>

So sometimes someone can need it, so we must have good support? Is that how
we operate these days?


> 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';
>

And (in the same order):
System.import("MyClass").then(function (MyClassModule) {
  // I don't actually know how someone would even access the default
exports from the module object unless in case of default exports there is
no module object, just the default exports as the module.
  var MyClass = MyClassModule;
});

System.import("MyClass").then(function (MyClassModule) {
  var { MyClass } = MyClassModule;
});

System.import("MyClass").then(function (MyClassModule) {
  var myClass = MyClassModule;
});

var MyClass = System.get("MyClass");
var {MyClass} = System.get("MyClass");
var myClass = System.get("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.
>

I agree. Thanks, I'm actually no longer even indifferent towards default
exports but I also think it should go.


> "Perfection is achieved, not when there is nothing more to add, but
> when there is nothing left to take away."
>
> B.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140703/61122b0b/attachment.html>


More information about the es-discuss mailing list