Skip to content

Commit 8c0ed01

Browse files
committed
Merge branch 'main' into fix/css-queries-collection
2 parents 4fd1b65 + c7bc716 commit 8c0ed01

File tree

206 files changed

+6702
-3733
lines changed

Some content is hidden

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

206 files changed

+6702
-3733
lines changed

.github/workflows/ci-rsc.yml

Lines changed: 18 additions & 4 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
@@ -31,13 +32,14 @@ jobs:
3132
- run: pnpm -C packages/plugin-rsc test
3233

3334
test-e2e:
34-
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }}) ${{ matrix.rolldown == true && '(rolldown)' || '' }}
35+
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }}) ${{ matrix.rolldown == true && '(rolldown)' || '' }} ${{ matrix.react_version && format('(react-{0})', matrix.react_version) || '' }}
3536
runs-on: ${{ matrix.os }}
3637
strategy:
3738
matrix:
3839
os: [ubuntu-latest, macos-latest, windows-latest]
3940
browser: [chromium]
4041
rolldown: [false]
42+
react_version: [""]
4143
include:
4244
- os: ubuntu-latest
4345
browser: firefox
@@ -46,6 +48,12 @@ jobs:
4648
- os: ubuntu-latest
4749
browser: chromium
4850
rolldown: true
51+
- os: ubuntu-latest
52+
browser: chromium
53+
react_version: canary
54+
- os: ubuntu-latest
55+
browser: chromium
56+
react_version: experimental
4957
fail-fast: false
5058
steps:
5159
- uses: actions/checkout@v4
@@ -54,6 +62,13 @@ jobs:
5462
node-version: 22
5563
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
5664
- run: pnpm i
65+
- name: install react
66+
if: ${{ matrix.react_version }}
67+
run: |
68+
sed -i "/^overrides:/a\ react: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
69+
sed -i "/^overrides:/a\ react-dom: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
70+
sed -i "/^overrides:/a\ react-server-dom-webpack: \"${{ matrix.react_version }}\"" pnpm-workspace.yaml
71+
pnpm i --no-frozen-lockfile
5772
- run: pnpm build
5873
- name: install rolldown
5974
if: ${{ matrix.rolldown }}
@@ -62,11 +77,10 @@ jobs:
6277
pnpm i --no-frozen-lockfile
6378
- run: pnpm -C packages/plugin-rsc exec playwright install ${{ matrix.browser }}
6479
- run: pnpm -C packages/plugin-rsc test-e2e-ci --project=${{ matrix.browser }}
65-
env:
66-
TEST_ISOLATED: true
6780
- uses: actions/upload-artifact@v4
6881
if: always()
6982
with:
70-
name: test-results-${{ matrix.os }}-${{ matrix.browser }}${{ matrix.rolldown == true && '-rolldown' || '' }}
83+
name: test-results-${{ matrix.os }}-${{ matrix.browser }}${{ matrix.rolldown == true && '-rolldown' || '' }}${{ matrix.react_version && format('-react-{0}', matrix.react_version) || '' }}
7184
path: |
7285
packages/plugin-rsc/test-results
86+
if-no-files-found: ignore

.github/workflows/ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
strategy:
3030
matrix:
3131
os: [ubuntu-latest]
32-
node_version: [18, 20, 22, 24]
32+
node_version: [20, 22, 24]
3333
include:
3434
# Active LTS + other OS
3535
- os: macos-latest
@@ -81,9 +81,6 @@ jobs:
8181
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
8282
run: pnpm playwright install chromium
8383

84-
- if: matrix.node_version == '18'
85-
run: pnpm i -D [email protected] -w
86-
8784
- name: Build
8885
run: pnpm run build
8986

@@ -96,6 +93,17 @@ jobs:
9693
- name: Test SWC
9794
run: pnpm --filter ./packages/plugin-react-swc run test
9895

96+
- name: Setup rolldown-vite
97+
run: |
98+
sed -i"" -e "s/overrides:/overrides:\n vite: catalog:rolldown-vite/" pnpm-workspace.yaml
99+
pnpm i --no-frozen-lockfile
100+
101+
- name: Test serve (rolldown-vite)
102+
run: pnpm run test-serve
103+
104+
- name: Test build (rolldown-vite)
105+
run: pnpm run test-build
106+
99107
lint:
100108
if: github.repository == 'vitejs/vite-plugin-react'
101109
timeout-minutes: 10
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
2+
3+
name: "Copilot Setup Steps"
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
jobs:
15+
copilot-setup-steps:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
27+
- run: pnpm i
28+
- run: pnpm exec playwright install chromium

.github/workflows/issue-close-require.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
pull-requests: write # for actions-cool/issues-helper to update PRs
1414
steps:
1515
- name: need reproduction
16-
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3
16+
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3
1717
with:
1818
actions: "close-issues"
1919
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/issue-labeled.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- name: contribution welcome
1616
if: github.event.label.name == 'contribution welcome' || github.event.label.name == 'help wanted'
17-
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3
17+
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3
1818
with:
1919
actions: "create-comment, remove-labels"
2020
token: ${{ secrets.GITHUB_TOKEN }}
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: remove pending
2727
if: (github.event.label.name == 'enhancement' || contains(github.event.label.description, '(priority)')) && contains(github.event.issue.labels.*.name, 'pending triage')
28-
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3
28+
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3
2929
with:
3030
actions: "remove-labels"
3131
token: ${{ secrets.GITHUB_TOKEN }}
@@ -34,7 +34,7 @@ jobs:
3434

3535
- name: need reproduction
3636
if: github.event.label.name == 'need reproduction'
37-
uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3
37+
uses: actions-cool/issues-helper@50068f49b7b2b3857270ead65e2d02e4459b022c # v3
3838
with:
3939
actions: "create-comment, remove-labels"
4040
token: ${{ secrets.GITHUB_TOKEN }}

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.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ See [`@vitejs/plugin-rsc` documentation](packages/plugin-rsc/README.md)
2424
| Package | Version (click for changelogs) |
2525
| ----------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- |
2626
| [@vitejs/plugin-react](packages/plugin-react) | [![plugin-react version](https://img.shields.io/npm/v/@vitejs/plugin-react.svg?label=%20)](packages/plugin-react/CHANGELOG.md) |
27-
| [@vitejs/plugin-react-oxc](packages/plugin-react-oxc) | [![plugin-react-oxc version](https://img.shields.io/npm/v/@vitejs/plugin-react-oxc.svg?label=%20)](packages/plugin-react-oxc/CHANGELOG.md) |
2827
| [@vitejs/plugin-react-swc](packages/plugin-react-swc) | [![plugin-react-swc version](https://img.shields.io/npm/v/@vitejs/plugin-react-swc.svg?label=%20)](packages/plugin-react-swc/CHANGELOG.md) |
2928
| [@vitejs/plugin-rsc](packages/plugin-rsc) | [![plugin-rsc version](https://img.shields.io/npm/v/@vitejs/plugin-rsc.svg?label=%20)](packages/plugin-rsc/CHANGELOG.md) |
29+
| [@vitejs/plugin-react-oxc](packages/plugin-react-oxc) | [Deprecated](packages/plugin-react-oxc/CHANGELOG.md), merged with [`@vitejs/plugin-react`](packages/plugin-react) |
3030

3131
## License
3232

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"private": true,
44
"type": "module",
55
"engines": {
6-
"node": "^14.18.0 || >=16.0.0"
6+
"node": "^20.19.0 || >=22.12.0"
77
},
8-
"packageManager": "pnpm@10.13.1",
8+
"packageManager": "pnpm@10.14.0",
99
"homepage": "https://github.com/vitejs/vite-plugin-react/",
1010
"keywords": [
1111
"frontend",
@@ -33,25 +33,25 @@
3333
"ci-publish": "tsx scripts/publishCI.ts"
3434
},
3535
"devDependencies": {
36-
"@eslint/js": "^9.31.0",
36+
"@eslint/js": "^9.33.0",
3737
"@types/fs-extra": "^11.0.4",
38-
"@types/node": "^22.16.3",
38+
"@types/node": "^22.17.1",
3939
"@vitejs/release-scripts": "^1.6.0",
40-
"eslint": "^9.31.0",
40+
"eslint": "^9.33.0",
4141
"eslint-plugin-import-x": "^4.16.1",
42-
"eslint-plugin-n": "^17.21.0",
43-
"eslint-plugin-regexp": "^2.9.0",
44-
"fs-extra": "^11.3.0",
42+
"eslint-plugin-n": "^17.21.3",
43+
"eslint-plugin-regexp": "^2.10.0",
44+
"fs-extra": "^11.3.1",
4545
"globals": "^16.3.0",
4646
"lint-staged": "^15.5.2",
4747
"picocolors": "^1.1.1",
48-
"playwright-chromium": "^1.54.1",
48+
"playwright-chromium": "^1.54.2",
4949
"prettier": "^3.6.2",
50-
"simple-git-hooks": "^2.13.0",
50+
"simple-git-hooks": "^2.13.1",
5151
"tsx": "^4.20.3",
52-
"typescript": "^5.8.3",
53-
"typescript-eslint": "^8.37.0",
54-
"vite": "^7.0.4",
52+
"typescript": "^5.9.2",
53+
"typescript-eslint": "^8.39.0",
54+
"vite": "^7.1.1",
5555
"vitest": "^3.2.4"
5656
},
5757
"simple-git-hooks": {

packages/common/refresh-runtime.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,21 @@ function isLikelyComponentType(type) {
545545
}
546546
}
547547

548+
function isCompoundComponent(type) {
549+
if (!isPlainObject(type)) return false
550+
for (const key in type) {
551+
if (!isLikelyComponentType(type[key])) return false
552+
}
553+
return true
554+
}
555+
556+
function isPlainObject(obj) {
557+
return (
558+
Object.prototype.toString.call(obj) === '[object Object]' &&
559+
(obj.constructor === Object || obj.constructor === undefined)
560+
)
561+
}
562+
548563
/**
549564
* Plugin utils
550565
*/
@@ -565,6 +580,13 @@ export function registerExportsForReactRefresh(filename, moduleExports) {
565580
// The register function has an identity check to not register twice the same component,
566581
// so this is safe to not used the same key here.
567582
register(exportValue, filename + ' export ' + key)
583+
} else if (isCompoundComponent(exportValue)) {
584+
for (const subKey in exportValue) {
585+
register(
586+
exportValue[subKey],
587+
filename + ' export ' + key + '-' + subKey,
588+
)
589+
}
568590
}
569591
}
570592
}
@@ -618,6 +640,7 @@ export function validateRefreshBoundaryAndEnqueueUpdate(
618640
(key, value) => {
619641
hasExports = true
620642
if (isLikelyComponentType(value)) return true
643+
if (isCompoundComponent(value)) return true
621644
return prevExports[key] === nextExports[key]
622645
},
623646
)

packages/plugin-react-oxc/CHANGELOG.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,44 @@
22

33
## Unreleased
44

5-
### Return `Plugin[]` instead of `PluginOption[]`
5+
## 0.4.0 (2025-08-07)
6+
7+
## 0.4.0-beta.0 (2025-07-28)
8+
9+
### Deprecate this plugin
10+
11+
The changes of this plugin is now included in `@vitejs/plugin-react`. Please use `@vitejs/plugin-react` instead.
12+
13+
### Allow processing files in `node_modules`
14+
15+
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.
16+
17+
### Require Node 20.19+, 22.12+
18+
19+
This plugin now requires Node 20.19+ or 22.12+.
20+
21+
## 0.3.0 (2025-07-18)
22+
23+
### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))
24+
25+
HMR now works for compound components like this:
26+
27+
```tsx
28+
const Root = () => <div>Accordion Root</div>
29+
const Item = () => <div>Accordion Item</div>
30+
31+
export const Accordion = { Root, Item }
32+
```
33+
34+
### Return `Plugin[]` instead of `PluginOption[]` ([#537](https://github.com/vitejs/vite-plugin-react/pull/537))
35+
36+
The return type has changed from `react(): PluginOption[]` to more specialized type `react(): Plugin[]`. This allows for type-safe manipulation of plugins, for example:
37+
38+
```tsx
39+
// previously this causes type errors
40+
react()
41+
.map(p => ({ ...p, applyToEnvironment: e => e.name === 'client' }))
42+
```
643

744
## 0.2.3 (2025-06-16)
845

0 commit comments

Comments
 (0)