Skip to content

Commit 355db75

Browse files
authored
Merge branch 'main' into feat/merge-plugin-oxc
2 parents b9eb52c + 707f35b commit 355db75

20 files changed

+1158
-376
lines changed

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

packages/plugin-rsc/CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Best for testing specific edge cases or isolated features. See `e2e/ssr-thenable
3636
# Build packages
3737
pnpm dev # pnpm -C packages/plugin-rsc dev
3838

39+
# Type check
40+
pnpm -C packages/plugin-rsc tsc-dev
41+
3942
# Run examples
4043
pnpm -C packages/plugin-rsc/examples/basic dev # build / preview
4144
pnpm -C packages/plugin-rsc/examples/starter dev # build / preview
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { test } from '@playwright/test'
2+
import { setupInlineFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
5+
test.describe(() => {
6+
const root = 'examples/e2e/temp/base'
7+
8+
test.beforeAll(async () => {
9+
await setupInlineFixture({
10+
src: 'examples/starter',
11+
dest: root,
12+
files: {
13+
'vite.config.base.ts': { cp: 'vite.config.ts' },
14+
'vite.config.ts': /* js */ `
15+
import { defineConfig, mergeConfig } from 'vite'
16+
import baseConfig from './vite.config.base.ts'
17+
18+
const overrideConfig = defineConfig({
19+
base: '/custom-base/',
20+
})
21+
22+
export default mergeConfig(baseConfig, overrideConfig)
23+
`,
24+
},
25+
})
26+
})
27+
28+
test.describe('dev-base', () => {
29+
const f = useFixture({ root, mode: 'dev' })
30+
defineStarterTest({
31+
...f,
32+
url: (url) => new URL(url ?? './', f.url('./custom-base/')).href,
33+
})
34+
})
35+
36+
test.describe('build-base', () => {
37+
const f = useFixture({ root, mode: 'build' })
38+
defineStarterTest({
39+
...f,
40+
url: (url) => new URL(url ?? './', f.url('./custom-base/')).href,
41+
})
42+
})
43+
})

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { createHash } from 'node:crypto'
22
import { readFileSync } from 'node:fs'
33
import { type Page, expect, test } from '@playwright/test'
4-
import { type Fixture, setupIsolatedFixture, useFixture } from './fixture'
4+
import { type Fixture, useFixture } from './fixture'
55
import {
66
expectNoPageError,
77
expectNoReload,
88
testNoJs,
99
waitForHydration,
1010
} from './helper'
11-
import path from 'node:path'
12-
import os from 'node:os'
1311

1412
test.describe('dev-default', () => {
1513
const f = useFixture({ root: 'examples/basic', mode: 'dev' })
@@ -48,31 +46,6 @@ test.describe('build-default', () => {
4846
defineTest(f)
4947
})
5048

51-
test.describe(() => {
52-
// disabled by default
53-
if (process.env.TEST_ISOLATED !== 'true') return
54-
55-
// use RUNNER_TEMP on Github Actions
56-
// https://github.com/actions/toolkit/issues/518
57-
const tmpRoot = path.join(
58-
process.env['RUNNER_TEMP'] || os.tmpdir(),
59-
'test-vite-rsc',
60-
)
61-
test.beforeAll(async () => {
62-
await setupIsolatedFixture({ src: 'examples/basic', dest: tmpRoot })
63-
})
64-
65-
test.describe('dev-isolated', () => {
66-
const f = useFixture({ root: tmpRoot, mode: 'dev' })
67-
defineTest(f)
68-
})
69-
70-
test.describe('build-isolated', () => {
71-
const f = useFixture({ root: tmpRoot, mode: 'build' })
72-
defineTest(f)
73-
})
74-
})
75-
7649
function defineTest(f: Fixture) {
7750
test('basic', async ({ page }) => {
7851
using _ = expectNoPageError(page)

packages/plugin-rsc/e2e/fixture.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export async function setupIsolatedFixture(options: {
162162
const packagesDir = path.join(import.meta.dirname, '..', '..')
163163
const overrides = {
164164
'@vitejs/plugin-rsc': `file:${path.join(packagesDir, 'plugin-rsc')}`,
165+
'@vitejs/plugin-react': `file:${path.join(packagesDir, 'plugin-react')}`,
165166
}
166167
editFileJson(path.join(options.dest, 'package.json'), (pkg: any) => {
167168
Object.assign(((pkg.pnpm ??= {}).overrides ??= {}), overrides)
@@ -200,7 +201,10 @@ function editFileJson(filepath: string, edit: (s: string) => string) {
200201
export async function setupInlineFixture(options: {
201202
src: string
202203
dest: string
203-
files?: Record<string, string>
204+
files?: Record<
205+
string,
206+
string | { cp: string } | { edit: (s: string) => string }
207+
>
204208
}) {
205209
fs.rmSync(options.dest, { recursive: true, force: true })
206210
fs.mkdirSync(options.dest, { recursive: true })
@@ -214,16 +218,29 @@ export async function setupInlineFixture(options: {
214218
// write additional files
215219
if (options.files) {
216220
for (let [filename, contents] of Object.entries(options.files)) {
217-
let filepath = path.join(options.dest, filename)
218-
fs.mkdirSync(path.dirname(filepath), { recursive: true })
219-
// strip indent
221+
const destFile = path.join(options.dest, filename)
222+
fs.mkdirSync(path.dirname(destFile), { recursive: true })
223+
224+
// custom command
225+
if (typeof contents === 'object' && 'cp' in contents) {
226+
const srcFile = path.join(options.dest, contents.cp)
227+
fs.copyFileSync(srcFile, destFile)
228+
continue
229+
}
230+
if (typeof contents === 'object' && 'edit' in contents) {
231+
const editted = contents.edit(fs.readFileSync(destFile, 'utf-8'))
232+
fs.writeFileSync(destFile, editted)
233+
continue
234+
}
235+
236+
// write a new file
220237
contents = contents.replace(/^\n*/, '').replace(/\s*$/, '\n')
221238
const indent = contents.match(/^\s*/)?.[0] ?? ''
222239
const strippedContents = contents
223240
.split('\n')
224241
.map((line) => line.replace(new RegExp(`^${indent}`), ''))
225242
.join('\n')
226-
fs.writeFileSync(filepath, strippedContents)
243+
fs.writeFileSync(destFile, strippedContents)
227244
}
228245
}
229246
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { test } from '@playwright/test'
2+
import { setupIsolatedFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
import path from 'node:path'
5+
import os from 'node:os'
6+
7+
test.describe(() => {
8+
// use RUNNER_TEMP on Github Actions
9+
// https://github.com/actions/toolkit/issues/518
10+
const tmpRoot = path.join(
11+
process.env['RUNNER_TEMP'] || os.tmpdir(),
12+
'test-vite-rsc',
13+
)
14+
test.beforeAll(async () => {
15+
await setupIsolatedFixture({ src: 'examples/starter', dest: tmpRoot })
16+
})
17+
18+
test.describe('dev-isolated', () => {
19+
const f = useFixture({ root: tmpRoot, mode: 'dev' })
20+
defineStarterTest(f)
21+
})
22+
23+
test.describe('build-isolated', () => {
24+
const f = useFixture({ root: tmpRoot, mode: 'build' })
25+
defineStarterTest(f)
26+
})
27+
})
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { test } from '@playwright/test'
2+
import { setupInlineFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
5+
test.describe(() => {
6+
const root = 'examples/e2e/temp/module-runner-hmr-false'
7+
8+
test.beforeAll(async () => {
9+
await setupInlineFixture({
10+
src: 'examples/starter',
11+
dest: root,
12+
files: {
13+
'vite.config.base.ts': { cp: 'vite.config.ts' },
14+
'vite.config.ts': /* js */ `
15+
import { defineConfig, mergeConfig, createRunnableDevEnvironment } from 'vite'
16+
import baseConfig from './vite.config.base.ts'
17+
18+
const overrideConfig = defineConfig({
19+
environments: {
20+
ssr: {
21+
dev: {
22+
createEnvironment(name, config) {
23+
return createRunnableDevEnvironment(name, config, {
24+
runnerOptions: {
25+
hmr: false,
26+
},
27+
})
28+
},
29+
},
30+
},
31+
rsc: {
32+
dev: {
33+
createEnvironment(name, config) {
34+
return createRunnableDevEnvironment(name, config, {
35+
runnerOptions: {
36+
hmr: false,
37+
},
38+
})
39+
},
40+
},
41+
},
42+
},
43+
})
44+
45+
export default mergeConfig(baseConfig, overrideConfig)
46+
`,
47+
},
48+
})
49+
})
50+
51+
test.describe('dev-module-runner-hmr-false', () => {
52+
const f = useFixture({ root, mode: 'dev' })
53+
defineStarterTest(f)
54+
})
55+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { expect, test } from '@playwright/test'
2+
import { useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
import path from 'node:path'
5+
import fs from 'node:fs'
6+
7+
test.describe('dev-no-ssr', () => {
8+
const f = useFixture({ root: 'examples/no-ssr', mode: 'dev' })
9+
defineStarterTest(f, 'no-ssr')
10+
})
11+
12+
test.describe('build-no-ssr', () => {
13+
const f = useFixture({ root: 'examples/no-ssr', mode: 'build' })
14+
defineStarterTest(f, 'no-ssr')
15+
16+
test('no ssr build', () => {
17+
expect(fs.existsSync(path.join(f.root, 'dist/ssr'))).toBe(false)
18+
})
19+
})
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { expect, test } from '@playwright/test'
2+
import { setupInlineFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
import { waitForHydration } from './helper'
5+
6+
test.describe(() => {
7+
const root = 'examples/e2e/temp/react-compiler'
8+
9+
test.beforeAll(async () => {
10+
await setupInlineFixture({
11+
src: 'examples/starter',
12+
dest: root,
13+
files: {
14+
'vite.config.base.ts': { cp: 'vite.config.ts' },
15+
'vite.config.ts': /* js */ `
16+
import rsc from '@vitejs/plugin-rsc'
17+
import react from '@vitejs/plugin-react'
18+
import { defineConfig, mergeConfig } from 'vite'
19+
import baseConfig from './vite.config.base.ts'
20+
21+
delete baseConfig.plugins
22+
23+
const overrideConfig = defineConfig({
24+
plugins: [
25+
react({
26+
babel: { plugins: ['babel-plugin-react-compiler'] },
27+
}).map((p) => ({
28+
...p,
29+
applyToEnvironment: (e) => e.name === 'client',
30+
})),
31+
rsc(),
32+
],
33+
})
34+
35+
export default mergeConfig(baseConfig, overrideConfig)
36+
`,
37+
},
38+
})
39+
})
40+
41+
test.describe('dev-react-compiler', () => {
42+
const f = useFixture({ root, mode: 'dev' })
43+
defineStarterTest(f)
44+
45+
test('verify react compiler', async ({ page }) => {
46+
await page.goto(f.url())
47+
await waitForHydration(page)
48+
const res = await page.request.get(f.url('src/client.tsx'))
49+
expect(await res.text()).toContain('react.memo_cache_sentinel')
50+
})
51+
})
52+
53+
test.describe('build-react-compiler', () => {
54+
const f = useFixture({ root, mode: 'build' })
55+
defineStarterTest(f)
56+
})
57+
})

0 commit comments

Comments
 (0)