-
Notifications
You must be signed in to change notification settings - Fork 44
Open issues with require(esm) #454
Description
This issue is meant to track concerns raised in the past about require(esm). I'm hoping to preempt having these discussions in January after we (or rather @weswigham) already invested more work into providing an implementation of require(esm).
Previous discussions:
- Is
requirewith ESM planned? nodejs/modules#308 - Conditional Exports section of 2019-10-23
- Unflagging in 12.x
- Proposal for single-mode packages with optional fallbacks for older versions of node
- Issue asking for a way to turn async code into sync code
From the 2019-10-23 meeting notes:
Wes’ points are valid. Except we should be decisive about require(ESM). Wes did good work. Now that work has stalled, we can’t say it will appear in 6 months. But it’s not spec compliant with ESM. Promises are specced to suspend main thread. Flattening promises would be non-spec compliant. So problem is lack of work and spec adherence. Top-level await makes this observable.
— @guybedford (emphasis mine)
From #308:
Even if require(esm) was provided today it becomes hazardous to use over time as async-to-eval modules get introduced. For example a JS module using top-level await or a WebAssembly module. This can happen in dependencies you don't control, so it's not easy to defend against this hazard.
For this reason I'm also skeptical that this feature could be provided in a safe way that guaranteed future compatibility.