radix-ui package exports map prevents resolving package.json
envgap__radix-ui__primitives-3818
01 / FAILURE SIGNATURE
As reported upstream
// => Error: Cannot find module 'radix-ui/dist/package.json.js'
Not a benchmark task.
- In a clean container the reported failure did not reproduce, or the known fix did not make the project run.
02 / ENVIRONMENT RECIPE
- Base commit
cac030cd7e880567f600e2f029fab2c6fa0d2cc9- Manifest
packages/react/radix-ui/package.json- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
radix-ui/primitives #3818 · read the original issue
## Bug report
### Current Behavior
The unified `radix-ui` package's exports map has a `"./*"` wildcard that maps to `./dist/*`. This intercepts attempts to resolve `radix-ui/package.json`, causing Node.js to look for `./dist/package.json.mjs` instead of the actual file at the package root.
Tools that use `require.resolve('radix-ui/package.json')` to read package metadata fail. For example, Storybook's compatibility checker emits:
```
▲ unable to find package.json for radix-ui
```
### Expected behavior
`require.resolve('radix-ui/package.json')` should resolve to the package's `package.json` file, as is conventional for npm packages with exports maps.
From the NodeJS docs: https://nodejs.org/api/packages.html#package-entry-points
> Existing packages introducing the ["exports"](https://nodejs.org/api/packages.html#exports) field will prevent consumers of the package from using any entry points that are not defined, including the [package.json](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions) (e.g. require('your-package/package.json')). This will likely be a breaking change.
### Reproducible example
```js
// Node.js 22+
require.resolve('radix-ui/package.json')
// => Error: Cannot find module 'radix-ui/dist/package.json.js'
```
This can also be reproduced by running Storybook in any project that depends on `radix-ui`.
### Suggested solution
Add a `./package.json` entry to the exports map in `packages/radix-ui/package.json`:
https://github.com/radix-ui/primitives/blob/main/packages/react/radix-ui/package.json#L16
```json
{
"exports": {
".": { ... },
"./*": { ... },
"./package.json": "./package.json"
}
}
```
### Additional context
The individual `@radix-ui/react-*` packages don't have this issue because they either lack an exports map or don't use a `"./*"` wildcard that intercepts `./package.json`.
### Your environment
| Software | Version |
|------------------|---------|
| radix-ui | 1.4.3 |
| Node.js | 22.x |
| Storybook | 10.2.12 |04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]