enable conditional exports #4448
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
depends on #4446
before:
i.e. importing from esm gives you cjs
after:
we have conditional exports, and it looks like nothing has changed.....
BUT:
Any version of Node honoring the module-sync condition i.e. where require(esm) is enabled will load ESM both when imported and required, i.e.
^20.19.0 || ^22.12.0 || >=23.0.0
, i.e. latest versions of all current Node.JS releases.We have been delaying this for some time secondary to dual-package-hazard concerns, but this looks like we can release ESM to the broader community via package exports while retaining whatever legacy CJS build we might need for those environments that need it => looking at you Jest.
We can look into whether we want to drop cjs support entirely as a follow-on PR => see #4437