Skip to content

Implement "exports" proposal

Rodrigo Muino Tomonari requested to merge github/fork/jkrems/exports into master

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 package import '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 the require 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 in package.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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading