-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Node is starting to ship an unflagged feature to allow you to require(...) es modules
This means a few things:
- we should be able to migrate many dual packages to esm-only
- we should be able to upgrade dependencies which have since moved to esm-only (but were pinned to keep CJS compatibility)
- we should be able to migrate faux modules (i.e. those with
type: "module"that export CJS) to esm-only
Research methods
High impact packages
The npm-esm-vs-cjs repo contains data sets that can help us understand which high impact packages use ESM, and which use CJS (or both).
Libraries
We can search this list for libraries and take the following action(s):
- if a package is esm-only, find high impact consumers of older CJS versions of the package and upgrade them to use the latest ESM version
- if a package is cjs-only, migrate it to esm-only
- if a package is dual (ESM/cjs), migrate it to esm-only
The joyee TODO list
@joyeecheung has helpfully already discovered many packages which publish CJS and ESM (i.e. they are dual packages) but are listed as ESM only.
You can view the list here
This could be a good TODO list for migrating to esm-only.
Considerations
- Not all packages can move yet since they need to support versions of node from before
require(esm)was possible. we should create an issue before a PR, to find out if the maintainers are in this situation
Questions
@joyeecheung do you know what the minimum node version is needed for this feature? when we open issues, we will have to ask if its ok to constrain to that version
I suspect many packages will still want older node support, but we will see