This repository has been archived by the owner on Mar 8, 2023. It is now read-only.
Expose package subpaths with the "exports" field #443
Merged
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.
This adds the
"exports"
field as defined in Node.js 12 and 14 to enable subpath imports.The current form is backwards compatible because the base-level files have been explicitly listed.
Ideally with the exports field, exact entry points would be listed, but the list here would be well over 100 which could be some work, but would have some benefits in hiding internal non public modules.
For now though, this will provide support to CDNs such as jspm and Skypack which use the "exports" field to determine how to resolve package subpaths. Specifically for jspm.dev this would ensure all subpaths are iterated and served, since usually subpaths are ignored as they might be tests etc.
Happy to answer any further questions around this, and the full docs on the field are available here - https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_package_entry_points.