Skip to content

Commit fe6fd0e

Browse files
Merge remote-tracking branch 'upstream/main' into chore-rsc-nightly
2 parents dfb2ac0 + 707f35b commit fe6fd0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1487
-470
lines changed

.github/workflows/ci-rsc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: ci-rsc
33
permissions: {}
44

55
on:
6+
workflow_dispatch:
67
push:
78
branches:
89
- main

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,7 @@ Some errors are masked and hidden away because of the layers of abstraction and
132132
In many test cases, we need to mock dependencies using `link:` and `file:` protocols. `pnpm` treats `link:` as symlinks and `file:` as hardlinks. To test dependencies as if they were copied into `node_modules`, use the `file:` protocol. Otherwise, use the `link:` protocol.
133133

134134
For a mock dependency, make sure you add a `@vitejs/test-` prefix to the package name. This will avoid possible issues like false-positive alerts.
135+
136+
## Contributing to `@vitejs/plugin-rsc`
137+
138+
See [CONTRIBUTING.md](packages/plugin-rsc/CONTRIBUTING.md) in the `@vitejs/plugin-rsc` package for specific guidelines on contributing to the React Server Components plugin.

packages/plugin-react-oxc/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Allow processing files in `node_modules`
6+
7+
The default value of `exclude` options is now `[/\/node_modules\//]` to allow processing files in `node_modules` directory. It was previously `[]` and files in `node_modules` was always excluded regardless of the value of `exclude` option.
8+
59
### Require Node 20.19+, 22.12+
610

711
This plugin now requires Node 20.19+ or 22.12+.

packages/plugin-react-oxc/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default defineConfig({
2525

2626
### include/exclude
2727

28-
Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
28+
Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
2929

3030
```js
3131
import { defineConfig } from 'vite'
@@ -40,8 +40,6 @@ export default defineConfig({
4040
})
4141
```
4242

43-
> `node_modules` are never processed by this plugin (but Oxc will)
44-
4543
### jsxImportSource
4644

4745
Control where the JSX factory is imported from. Default to `'react'`

packages/plugin-react-oxc/src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,11 @@ export interface Options {
2525
}
2626

2727
const defaultIncludeRE = /\.[tj]sx?(?:$|\?)/
28+
const defaultExcludeRE = /\/node_modules\//
2829

2930
export default function viteReact(opts: Options = {}): Plugin[] {
3031
const include = opts.include ?? defaultIncludeRE
31-
const exclude = [
32-
...(Array.isArray(opts.exclude)
33-
? opts.exclude
34-
: opts.exclude
35-
? [opts.exclude]
36-
: []),
37-
/\/node_modules\//,
38-
]
32+
const exclude = opts.exclude ?? defaultExcludeRE
3933

4034
const jsxImportSource = opts.jsxImportSource ?? 'react'
4135
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`

packages/plugin-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Allow processing files in `node_modules`
6+
7+
The default value of `exclude` options is now `[/\/node_modules\//]` to allow processing files in `node_modules` directory. It was previously `[]` and files in `node_modules` was always excluded regardless of the value of `exclude` option.
8+
59
### `react` and `react-dom` is no longer added to [`resolve.dedupe`](https://vite.dev/config/#resolve-dedupe) automatically
610

711
Adding values to `resolve.dedupe` forces Vite to resolve them differently from how Node.js does, which can be confusing and may not be expected. This plugin no longer adds `react` and `react-dom` to `resolve.dedupe` automatically.

packages/plugin-react/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default defineConfig({
2121

2222
### include/exclude
2323

24-
Includes `.js`, `.jsx`, `.ts` & `.tsx` by default. This option can be used to add fast refresh to `.mdx` files:
24+
Includes `.js`, `.jsx`, `.ts` & `.tsx` and excludes `/node_modules/` by default. This option can be used to add fast refresh to `.mdx` files:
2525

2626
```js
2727
import { defineConfig } from 'vite'
@@ -36,8 +36,6 @@ export default defineConfig({
3636
})
3737
```
3838

39-
> `node_modules` are never processed by this plugin (but esbuild will)
40-
4139
### jsxImportSource
4240

4341
Control where the JSX factory is imported from. Default to `'react'`

packages/plugin-react/src/index.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,12 @@ export type ViteReactPluginApi = {
104104
}
105105

106106
const defaultIncludeRE = /\.[tj]sx?$/
107+
const defaultExcludeRE = /\/node_modules\//
107108
const tsRE = /\.tsx?$/
108109

109110
export default function viteReact(opts: Options = {}): Plugin[] {
110111
const include = opts.include ?? defaultIncludeRE
111-
const exclude = opts.exclude
112+
const exclude = opts.exclude ?? defaultExcludeRE
112113
const filter = createFilter(include, exclude)
113114

114115
const jsxImportSource = opts.jsxImportSource ?? 'react'
@@ -222,17 +223,10 @@ export default function viteReact(opts: Options = {}): Plugin[] {
222223
filter: {
223224
id: {
224225
include: makeIdFiltersToMatchWithQuery(include),
225-
exclude: [
226-
...(exclude
227-
? makeIdFiltersToMatchWithQuery(ensureArray(exclude))
228-
: []),
229-
/\/node_modules\//,
230-
],
226+
exclude: makeIdFiltersToMatchWithQuery(exclude),
231227
},
232228
},
233229
async handler(code, id, options) {
234-
if (id.includes('/node_modules/')) return
235-
236230
const [filepath] = id.split('?')
237231
if (!filter(filepath)) return
238232

@@ -472,7 +466,3 @@ function getReactCompilerRuntimeModule(
472466
}
473467
return moduleName
474468
}
475-
476-
function ensureArray<T>(value: T | T[]): T[] {
477-
return Array.isArray(value) ? value : [value]
478-
}

packages/plugin-rsc/CHANGELOG.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
## <small>[0.4.13](https://github.com/vitejs/vite-plugin-react/compare/[email protected]@0.4.13) (2025-07-24)</small>
2+
### Features
3+
4+
* **rsc:** add support for `experimental.renderBuiltUrl` on assets metadata ([#612](https://github.com/vitejs/vite-plugin-react/issues/612)) ([5314ed6](https://github.com/vitejs/vite-plugin-react/commit/5314ed60572e2c89963e5a720d21bcad17687382))
5+
6+
### Bug Fixes
7+
8+
* **deps:** update all non-major dependencies ([#568](https://github.com/vitejs/vite-plugin-react/issues/568)) ([d14f31d](https://github.com/vitejs/vite-plugin-react/commit/d14f31d3bf8487346ae6f9db7e6ca7263c93066b))
9+
* **deps:** update all non-major dependencies ([#593](https://github.com/vitejs/vite-plugin-react/issues/593)) ([9ce3b22](https://github.com/vitejs/vite-plugin-react/commit/9ce3b22e4bc7db28f549b9c9b9195d2bd82ff736))
10+
* **rsc:** await handler to avoid unhandled rejection ([#576](https://github.com/vitejs/vite-plugin-react/issues/576)) ([fa60127](https://github.com/vitejs/vite-plugin-react/commit/fa60127be46d48ecd8a8b0d0e7e6751ed11303e2))
11+
* **rsc:** ensure trailing slash of `BASE_URL` ([#589](https://github.com/vitejs/vite-plugin-react/issues/589)) ([fa1d260](https://github.com/vitejs/vite-plugin-react/commit/fa1d260ef384d986284aaec6e0984967f3b436ad))
12+
* **rsc:** update rsc-html-stream v0.0.7 ([#578](https://github.com/vitejs/vite-plugin-react/issues/578)) ([df6a38e](https://github.com/vitejs/vite-plugin-react/commit/df6a38e42339cf5deecd3f1b6c0aa4dd838833c5))
13+
14+
### Documentation
15+
16+
* **rsc:** add `CONTRIBUTING.md` ([#613](https://github.com/vitejs/vite-plugin-react/issues/613)) ([4005dbe](https://github.com/vitejs/vite-plugin-react/commit/4005dbe1bb943b882d8199ef29ccaeb9d268784e))
17+
18+
### Miscellaneous Chores
19+
20+
* replace `build --app` with `build` in examples ([#572](https://github.com/vitejs/vite-plugin-react/issues/572)) ([7c564ff](https://github.com/vitejs/vite-plugin-react/commit/7c564ff4f290a554927f2eef600e82bffee16e6b))
21+
* **rsc:** comment ([#599](https://github.com/vitejs/vite-plugin-react/issues/599)) ([b550b63](https://github.com/vitejs/vite-plugin-react/commit/b550b63fe7f6ef82588ff0d60389d11906c3cc4e))
22+
* **rsc:** deprecate `@vitejs/plugin-rsc/extra` API ([#592](https://github.com/vitejs/vite-plugin-react/issues/592)) ([bd6a2a1](https://github.com/vitejs/vite-plugin-react/commit/bd6a2a1ff272c8550f92bc1530c7b28fb81e1c60))
23+
* **rsc:** deprecate `rsc-html-stream` re-exports ([#602](https://github.com/vitejs/vite-plugin-react/issues/602)) ([8e0e8b6](https://github.com/vitejs/vite-plugin-react/commit/8e0e8b60c511f34df188a8e8b103cf273891d7ad))
24+
* **rsc:** fix temporary references in examples ([#603](https://github.com/vitejs/vite-plugin-react/issues/603)) ([22e5398](https://github.com/vitejs/vite-plugin-react/commit/22e53987a5548d237fcbe61377bd1da6e86947ef))
25+
* **rsc:** move comment ([#604](https://github.com/vitejs/vite-plugin-react/issues/604)) ([4d6c72f](https://github.com/vitejs/vite-plugin-react/commit/4d6c72f81d64972ac84735240d27516be81431f8))
26+
* **rsc:** remove `@vite/plugin-rsc/extra` API usages from examples ([#596](https://github.com/vitejs/vite-plugin-react/issues/596)) ([87319bf](https://github.com/vitejs/vite-plugin-react/commit/87319bf94ddb07061a1a80d3eefbfadb980f7008))
27+
* **rsc:** remove console.log ([#607](https://github.com/vitejs/vite-plugin-react/issues/607)) ([2a7ff5c](https://github.com/vitejs/vite-plugin-react/commit/2a7ff5c93e600b06aafc7ce1a6d8a11c2ad4cf2e))
28+
* **rsc:** tweak changelog ([#570](https://github.com/vitejs/vite-plugin-react/issues/570)) ([8804446](https://github.com/vitejs/vite-plugin-react/commit/88044469a6399c8a1d909b564f6ddc039782c066))
29+
* **rsc:** update React Router RSC references ([#581](https://github.com/vitejs/vite-plugin-react/issues/581)) ([d464e8f](https://github.com/vitejs/vite-plugin-react/commit/d464e8fc9e8e14bdc84051de9ffacec16317d2ae))
30+
31+
### Tests
32+
33+
* **rsc:** add more basic tests to starter ([#600](https://github.com/vitejs/vite-plugin-react/issues/600)) ([d7fcdd8](https://github.com/vitejs/vite-plugin-react/commit/d7fcdd8550a7a11da01887cbf48a646af898b7f1))
34+
* **rsc:** add SSR thenable workaround in examples ([#591](https://github.com/vitejs/vite-plugin-react/issues/591)) ([bfd434f](https://github.com/vitejs/vite-plugin-react/commit/bfd434f7fdd063ad017aa3c3a41e42983efc0ef4))
35+
* **rsc:** add transitive cjs dep example ([#611](https://github.com/vitejs/vite-plugin-react/issues/611)) ([2a81b90](https://github.com/vitejs/vite-plugin-react/commit/2a81b9015286558c1463ab8079a7a6e40a82a5c6))
36+
* **rsc:** refactor variant tests ([#601](https://github.com/vitejs/vite-plugin-react/issues/601)) ([5167266](https://github.com/vitejs/vite-plugin-react/commit/5167266aff6671065cf5b49cf8ada3d0ace2bbb4))
37+
* **rsc:** remove global unhandled error handlers ([#597](https://github.com/vitejs/vite-plugin-react/issues/597)) ([c5f0bab](https://github.com/vitejs/vite-plugin-react/commit/c5f0babdc06c813bbef08d3c44ee696789416116))
38+
* **rsc:** support `fs:cp` command in `setupInlineFixture` ([#621](https://github.com/vitejs/vite-plugin-react/issues/621)) ([d9cb926](https://github.com/vitejs/vite-plugin-react/commit/d9cb92650b217abba4144d62737c5c696b55d0bb))
39+
* **rsc:** test build with `NODE_ENV=development` and vice versa ([#606](https://github.com/vitejs/vite-plugin-react/issues/606)) ([e8fa2d0](https://github.com/vitejs/vite-plugin-react/commit/e8fa2d0b4cb6e1dd3132fe8b7f45529a74d9be03))
40+
* **rsc:** test module runner `hmr: false` ([#595](https://github.com/vitejs/vite-plugin-react/issues/595)) ([7223093](https://github.com/vitejs/vite-plugin-react/commit/7223093d793242f3d1ef313bbfec692499f0659e))
41+
142
## <small>[0.4.12](https://github.com/vitejs/vite-plugin-react/compare/[email protected]@0.4.12) (2025-07-14)</small>
243
### Features
344

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Contributing to @vitejs/plugin-rsc
2+
3+
This guide provides essential tips for contributors working on the RSC plugin.
4+
5+
## Testing
6+
7+
### E2E Test Setup
8+
9+
Tests use Playwright and are located in `e2e/` and use `examples` as test apps.
10+
11+
#### Test Fixture Patterns
12+
13+
- `examples/basic` - comprehensive test suite for the RSC plugin
14+
- `examples/starter` - lightweight base template for writing more targeted tests using `setupInlineFixture` utility
15+
- `examples/e2e/temp/` - base directory for test projects
16+
17+
### Adding New Test Cases
18+
19+
**Expanding `examples/basic` (for comprehensive features)**
20+
Best for features that should be part of the main test suite. `examples/basic` is mainly used for e2e testing:
21+
22+
1. Add your test case files to `examples/basic/src/routes/`
23+
2. Update the routing in `examples/basic/src/routes/root.tsx`
24+
3. Add corresponding tests in `e2e/basic.test.ts`
25+
26+
**Using `setupInlineFixture` (for specific edge cases)**
27+
Best for testing specific edge cases or isolated features. See `e2e/ssr-thenable.test.ts` for the pattern.
28+
29+
<!-- TODO: mention unit test -->
30+
31+
## Development Workflow
32+
33+
<!-- TODO: mention playwright vscode extension? -->
34+
35+
```bash
36+
# Build packages
37+
pnpm dev # pnpm -C packages/plugin-rsc dev
38+
39+
# Type check
40+
pnpm -C packages/plugin-rsc tsc-dev
41+
42+
# Run examples
43+
pnpm -C packages/plugin-rsc/examples/basic dev # build / preview
44+
pnpm -C packages/plugin-rsc/examples/starter dev # build / preview
45+
46+
# Run all e2e tests
47+
pnpm -C packages/plugin-rsc test-e2e
48+
49+
# Run with UI (this allows filtering interactively)
50+
pnpm -C packages/plugin-rsc test-e2e --ui
51+
52+
# Run specific test file
53+
pnpm -C packages/plugin-rsc test-e2e basic
54+
55+
# Run with filter/grep
56+
pnpm -C packages/plugin-rsc test-e2e -g "hmr"
57+
58+
# Test projects created with `setupInlineFixture` are locally runnable. For example:
59+
pnpm -C packages/plugin-rsc/examples/e2e/temp/react-compiler dev
60+
```
61+
62+
## Tips
63+
64+
- Prefer `setupInlineFixture` for new tests - it's more maintainable and faster
65+
- The `examples/basic` project contains comprehensive test scenarios
66+
- Dependencies for temp test projects are managed in `examples/e2e/package.json`

0 commit comments

Comments
 (0)