The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:
- How can authors of function-modules convert to ES6
export
syntax, without breaking consumers that dorequire("function-module")()
? - How can consumers of function-modules use ES6
import
syntax, while not demanding that the module author rewrites his code to ES6export
?
@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.
This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.