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" field will prevent consumers of the package from using any entry points that are not defined, including the package.json (e.g. require('your-package/package.json')). This will likely be a breaking change.
Reproducible example
// 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
{
"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 |
Bug report
Current Behavior
The unified
radix-uipackage's exports map has a"./*"wildcard that maps to./dist/*. This intercepts attempts to resolveradix-ui/package.json, causing Node.js to look for./dist/package.json.mjsinstead 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:Expected behavior
require.resolve('radix-ui/package.json')should resolve to the package'spackage.jsonfile, as is conventional for npm packages with exports maps.From the NodeJS docs: https://nodejs.org/api/packages.html#package-entry-points
Reproducible example
This can also be reproduced by running Storybook in any project that depends on
radix-ui.Suggested solution
Add a
./package.jsonentry to the exports map inpackages/radix-ui/package.json:https://github.com/radix-ui/primitives/blob/main/packages/react/radix-ui/package.json#L16
{ "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