adobe / adobe/react-spectrum

`source` conditional exports point to files omitted from npm packages

Open
#10,397 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the issue here

`react-aria`, `react-stately`, and `react-aria-components` expose a `source` conditional export such as `./exports/index.ts`, but their npm package files exclude `exports/**`. Bundlers that opt into the `source` condition resolve an entry that is not present in the installed package.

### 🤔 Expected Behavior?

An installed npm package should either resolve its advertised `source` conditional export or fall back to its distributed ESM `import` entry.

### 😯 Current Behavior

When Vite is configured with `resolve.conditions: ['source']`, it selects the missing `source` entries and fails to start:

```txt
Failed to resolve import "react-aria/I18nProvider"
Failed to resolve import "react-aria-components"
```

### 💁 Possible Solution

Either remove the `source` conditional exports from packages whose source files are not published, or include `exports/**/*.ts` in the npm package files.

### 🔦 Context

We enable the `source` condition to consume linked workspace packages directly in a Vite-based Storybook. Because Vite applies the condition to every package, it also selects the React Aria `source` entries. This affects root and deep imports such as `react-aria/I18nProvider`.

### 🖥️ Steps to Reproduce

1. Install `react-aria` from npm.
2. Add the following Vite configuration:

```ts
export default defineConfig({
resolve: {
conditions: ['source'],
},
});
```

3. Import from `react-aria` or a deep entry such as `react-aria/I18nProvider`.
4. Start the Vite development server or run a Vite-based test.

### Version

`react-aria` 3.50.0, `react-aria-components` 1.19.0, `react-stately` 3.48.0

### What browsers are you seeing the problem on?

Chrome

### If other, please specify.

_No response_

### What operating system are you using?

macOS 26.5.2

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the package manifests and packaging rules for react-aria, react-stately, and react-aria-components, focusing on the advertised exports/index.ts and exports/** paths. Reproduce the failure with Vite's source condition and verify that root and deep imports either resolve those files from npm or fall back to the distributed ESM import entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.