facebook/flow

ESM for `flow-enums-runtime` and `babel-plugin-transform-flow-enums`

Closed this issue · 3 comments

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 use import instead of require
    • 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

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.

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.

What about web browsers, which don't have CJS, only ESM?

Isn't this code for web browsers too not just Node.js?

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