Proposal: minimal esm implementation #141
Description
Hey All,
Like everyone here I've been thinking about this a whole bunch. For a while I've been trying to come up with a minimal implementation that we can iterate on. Something that could offer a fast path to deflagging.
Features
- esm works with flag --experimental-modules
- must use .mjs as entry point for node binary
- no transparent interoperability
- import.meta.require for cjs interop in esm
- dynamic import for esm interop in cjs
- package-name-map compliance for esm specifier resolution
- must provide full path to module
- no support for importing directories
Try it out today
Repo: https://github.com/MylesBorins/node/tree/esm-kernel
Download: https://nodejs.org/download/test/v11.0.0-test2018070976df5841a1/
$ NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/test nvm install v11.0.0-test2018070976df5841a1
warning super naive implementation, lots of room for improvement... but it shows off the desired UX and all the tests pass locally on my machine.
Upstream PRs
- import.meta.require
- package-name-map compliance
TODO
- improve implementation
- get tests working on all platforms
- build consensus
- ensure loaders works
- ensure vm works
Note
I have not opened a PR upstream to remove transparent interoperability as I want to be respectful of the current conversations going on within the group. While import.meta.require and limiting extensions are not guaranteed to land, I do think that they are worth discussing independently on their own merits.