Skip to content

Commit 57ed68f

Browse files
committed
Merge branch 'main' into 07-08-test_test_no_refresh_transform_for_non-jsx_files
2 parents 18a57df + bfd434f commit 57ed68f

File tree

115 files changed

+2418
-1125
lines changed

Some content is hidden

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

115 files changed

+2418
-1125
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ body:
1919
[plugin-react-swc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc)
2020
- label: |
2121
[plugin-react-oxc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-oxc)
22+
- label: |
23+
[plugin-rsc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc)
2224
- type: textarea
2325
id: bug-description
2426
attributes:

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ body:
1919
[plugin-react-swc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-swc)
2020
- label: |
2121
[plugin-react-oxc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react-oxc)
22+
- label: |
23+
[plugin-rsc](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-rsc)
2224
- type: textarea
2325
id: feature-description
2426
attributes:

.github/renovate.json5

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
// manually bumping
3737
"node",
3838

39-
"generouted", // testing lib shipping JSX (new version ship transpiled JS)
40-
4139
// breaking changes
4240
"source-map", // `source-map:v0.7.0+` needs more investigation
4341
"kill-port", // `kill-port:^2.0.0 has perf issues (#8392)

.github/workflows/ci-rsc.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,21 @@ jobs:
3131
- run: pnpm -C packages/plugin-rsc test
3232

3333
test-e2e:
34-
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }})
34+
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }}) ${{ matrix.rolldown == true && '(rolldown)' || '' }}
3535
runs-on: ${{ matrix.os }}
3636
strategy:
37-
# TODO: shard?
3837
matrix:
3938
os: [ubuntu-latest, macos-latest, windows-latest]
4039
browser: [chromium]
40+
rolldown: [false]
4141
include:
4242
- os: ubuntu-latest
4343
browser: firefox
4444
- os: macos-latest
4545
browser: webkit
46+
- os: ubuntu-latest
47+
browser: chromium
48+
rolldown: true
4649
fail-fast: false
4750
steps:
4851
- uses: actions/checkout@v4
@@ -52,13 +55,18 @@ jobs:
5255
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
5356
- run: pnpm i
5457
- run: pnpm build
58+
- name: install rolldown
59+
if: ${{ matrix.rolldown }}
60+
run: |
61+
sed -i '/^overrides:/a\ vite: "npm:rolldown-vite@latest"' pnpm-workspace.yaml
62+
pnpm i --no-frozen-lockfile
5563
- run: pnpm -C packages/plugin-rsc exec playwright install ${{ matrix.browser }}
5664
- run: pnpm -C packages/plugin-rsc test-e2e-ci --project=${{ matrix.browser }}
5765
env:
5866
TEST_ISOLATED: true
5967
- uses: actions/upload-artifact@v4
6068
if: always()
6169
with:
62-
name: test-results-${{ matrix.os }}-${{ matrix.browser }}
70+
name: test-results-${{ matrix.os }}-${{ matrix.browser }}${{ matrix.rolldown == true && '-rolldown' || '' }}
6371
path: |
6472
packages/plugin-rsc/test-results

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ This repo is a monorepo using pnpm workspaces. The package manager used to insta
1313
- Checkout a topic branch from a base branch (e.g. `main`), and merge back against that branch.
1414

1515
- If adding a new feature:
16-
1716
- Add accompanying test case.
1817
- Provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first, and have it approved before working on it.
1918

2019
- If fixing a bug:
21-
2220
- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log (e.g. `fix: update entities encoding/decoding (fix #3899)`).
2321
- Provide a detailed description of the bug in the PR. Live demo preferred.
2422
- Add appropriate test coverage if applicable.

package.json

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"engines": {
66
"node": "^14.18.0 || >=16.0.0"
77
},
8-
"packageManager": "pnpm@10.12.4",
8+
"packageManager": "pnpm@10.13.1",
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.30.1",
36+
"@eslint/js": "^9.31.0",
3737
"@types/fs-extra": "^11.0.4",
38-
"@types/node": "^22.16.0",
38+
"@types/node": "^22.16.3",
3939
"@vitejs/release-scripts": "^1.6.0",
40-
"eslint": "^9.30.1",
40+
"eslint": "^9.31.0",
4141
"eslint-plugin-import-x": "^4.16.1",
4242
"eslint-plugin-n": "^17.21.0",
4343
"eslint-plugin-regexp": "^2.9.0",
4444
"fs-extra": "^11.3.0",
4545
"globals": "^16.3.0",
4646
"lint-staged": "^15.5.2",
4747
"picocolors": "^1.1.1",
48-
"playwright-chromium": "^1.53.2",
49-
"prettier": "^3.0.3",
48+
"playwright-chromium": "^1.54.1",
49+
"prettier": "^3.6.2",
5050
"simple-git-hooks": "^2.13.0",
5151
"tsx": "^4.20.3",
5252
"typescript": "^5.8.3",
53-
"typescript-eslint": "^8.35.1",
54-
"vite": "^7.0.2",
53+
"typescript-eslint": "^8.37.0",
54+
"vite": "^7.0.4",
5555
"vitest": "^3.2.4"
5656
},
5757
"simple-git-hooks": {
@@ -70,15 +70,5 @@
7070
"playground/**/__tests__/**/*.ts": [
7171
"eslint --cache --fix"
7272
]
73-
},
74-
"pnpm": {
75-
"packageExtensions": {
76-
"generouted": {
77-
"peerDependencies": {
78-
"react": "*",
79-
"react-router-dom": "*"
80-
}
81-
}
82-
}
8373
}
8474
}

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: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,28 @@
22

33
## Unreleased
44

5-
### Return `Plugin[]` instead of `PluginOption[]`
5+
## 0.3.0 (2025-07-18)
6+
7+
### Add HMR support for compound components ([#518](https://github.com/vitejs/vite-plugin-react/pull/518))
8+
9+
HMR now works for compound components like this:
10+
11+
```tsx
12+
const Root = () => <div>Accordion Root</div>
13+
const Item = () => <div>Accordion Item</div>
14+
15+
export const Accordion = { Root, Item }
16+
```
17+
18+
### Return `Plugin[]` instead of `PluginOption[]` ([#537](https://github.com/vitejs/vite-plugin-react/pull/537))
19+
20+
The return type has changed from `react(): PluginOption[]` to more specialized type `react(): Plugin[]`. This allows for type-safe manipulation of plugins, for example:
21+
22+
```tsx
23+
// previously this causes type errors
24+
react()
25+
.map(p => ({ ...p, applyToEnvironment: e => e.name === 'client' }))
26+
```
627

728
## 0.2.3 (2025-06-16)
829

packages/plugin-react-oxc/build.config.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/plugin-react-oxc/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vitejs/plugin-react-oxc",
3-
"version": "0.2.3",
3+
"version": "0.3.0",
44
"license": "MIT",
55
"author": "Evan You",
66
"contributors": [
@@ -20,11 +20,11 @@
2020
"dist"
2121
],
2222
"type": "module",
23-
"types": "./dist/index.d.mts",
24-
"exports": "./dist/index.mjs",
23+
"types": "./dist/index.d.ts",
24+
"exports": "./dist/index.js",
2525
"scripts": {
26-
"dev": "unbuild --stub",
27-
"build": "unbuild && tsx scripts/copyRefreshRuntime.ts",
26+
"dev": "tsdown --watch",
27+
"build": "tsdown",
2828
"prepublishOnly": "npm run build"
2929
},
3030
"engines": {
@@ -44,10 +44,11 @@
4444
},
4545
"devDependencies": {
4646
"@vitejs/react-common": "workspace:*",
47+
"tsdown": "^0.12.9",
4748
"unbuild": "^3.5.0",
4849
"vite": "catalog:rolldown-vite"
4950
},
5051
"dependencies": {
51-
"@rolldown/pluginutils": "1.0.0-beta.24"
52+
"@rolldown/pluginutils": "1.0.0-beta.27"
5253
}
5354
}

0 commit comments

Comments
 (0)