Skip to content

Commit edada76

Browse files
Merge remote-tracking branch 'upstream/main' into chore-rsc-nightly
2 parents 0e0a6e2 + c719e5d commit edada76

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

packages/plugin-react/CHANGELOG.md

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

33
## Unreleased
44

5+
### Skip transform hook completely in rolldown-vite in dev if possible ([#783](https://github.com/vitejs/vite-plugin-react/pull/783))
6+
57
## 5.0.1 (2025-08-19)
68

79
### Set `optimizeDeps.rollupOptions.transform.jsx` instead of `optimizeDeps.rollupOptions.jsx` for rolldown-vite ([#735](https://github.com/vitejs/vite-plugin-react/pull/735))

packages/plugin-react/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ export default function viteReact(opts: Options = {}): Plugin[] {
208208
staticBabelOptions = createBabelOptions(opts.babel)
209209

210210
if (
211+
(isRolldownVite || skipFastRefresh) &&
211212
canSkipBabel(staticBabelOptions.plugins, staticBabelOptions) &&
212-
skipFastRefresh &&
213213
(opts.jsxRuntime === 'classic' ? isProduction : true)
214214
) {
215215
delete viteBabel.transform
@@ -269,8 +269,7 @@ export default function viteReact(opts: Options = {}): Plugin[] {
269269

270270
const isJSX = filepath.endsWith('x')
271271
const useFastRefresh =
272-
!isRolldownVite &&
273-
!skipFastRefresh &&
272+
!(isRolldownVite || skipFastRefresh) &&
274273
!ssr &&
275274
(isJSX ||
276275
(opts.jsxRuntime === 'classic'

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,42 @@ function defineTest(f: Fixture) {
238238
await testUseActionState(page)
239239
})
240240

241+
test('useActionState nojs to js', async ({ page, browserName }) => {
242+
// firefox seems to cache html and route interception doesn't work
243+
test.skip(browserName === 'firefox')
244+
245+
// this test fails without `formState` passed to `hydrateRoot(..., { formState })`
246+
247+
// intercept request to disable js
248+
let js: boolean
249+
await page.route(f.url(), async (route) => {
250+
if (!js) {
251+
await route.continue({ url: route.request().url() + '?__nojs' })
252+
return
253+
}
254+
await route.continue()
255+
})
256+
257+
// no js
258+
js = false
259+
await page.goto(f.url())
260+
await expect(page.getByTestId('use-action-state')).toContainText(
261+
'test-useActionState: 0',
262+
)
263+
await page.getByTestId('use-action-state').click()
264+
await expect(page.getByTestId('use-action-state')).toContainText(
265+
'test-useActionState: 1',
266+
)
267+
268+
// with js (hydration)
269+
js = true
270+
await page.getByTestId('use-action-state').click()
271+
await waitForHydration(page)
272+
await expect(page.getByTestId('use-action-state')).toContainText(
273+
'test-useActionState: 2', // this becomes "0" without formState
274+
)
275+
})
276+
241277
async function testUseActionState(page: Page) {
242278
await expect(page.getByTestId('use-action-state')).toContainText(
243279
'test-useActionState: 0',

0 commit comments

Comments
 (0)