- Notifications
You must be signed in to change notification settings - Fork 44
Conditional exports naming usability discussion#452
Description
Further to discussions from today re resolver stability and trying to incorporate the current feedback on conditional exports I've posted the PR at nodejs/node#30799 to open discussion around conditional exports naming and behaviours.
From the PR description -
A major priority for the modules implementation is resolver stability, and the dual mode story through conditional exports is a big remaining piece of this.
Common usability feedback out of various discussions on conditional exports so far has been that the "default" field may be seen to be a confusing name, and that it isn't clear when the "require" condition will match either.
To try and improve the overall usability this PR makes the following condition name changes:
- Add a new
"import"condition as the converse of the"require"condition, only applying for the ESM loader.
All conditions (except for "default") remain behind the --experimental-conditional-exports flag.
This makes the dual mode workflow look like:
{"type": "module", "main": "./index.cjs", "exports":{"require": "./index.cjs", "import": "./index.js" } }instead of the previous:
{"type": "module", "main": "./index.cjs", "exports":{"require": "./index.cjs", "default": "./index.js" } }the UX improvement being that the former seems like it will look more natural to most users unfamiliar with "exports".