Skip to content

fix: add package.json subpath#9660

Open
unional wants to merge 1 commit intoadobe:mainfrom
unional:package.json-subpath
Open

fix: add package.json subpath#9660
unional wants to merge 1 commit intoadobe:mainfrom
unional:package.json-subpath

Conversation

@unional
Copy link
Contributor

@unional unional commented Feb 14, 2026

This fix importing package.json for tooling.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

run script to read package.json such as:

import.meta.resolve('react-aria-components/package.json')

Without this fix, you will get the following error:

Package subpath './package.json' is not defined by "exports"

@unional
Copy link
Contributor Author

unional commented Feb 14, 2026

Note that ideally should also add type: module, but that's a different topic and it's better to separate them.

@snowystinger
Copy link
Member

Can you say more about why you need this? We're in the middle of reworking all of our packages and it would be good to know more about this.

@unional
Copy link
Contributor Author

unional commented Feb 14, 2026

It's for tooling. Many tools would read the package.json of an installed package to learn about additional information about it, for example bundler would read for the sideEffect field, and some other tools read about its dependency tree, author info, etc.

In CJS, <pkg>/package.json is resolved automatically to the ./package.json. That's not the case for ESM. So it is very common that library add this to restore this capability when moving from CJS to ESM.

@unional
Copy link
Contributor Author

unional commented Feb 14, 2026

We're in the middle of reworking all of our packages

btw what's your plan about this work? I'm interested to know more.

@snowystinger
Copy link
Member

@unional
Copy link
Contributor Author

unional commented Feb 14, 2026

Thanks for the link. That looks great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants