module: conditional exports condition renaming proposal for usability
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".
Modules group discussion in https://github.com/nodejs/modules/issues/452, which this PR can be considered blocked on for now.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines