Implement "exports" proposal
This implements the package.json "exports" proposal (https://github.com/jkrems/proposal-pkg-exports/) with the following features:
- When
"exports"
are defined for a package ({ "exports": { "./x": "./x.js" }
), resolving that packageimport 'pkg/x'
, will resolve the exports path (/path/to/pkg/x.js
). - When a subpath does not match
"exports"
, an error is thrown (see test case). - Support for
"exports": false
to indicate a package has no exports at all. - Support for folder exports (
{ "./folder/": "./other-folder/" }
).
This reflects the consensus from this week's modules working group to move forward with exports
support in core.
Items to be addressed before this feature is considered "fully done":
- Support
exports
in therequire
loader. - Consider key / target validations (if any) and provide error messages where appropriate.
- Make call on support for differential exports (array syntax in import maps).
- Make call on support for package-internal entries (e.g. an
imports
field inpackage.json
).
The working group's recommendation was to address these items as follow-ups to keep the changes (and discussions) focussed on one thing at a time.
See: https://github.com/jkrems/proposal-pkg-exports/issues/36
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