Skip to content

Commit 4585faa

Browse files
hi-ogawadai-shi
andauthored
perf: merge client chunks based on server page usage (#1653)
This PR enables client reference chunk optimization implemented by vitejs/vite-plugin-react#766 and vitejs/vite-plugin-react#767. I will likely enables this by default in next release, but testing on Waku for starter. The idea is similar to the one explained in https://devongovett.me/blog/parcel-rsc.html "Bundling client components" section. > One interesting thing you might notice is that "use client" is not an explicit code splitting point like dynamic import(). If you import more than one client component from a server component, the client components will be grouped together into a single bundle instead of split into separate bundles. This difference can be seen in `packages/website` where previously each `"use client"` component file becoming its own chunk e.g. https://waku.gg/ - `Destination` -> `/assets/destination-xxx.js` - `Start` -> `/assets/start-xxx.js` - `Fade` -> `/assets/fade-xxx.js` - `Menu` -> `/assets/menu-xxx.js` - `Navigation` -> ... - `Scroll` -> ... - etc. but now, some client component chunks are merged together based on server-side usage, e.g. https://waku-git-fork-hi-ogawa-08-24-featoptimi-f784e4-daishis-projects.vercel.app/ - `Destination`, `Start` -> `/assets/index-xxx.js` (only used in `/`) - `Fade`, `Menu`, `Navigation`, `Scroll` -> `/assets/fade-xxx.js` (shared by all pages `/`, `/blog`, ...) - etc. --------- Co-authored-by: Daishi Kato <[email protected]>
1 parent 1df4226 commit 4585faa

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

packages/waku/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"@hono/node-server": "1.19.0",
8282
"@swc/core": "1.13.4",
8383
"@vitejs/plugin-react": "5.0.1",
84-
"@vitejs/plugin-rsc": "0.4.22",
84+
"@vitejs/plugin-rsc": "0.4.25",
8585
"dotenv": "17.2.1",
8686
"hono": "4.9.4",
8787
"rsc-html-stream": "0.0.7",

packages/waku/src/lib/vite-rsc/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export function rscPlugin(rscPluginOptions?: RscPluginOptions): PluginOption {
9696
keepUseCientProxy: true,
9797
ignoredPackageWarnings: [/.*/],
9898
useBuildAppHook: true,
99+
clientChunks: (meta) => meta.serverChunk,
99100
}),
100101
{
101102
name: 'rsc:waku',

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)