Skip to content

Commit 0318334

Browse files
hi-ogawasapphi-red
andauthored
feat: add @vitejs/plugin-rsc (#521)
Co-authored-by: 翠 <[email protected]>
1 parent 7196f66 commit 0318334

File tree

208 files changed

+13893
-50
lines changed

Some content is hidden

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

208 files changed

+13893
-50
lines changed

.github/workflows/ci-rsc.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: ci-rsc
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths:
8+
- "packages/plugin-rsc/**"
9+
- "pnpm-lock.yaml"
10+
- ".github/workflows/ci-rsc.yml"
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 22
24+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
25+
- run: pnpm i
26+
- run: pnpm build
27+
- run: pnpm -C packages/plugin-rsc tsc
28+
- run: pnpm -C packages/plugin-rsc test
29+
30+
test-e2e:
31+
name: test-rsc (${{ matrix.os }} / ${{ matrix.browser }})
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
# TODO: shard?
35+
matrix:
36+
os: [ubuntu-latest, macos-latest, windows-latest]
37+
browser: [chromium]
38+
include:
39+
- os: ubuntu-latest
40+
browser: firefox
41+
- os: macos-latest
42+
browser: webkit
43+
fail-fast: false
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-node@v4
47+
with:
48+
node-version: 22
49+
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
50+
- run: pnpm i
51+
- run: pnpm build
52+
- run: pnpm -C packages/plugin-rsc exec playwright install ${{ matrix.browser }}
53+
- run: pnpm -C packages/plugin-rsc test-e2e-ci --project=${{ matrix.browser }}
54+
env:
55+
TEST_ISOLATED: true
56+
- uses: actions/upload-artifact@v4
57+
if: always()
58+
with:
59+
name: test-results-${{ matrix.os }}-${{ matrix.browser }}
60+
path: |
61+
packages/plugin-rsc/test-results

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515

1616
See [`@vitejs/plugin-react` documentation](packages/plugin-react/README.md) and [`@vitejs/plugin-react-swc` documentation](packages/plugin-react-swc/README.md)
1717

18+
# Vite Plugin RSC
19+
20+
See [`@vitejs/plugin-rsc` documentation](packages/plugin-rsc/README.md)
21+
1822
## Packages
1923

2024
| Package | Version (click for changelogs) |
2125
| ----------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------- |
2226
| [@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) |
2327
| [@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) |
2428
| [@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) |
29+
| [@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) |
2530

2631
## License
2732

eslint.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import globals from 'globals'
99

1010
export default tseslint.config(
1111
{
12-
ignores: ['**/dist/**', '**/playground-temp/**', '**/temp/**'],
12+
ignores: [
13+
'**/dist/**',
14+
'**/playground-temp/**',
15+
'**/temp/**',
16+
'packages/plugin-rsc/**',
17+
],
1318
},
1419
eslint.configs.recommended,
1520
...tseslint.configs.recommended,

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@eslint/js": "^9.30.1",
3737
"@types/fs-extra": "^11.0.4",
3838
"@types/node": "^22.16.0",
39-
"@vitejs/release-scripts": "^1.5.0",
39+
"@vitejs/release-scripts": "^1.6.0",
4040
"eslint": "^9.30.1",
4141
"eslint-plugin-import-x": "^4.16.1",
4242
"eslint-plugin-n": "^17.20.0",
@@ -72,6 +72,9 @@
7272
]
7373
},
7474
"pnpm": {
75+
"overrides": {
76+
"@vitejs/plugin-rsc": "workspace:*"
77+
},
7578
"packageExtensions": {
7679
"generouted": {
7780
"peerDependencies": {

packages/plugin-rsc/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
node_modules
2+
dist
3+
.vercel
4+
.vite-node
5+
.wrangler
6+
.netlify
7+
*.log
8+
*.tgz
9+
test-results
10+
*.tsbuildinfo
11+
.debug
12+
.vite-inspect
13+
.claude

packages/plugin-rsc/CHANGELOG.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Changelog
2+
3+
## v0.4.10 (2025-07-04)
4+
5+
- feat: add `@vitejs/plugin-rsc` ([#521](https://github.com/vitejs/vite-plugin-react/pull/521))
6+
7+
---
8+
9+
Older versions were released as [`@hi-ogawa/vite-rsc`](https://github.com/hi-ogawa/vite-plugins/tree/main/packages/rsc).
10+
11+
## v0.4.9 (2025-07-03)
12+
13+
- feat: re-export plugin from base exports entry ([#1125](https://github.com/hi-ogawa/vite-plugins/pull/1125))
14+
- feat: re-export `transformHoistInlineDirective` ([#1122](https://github.com/hi-ogawa/vite-plugins/pull/1122))
15+
- fix: don't copy vite manifest from rsc to client ([#1118](https://github.com/hi-ogawa/vite-plugins/pull/1118))
16+
17+
## v0.4.8 (2025-07-01)
18+
19+
- fix: copy all server assets to client by default and output `__vite_rsc_encryption_key` to fs directly ([#1102](https://github.com/hi-ogawa/vite-plugins/pull/1102))
20+
- fix: stable client build ([#1094](https://github.com/hi-ogawa/vite-plugins/pull/1094))
21+
22+
## v0.4.7 (2025-06-28)
23+
24+
- feat: re-export `encodeReply` and `createTemporaryReferenceSet` from `react-server-dom/client` in `rsc` ([#1089](https://github.com/hi-ogawa/vite-plugins/pull/1089))
25+
- chore: add `use cache` example ([#1089](https://github.com/hi-ogawa/vite-plugins/pull/1089))
26+
- refactor: output code without indent ([#1087](https://github.com/hi-ogawa/vite-plugins/pull/1087))
27+
28+
## v0.4.6 (2025-06-27)
29+
30+
- fix: correctly resolve server function created by 3rd party package during dev ([#1067](https://github.com/hi-ogawa/vite-plugins/pull/1067))
31+
- fix: correctly resolve client boundary created by server package during dev ([#1050](https://github.com/hi-ogawa/vite-plugins/pull/1050))
32+
- fix: copy only css assets from server build to client build by default ([#1072](https://github.com/hi-ogawa/vite-plugins/pull/1072))
33+
- fix: fix single quote string in `loadModule('ssr', 'index')` ([#1064](https://github.com/hi-ogawa/vite-plugins/pull/1064))
34+
- fix: stabilize server build by externalizing encryption key file ([#1069](https://github.com/hi-ogawa/vite-plugins/pull/1069))
35+
- fix: check build instead of `import.meta.env.DEV` ([#1083](https://github.com/hi-ogawa/vite-plugins/pull/1083))
36+
- perf: strip code during scan build ([#1066](https://github.com/hi-ogawa/vite-plugins/pull/1066))
37+
- feat: support preserving client reference original value ([#1078](https://github.com/hi-ogawa/vite-plugins/pull/1078))
38+
- feat: add `enableActionEncryption` option for debugging purpose ([#1084](https://github.com/hi-ogawa/vite-plugins/pull/1084))
39+
- feat: add `ignoredClientInServerPackageWarning` option ([#1065](https://github.com/hi-ogawa/vite-plugins/pull/1065))
40+
41+
## v0.4.5 (2025-06-22)
42+
43+
- feat: rsc css transform for default export identifier ([#1046](https://github.com/hi-ogawa/vite-plugins/pull/1046))
44+
- feat: add `import.meta.viteRsc.loadBootstrapScriptContent` ([#1042](https://github.com/hi-ogawa/vite-plugins/pull/1042))
45+
- fix: only include jsx/tsx for rsc css export transform ([#1034](https://github.com/hi-ogawa/vite-plugins/pull/1034))
46+
- fix: ensure server-only and client-only not externalized ([#1045](https://github.com/hi-ogawa/vite-plugins/pull/1045))
47+
- fix: use static import for `loadCss` virtuals during build ([#1043](https://github.com/hi-ogawa/vite-plugins/pull/1043))
48+
49+
## v0.4.4 (2025-06-20)
50+
51+
- feat: automatic rsc css export transform ([#1030](https://github.com/hi-ogawa/vite-plugins/pull/1030))
52+
- feat: add plugin to workaround cloudflare error ([#1014](https://github.com/hi-ogawa/vite-plugins/pull/1014))
53+
- feat: add load module dev proxy ([#1012](https://github.com/hi-ogawa/vite-plugins/pull/1012))
54+
- feat: add `serverHandler` option to allow using ssr environment as main handler ([#1008](https://github.com/hi-ogawa/vite-plugins/pull/1008))
55+
- feat: support `loadModule(environment, entry)` ([#1007](https://github.com/hi-ogawa/vite-plugins/pull/1007))
56+
- refactor: tweak renderHtml types and naming ([#1029](https://github.com/hi-ogawa/vite-plugins/pull/1029))
57+
58+
## v0.4.3 (2025-06-18)
59+
60+
- feat: add rsc css export transform helper ([#1002](https://github.com/hi-ogawa/vite-plugins/pull/1002))
61+
- feat: support `loadCss(importer)` ([#1001](https://github.com/hi-ogawa/vite-plugins/pull/1001))
62+
63+
## v0.4.2 (2025-06-17)
64+
65+
- fix: allow custom `outDir` + chore: cloudflare single worker setup ([#990](https://github.com/hi-ogawa/vite-plugins/pull/990))
66+
- fix: transform `__webpack_require__` global ([#980](https://github.com/hi-ogawa/vite-plugins/pull/980))
67+
- fix: inline and optimize react deps in ssr environment ([#982](https://github.com/hi-ogawa/vite-plugins/pull/982))
68+
- refactor: resolve self runtime import instead of `dedupe` ([#975](https://github.com/hi-ogawa/vite-plugins/pull/975))
69+
- refactor: emit assets manifest during `writeBundle` ([#972](https://github.com/hi-ogawa/vite-plugins/pull/972))
70+
- refactor: use `../` instead of `./../` path in output ([#963](https://github.com/hi-ogawa/vite-plugins/pull/963))
71+
72+
## v0.4.1 (2025-06-15)
73+
74+
- fix: re-publish to fix vendored dependency
75+
76+
## v0.4.0 (2025-06-15)
77+
78+
- refactor!: rework multi environment API (bootstrap script) ([#958](https://github.com/hi-ogawa/vite-plugins/pull/958))
79+
- refactor!: rework multi environment API (ssr module) ([#957](https://github.com/hi-ogawa/vite-plugins/pull/957))
80+
- refactor!: simplify plugin options in favor of `rollupOptions.input` ([#956](https://github.com/hi-ogawa/vite-plugins/pull/956))
81+
- feat: expose `rsc-html-stream` utils ([#950](https://github.com/hi-ogawa/vite-plugins/pull/950))
82+
- fix: fix missing rsc css on build ([#949](https://github.com/hi-ogawa/vite-plugins/pull/949))
83+
84+
## v0.3.4 (2025-06-12)
85+
86+
- fix: fix internal import to allow stable react vendor chunk ([#824](https://github.com/hi-ogawa/vite-plugins/pull/824))
87+
- fix: compat for old react plugin ([#939](https://github.com/hi-ogawa/vite-plugins/pull/939))
88+
89+
## v0.3.3 (2025-06-12)
90+
91+
- feat: support rolldown-vite ([#931](https://github.com/hi-ogawa/vite-plugins/pull/931))
92+
- fix: allow usage without react plugin ([#934](https://github.com/hi-ogawa/vite-plugins/pull/934))
93+
- chore: docs ([#921](https://github.com/hi-ogawa/vite-plugins/pull/921))
94+
95+
## v0.3.2 (2025-06-10)
96+
97+
- feat: auto initialize ([#925](https://github.com/hi-ogawa/vite-plugins/pull/925))
98+
- fix: emit assets manifest only in server build ([#929](https://github.com/hi-ogawa/vite-plugins/pull/929))
99+
- refactor: inline react-server-dom in ssr (2) ([#927](https://github.com/hi-ogawa/vite-plugins/pull/927))
100+
- chore: add `@cloudflare/vite-plugin` example ([#926](https://github.com/hi-ogawa/vite-plugins/pull/926))
101+
102+
## v0.3.1 (2025-06-06)
103+
104+
- refactor: vendor react-server-dom ([#854](https://github.com/hi-ogawa/vite-plugins/pull/854))
105+
106+
## v0.3.0 (2025-06-05)
107+
108+
- feat!: rsc css code split ([#876](https://github.com/hi-ogawa/vite-plugins/pull/876))
109+
- feat: encrypt closure bind values ([#897](https://github.com/hi-ogawa/vite-plugins/pull/897))
110+
- fix: client element as bound arg encryption ([#905](https://github.com/hi-ogawa/vite-plugins/pull/905))
111+
- fix: throw on client reference call on server ([#900](https://github.com/hi-ogawa/vite-plugins/pull/900))
112+
113+
## v0.2.4 (2025-05-26)
114+
115+
- fix: fix stale css import in non-boundary client module ([#887](https://github.com/hi-ogawa/vite-plugins/pull/887))
116+
- fix: fix non-client-boundary client module hmr in tailwind example ([#886](https://github.com/hi-ogawa/vite-plugins/pull/886))
117+
118+
## v0.2.3 (2025-05-22)
119+
120+
- fix: support Windows ([#884](https://github.com/hi-ogawa/vite-plugins/pull/884))
121+
- fix: remove stale ssr styles during dev ([#879](https://github.com/hi-ogawa/vite-plugins/pull/879))
122+
- fix: add `vary` header to avoid rsc payload on tab re-open ([#877](https://github.com/hi-ogawa/vite-plugins/pull/877))
123+
124+
## v0.2.2 (2025-05-18)
125+
126+
- fix: emit server assets and copy to client ([#861](https://github.com/hi-ogawa/vite-plugins/pull/861))
127+
- fix: css modules hmr ([#860](https://github.com/hi-ogawa/vite-plugins/pull/860))
128+
- fix: fix `collectCssByUrl` error ([#856](https://github.com/hi-ogawa/vite-plugins/pull/856))
129+
- fix: show invalid transform error with code frame ([#871](https://github.com/hi-ogawa/vite-plugins/pull/871))
130+
- perf: preload client reference deps before non-cached import ([#850](https://github.com/hi-ogawa/vite-plugins/pull/850))
131+
132+
## v0.2.1 (2025-05-13)
133+
134+
- feat: automatic client package heuristics ([#830](https://github.com/hi-ogawa/vite-plugins/pull/830))
135+
- fix: add browser entry to `optimizeDeps.entries` ([#846](https://github.com/hi-ogawa/vite-plugins/pull/846))
136+
- fix: resolve self package from project root ([#845](https://github.com/hi-ogawa/vite-plugins/pull/845))
137+
- refactor: use `rsc-html-stream` ([#843](https://github.com/hi-ogawa/vite-plugins/pull/843))
138+
139+
## v0.2.0 (2025-05-12)
140+
141+
- feat: apply tree-shaking to all client references (2nd approach) ([#838](https://github.com/hi-ogawa/vite-plugins/pull/838))
142+
- feat: support nonce ([#813](https://github.com/hi-ogawa/vite-plugins/pull/813))
143+
- feat: support css in rsc environment ([#825](https://github.com/hi-ogawa/vite-plugins/pull/825))
144+
- feat: support css in client references ([#823](https://github.com/hi-ogawa/vite-plugins/pull/823))
145+
- fix: handle html escape and binary data in ssr rsc payload ([#839](https://github.com/hi-ogawa/vite-plugins/pull/839))
146+
- fix: wrap virtual to workaround module runner entry issues ([#832](https://github.com/hi-ogawa/vite-plugins/pull/832))
147+
- fix: scan build in two environments ([#820](https://github.com/hi-ogawa/vite-plugins/pull/820))
148+
- refactor: simplify client reference mapping ([#836](https://github.com/hi-ogawa/vite-plugins/pull/836))
149+
- refactor!: remove `entries.css` ([#831](https://github.com/hi-ogawa/vite-plugins/pull/831))
150+
- refactor: client reference ssr preinit/preload via proxy and remove `prepareDestination` ([#828](https://github.com/hi-ogawa/vite-plugins/pull/828))
151+
- refactor: tweak asset links api ([#826](https://github.com/hi-ogawa/vite-plugins/pull/826))
152+
153+
## v0.1.1 (2025-05-07)
154+
155+
- fix: statically import client references virtual ([#815](https://github.com/hi-ogawa/vite-plugins/pull/815))
156+
- fix: fix base for findSourceMapURL ([#812](https://github.com/hi-ogawa/vite-plugins/pull/812))
157+
- fix: fix module runner line offset in `findSourceMapURL` ([#810](https://github.com/hi-ogawa/vite-plugins/pull/810))
158+
159+
## v0.1.0 (2025-05-01)
160+
161+
- feat: support `findSourceMapURL` for `createServerReference` ([#796](https://github.com/hi-ogawa/vite-plugins/pull/796))
162+
- feat: support `findSourceMapURL` for component stack and replay logs ([#779](https://github.com/hi-ogawa/vite-plugins/pull/779))
163+
- feat: support temporary references ([#776](https://github.com/hi-ogawa/vite-plugins/pull/776))
164+
- feat: support custom base ([#775](https://github.com/hi-ogawa/vite-plugins/pull/775))
165+
- feat: refactor assets manifest and expose it to rsc build ([#767](https://github.com/hi-ogawa/vite-plugins/pull/767))
166+
- feat: ssr modulepreload only for build ([#763](https://github.com/hi-ogawa/vite-plugins/pull/763))
167+
- feat: tree shake unused reference exports ([#761](https://github.com/hi-ogawa/vite-plugins/pull/761))
168+
- feat: re-export react-server-dom ([#744](https://github.com/hi-ogawa/vite-plugins/pull/744))
169+
- feat: support css entry ([#737](https://github.com/hi-ogawa/vite-plugins/pull/737))
170+
- feat wrap client packages in virtual (support `clientPackages` options) ([#718](https://github.com/hi-ogawa/vite-plugins/pull/718))
171+
- feat: modulepreload client reference on ssr ([#703](https://github.com/hi-ogawa/vite-plugins/pull/703))
172+
- feat: create vite-rsc ([#692](https://github.com/hi-ogawa/vite-plugins/pull/692))

0 commit comments

Comments
 (0)