From this article : https://hacks.mozilla.org/2015/08/es6-in-depth-modules/
It is written that
The new standard is designed to interoperate with existing CommonJS and AMD modules.
And more precisely
All CommonJS and AMD modules are presented to ES6 as having a default export
If it is really the case all we'd need is a ES6 polyfill and we wouldn't have to do use anything else.
Yet for eg this ES6 Polyfill :https://github.com/ModuleLoader/es6-module-loader doesn't seem to allow loading CommonJS/AMD modules from ES6 but only solutions built on top of it like SystemJS allow it.
So the question is : Is this true that the official ES6 standard says CommonJS/AMD should be supported (by being presented as having a default export) ?
If it is the case, do you have a reference to the ESCMA specification that says so ? and then why is it not a feature of the polyfill itself rather than solutions built on top of it ?
So far here is what I've understood, but I may be wrong so confirmation/rectifications are welcomed.
ECMAScript 6 does not specifies any compatibility with AMD, CommonJS or any other module format. It only allows for ECMAScript 6 Module as defined in the spec.
However from this source :
Module Loaders : Not part of ES2015. This is left as implementation-defined within the ECMAScript 2015 specification. The eventual standard will be in WHATWG's Loader specification, but that is currently a work in progress.
Module Loader spec will allow to define your own custom module loader. Thus it will be possible to import AMD, CommonJS, etc... by writing your own loader that will describe how to load such a module. But it will also allow to load for eg coffee script or any other resource as long as our custom module loader describes how to interpret this resource.
来源:https://stackoverflow.com/questions/34518339/es6-modules-import-officially-compatible-with-commonjs-and-amd