Quantifying Default Exports

Brian Di Palma offler at gmail.com
Sat Jul 19 09:53:02 PDT 2014


Great work on the analysis, very thorough.

For what it's worth I disagree with

    3) Default exports improve interoperability with legacy modules.

Based on my experience default exports do not help interoperability
with legacy module systems.

I'm currently working on a global namespaced script code to ES6/CJS
module compiler using node.js.
The compiler is written in ES6 and I'm using CJS npm packages in the project.

When an npm package exports a named identifier it's trivial to use it
in an ES6 module.

import {
    parse,
    print
} from 'recast';

When on the other hand it sets its export on `module.exports` default
exports provide no help at all.
There is no export named `default` to import, so I'm forced to use the
module form.

module minimist from 'minimist';

Examples taken from
https://github.com/briandipalma/global-compiler/blob/master/src/index.js

Default imports/exports seem totally unnecessary to me.
Nothing more then a distraction, providing no value but overhead.


More information about the es-discuss mailing list