-
-
Notifications
You must be signed in to change notification settings - Fork 949
Closed
Labels
Description
As of 2019-10-31 ECMAScript Module (ESM) support in Node.js is still experimental and there is not yet a stable way of offering an ESM build for Node.js. The authors of the Node.js module working group even urge developers not to release dual CommonJS/ESM packages to npm yet, see: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md#phase-4-further-improvements-after-unflagging which states:
- Dual CommonJS/ESM packages: Either support packages with both CommonJS and ESM sources that can be used in either environment; or decide to specifically not support dual CommonJS/ESM packages.
- Status quo (at time of possible unflagging): "main" points to exactly one file, and all file extensions are mandatory (by default), so there is no possibility of an import specifier pointing to different files in ESM versus CommonJS. Recommended practice for dual packages is to have "main" point to the CommonJS entry point and have users use a deep import, e.g. /module.mjs, to access ESM entry point.
There is ongoing work within Node.js to support multiple exports for npm packages which will eventually solve this issue. We will support this feature once it becomes stable in node (i.e. once it's no longer hidden behind an experimental flag).
Corresponding Node.js issues:
Reactions are currently unavailable