Skip to content

feat: add react-server-dom-vite #33152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2fb60b4
feat: add react-server-dom-vite
hi-ogawa Apr 24, 2025
669db2d
chore(deps): update rsc-html-stream for nonce
hi-ogawa May 10, 2025
decd526
refactor: move prepare destination to userland
hi-ogawa May 10, 2025
f2c1f9b
feat: support css
hi-ogawa May 10, 2025
b4e09cc
fix: fix nonce
hi-ogawa May 10, 2025
cbcdfb7
chore: remove unused preloadModuleForSSR
hi-ogawa May 10, 2025
3fcc54b
chore: add client side navigation in fixture
hi-ogawa May 10, 2025
034f737
chore: simplify nonce handling
hi-ogawa May 10, 2025
fc4c5af
refactor: remove `prepareDestination` in favor of `wrapResourceProxy`
hi-ogawa May 10, 2025
04b9e61
chore: cleanup
hi-ogawa May 19, 2025
20560ab
Merge branch 'main' into feat-rsc-vite
hi-ogawa Jun 3, 2025
24c6341
chore: update deps
hi-ogawa Jun 3, 2025
148fd02
fix: support server seriailization
hi-ogawa Jun 3, 2025
be8444e
chore: prettier
hi-ogawa Jun 4, 2025
998224f
refactor: simplify serverConsumerManifest
hi-ogawa Jun 4, 2025
a4d4d32
chore: cleanup
hi-ogawa Jun 4, 2025
472fc43
test: tweak
hi-ogawa Jun 4, 2025
de05ee8
refactor: expose clientManifest and serverManifest via API (wip)
hi-ogawa Jun 4, 2025
a55f46f
refactor: replace setPreloadModule with clientManifest/serverManifest…
hi-ogawa Jun 4, 2025
35fff65
refactor: remove setPreloadModule
hi-ogawa Jun 4, 2025
d38a338
chore: fix flow
hi-ogawa Jun 4, 2025
3f1f41d
test: support custom base
hi-ogawa Jun 4, 2025
a550f87
test: refactor custom base
hi-ogawa Jun 4, 2025
da299d1
chore: lint
hi-ogawa Jun 4, 2025
900f916
feat: allow resolveClientReferenceMetadata remapping like webpack
hi-ogawa Jun 4, 2025
b5f8837
chore: tweak script
hi-ogawa Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ module.exports = {
'packages/react-server-dom-webpack/**/*.js',
'packages/react-server-dom-turbopack/**/*.js',
'packages/react-server-dom-parcel/**/*.js',
'packages/react-server-dom-vite/**/*.js',
'packages/react-server-dom-fb/**/*.js',
'packages/react-test-renderer/**/*.js',
'packages/react-debug-tools/**/*.js',
Expand Down Expand Up @@ -484,6 +485,9 @@ module.exports = {
parcelRequire: 'readonly',
},
},
{
files: ['packages/react-server-dom-vite/**/*.js'],
},
{
files: ['packages/scheduler/**/*.js'],
globals: {
Expand Down
1 change: 1 addition & 0 deletions ReactVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const stablePackages = {
'react-server-dom-webpack': ReactVersion,
'react-server-dom-turbopack': ReactVersion,
'react-server-dom-parcel': ReactVersion,
'react-server-dom-vite': ReactVersion,
'react-is': ReactVersion,
'react-reconciler': '0.33.0',
'react-refresh': '0.18.0',
Expand Down
3 changes: 3 additions & 0 deletions fixtures/flight-vite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
test-results
tsconfig.tsbuildinfo
28 changes: 28 additions & 0 deletions fixtures/flight-vite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# flight-vite

Basic RSC app ported from [`@hiogawa/vite-rsc`](https://github.com/hi-ogawa/vite-plugins/tree/main/packages/rsc),
which was made on top of `react-server-dom-webpack`.

## Code structure

- `basic/{browser,ssr,rsc,plugin}.ts`
- baseline "framework-less" Vite plugin and runtime helpers
- `vite.config.ts`, `src`
- RSC framework/application consuming `react-server-dom-vite` APIs and `basic` plugin/runtime

## How to test

```sh
# setup
yarn build-dep
yarn

# development
yarn dev --force
yarn test-e2e

# production
yarn build
yarn preview
yarn test-e2e-preview
```
1 change: 1 addition & 0 deletions fixtures/flight-vite/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Baseline plugins and runtime helpers based on https://github.com/hi-ogawa/vite-plugins/tree/main/packages/rsc
31 changes: 31 additions & 0 deletions fixtures/flight-vite/basic/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @ts-ignore
import clientReferences from 'virtual:vite-rsc/client-references';

export const clientManifest = {load: loadModule};

function loadModule(id: string) {
if (import.meta.env.DEV) {
// @ts-ignore
return __vite_rsc_raw_import__(
/* @vite-ignore */ import.meta.env.BASE_URL + id.slice(1),
);
} else {
return clientReferences[id]();
}
}

export function findSourceMapURL(filename: string, environmentName: string) {
if (!import.meta.env.DEV) return null;
const url = new URL('/__vite_rsc_source_map', window.location.origin);
url.searchParams.set('filename', filename);
url.searchParams.set('environmentName', environmentName);
return url.toString();
}

export const callServer = (...args: any[]) => callServer_(...args);

let callServer_: any;

export function setCallServer(fn: any) {
callServer_ = fn;
}
Loading