Skip to content

Commit 84460c0

Browse files
Merge remote-tracking branch 'upstream/main' into chore-rsc-nightly
2 parents 3156088 + 71bb49c commit 84460c0

File tree

18 files changed

+187
-2
lines changed

18 files changed

+187
-2
lines changed

packages/plugin-react/CHANGELOG.md

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

33
## Unreleased
44

5+
### Fix `reactRefreshHost` option on rolldown-vite ([#716](https://github.com/vitejs/vite-plugin-react/pull/716))
6+
7+
### Fix `RefreshRuntime` being injected twice for class components on rolldown-vite ([#708](https://github.com/vitejs/vite-plugin-react/pull/708))
8+
9+
### Skip `babel-plugin-react-compiler` on non client environment ([689](https://github.com/vitejs/vite-plugin-react/pull/689))
10+
511
## 5.0.0 (2025-08-07)
612

713
## 5.0.0-beta.0 (2025-07-28)

packages/plugin-react/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,15 @@ export default function viteReact(opts: Options = {}): Plugin[] {
255255

256256
const isJSX = filepath.endsWith('x')
257257
const useFastRefresh =
258+
!isRolldownVite &&
258259
!skipFastRefresh &&
259260
!ssr &&
260261
(isJSX ||
261262
(opts.jsxRuntime === 'classic'
262263
? importReactRE.test(code)
263264
: code.includes(jsxImportDevRuntime) ||
264265
code.includes(jsxImportRuntime)))
265-
if (useFastRefresh && !isRolldownVite) {
266+
if (useFastRefresh) {
266267
plugins.push([
267268
await loadPlugin('react-refresh/babel'),
268269
{ skipEnvCheck: true },
@@ -368,6 +369,7 @@ export default function viteReact(opts: Options = {}): Plugin[] {
368369
avoidSourceMapOption,
369370
'@vitejs/plugin-react',
370371
id,
372+
opts.reactRefreshHost,
371373
)
372374
return { code: newCode, map: null }
373375
},

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,4 +1152,31 @@ function defineTest(f: Fixture) {
11521152
'(cacheFnCount = 4, nonCacheFnCount = 6)',
11531153
)
11541154
})
1155+
1156+
test('css queries', async ({ page }) => {
1157+
await page.goto(f.url())
1158+
await waitForHydration(page)
1159+
1160+
const tests = [
1161+
['.test-css-url-client', 'rgb(255, 100, 0)'],
1162+
['.test-css-inline-client', 'rgb(255, 50, 0)'],
1163+
['.test-css-raw-client', 'rgb(255, 0, 0)'],
1164+
['.test-css-url-server', 'rgb(0, 255, 100)'],
1165+
['.test-css-inline-server', 'rgb(0, 255, 50)'],
1166+
['.test-css-raw-server', 'rgb(0, 255, 0)'],
1167+
] as const
1168+
1169+
// css with queries are not injected automatically
1170+
for (const [selector] of tests) {
1171+
await expect(page.locator(selector)).toHaveCSS('color', 'rgb(0, 0, 0)')
1172+
}
1173+
1174+
// inject css manually
1175+
await page.getByRole('button', { name: 'test-css-queries' }).click()
1176+
1177+
// verify styles
1178+
for (const [selector, color] of tests) {
1179+
await expect(page.locator(selector)).toHaveCSS('color', color)
1180+
}
1181+
})
11551182
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { test } from '@playwright/test'
2+
import { setupInlineFixture, useFixture } from './fixture'
3+
import { defineStarterTest } from './starter'
4+
import fs from 'node:fs'
5+
import path from 'node:path'
6+
7+
test.describe(() => {
8+
const root = 'examples/e2e/temp/root'
9+
10+
test.beforeAll(async () => {
11+
await setupInlineFixture({
12+
src: 'examples/starter',
13+
dest: root,
14+
files: {
15+
'vite.config.base.ts': { cp: 'vite.config.ts' },
16+
'vite.config.ts': /* js */ `
17+
import baseConfig from './vite.config.base.ts'
18+
import path from "node:path";
19+
baseConfig.root = "./custom-root";
20+
for (const e of Object.values(baseConfig.environments)) {
21+
e.build.rollupOptions.input.index = path.resolve(
22+
'custom-root',
23+
e.build.rollupOptions.input.index,
24+
);
25+
}
26+
export default baseConfig;
27+
`,
28+
},
29+
})
30+
fs.mkdirSync(`${root}/custom-root`, { recursive: true })
31+
fs.renameSync(`${root}/src`, `${root}/custom-root/src`)
32+
fs.renameSync(`${root}/public`, `${root}/custom-root/public`)
33+
})
34+
35+
test.describe('dev-root', () => {
36+
const f = useFixture({ root, mode: 'dev' })
37+
const oldCreateEditor = f.createEditor
38+
f.createEditor = (filePath: string) =>
39+
oldCreateEditor(path.resolve(root, 'custom-root', filePath))
40+
defineStarterTest(f)
41+
})
42+
43+
test.describe('build-root', () => {
44+
const f = useFixture({ root, mode: 'build' })
45+
defineStarterTest(f)
46+
})
47+
})
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-css-inline-client {
2+
color: rgb(255, 50, 0);
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-css-raw-client {
2+
color: rgb(255, 0, 0);
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-css-url-client {
2+
color: rgb(255, 100, 0);
3+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use client'
2+
3+
import cssUrl from './client-url.css?url'
4+
import cssInline from './client-inline.css?inline'
5+
import cssRaw from './client-raw.css?raw'
6+
import React from 'react'
7+
8+
export function TestCssQueriesClient(props: {
9+
serverUrl: string
10+
serverInline: string
11+
serverRaw: string
12+
}) {
13+
const [enabled, setEnabled] = React.useState(false)
14+
15+
function urlWithHmr(href: string) {
16+
if (import.meta.hot) {
17+
href += '?t=' + Date.now()
18+
}
19+
return href
20+
}
21+
22+
return (
23+
<div>
24+
<button onClick={() => setEnabled(!enabled)}>test-css-queries</button>
25+
{enabled && (
26+
<>
27+
<link rel="stylesheet" href={urlWithHmr(cssUrl)} />
28+
<style>{cssInline}</style>
29+
<style>{cssRaw}</style>
30+
<link rel="stylesheet" href={urlWithHmr(props.serverUrl)} />
31+
<style>{props.serverInline}</style>
32+
<style>{props.serverRaw}</style>
33+
</>
34+
)}
35+
<div className="test-css-url-client">test-css-url-client</div>
36+
<div className="test-css-inline-client">test-css-inline-client</div>
37+
<div className="test-css-raw-client">test-css-raw-client</div>
38+
</div>
39+
)
40+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-css-inline-server {
2+
color: rgb(0, 255, 50);
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test-css-raw-server {
2+
color: rgb(0, 255, 0);
3+
}

0 commit comments

Comments
 (0)