ESM for `flow-enums-runtime` and `babel-plugin-transform-flow-enums`
Closed this issue · 3 comments
trusktr commented
Proposal
Two things:
- add an ES Module file to
flow-enums-runtime
- right now it only ships with a CommonJS module
- enable an option for
babel-plugin-transform-flow-enums
to useimport
instead ofrequire
- right now it injects
require('flow-enums-runtime')
which is not compatible with ES Modules out of the box. - Instead, we can have it add an
import FlowEnumsRuntime from 'flow-enumes-runtime'
statement
- right now it injects
Use case
Easier integration into ES module projects, especially those without a build, or those with tooling that supports only ES modules and not CommonJS.
SamChou19815 commented
I do not see a need for this. react ships with only cjs and most of the tools work fine with it. Even node will improve esm-cjs interop in later versions where it will allow sync import esm files given that there is no top-level await, which our runtime certainly doesn't have.
trusktr commented
What about web browsers, which don't have CJS, only ESM?
Isn't this code for web browsers too not just Node.js?
SamChou19815 commented
At this point, almost all the scalable web dev requires some kind of transform and bundling, so we are not interested in the vanilla js space