Rationale for dropping ModuleImport syntax?

Karolis Narkevičius karolis.n at gmail.com
Mon Jun 9 01:56:24 PDT 2014

Why can't we have this?

// when only default exports are used
// import that one function
import mkdirp from "mkdirp";

// when only named exports are used
// import it like a module
import fs from "fs";

// when both named and default exports are used
// this imports the default export
import when from "when";
// and the named ones can only be imported via
import {all, map} from "when";

This way modules with one export work well and bags of utilities also work
well. The third case is a little trickier but it's not much worse compared
to how it would have been with a ModuleImport syntax, since if you want to
use both default export and named exports in the same file you would end up
with something like this:

module whenModule from "when";
import when from "when";

whenModule.map([when(foo), when(bar)]);

So ideally it should be possible to do

import when from "when";
import {all} from "when";
// when is a function and also has named exports attached
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140609/8dd0309c/attachment.html>

More information about the es-discuss mailing list