-
Notifications
You must be signed in to change notification settings - Fork 365
perf(app): use @vitejs/plugin-rsc/rsc/* entries
#2677
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -289,17 +289,12 @@ import { | |||||||||||||||||||||||
| createTemporaryReferenceSet,` | ||||||||||||||||||||||||
| : "" | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } from ${JSON.stringify( | ||||||||||||||||||||||||
| hasServerActions ? "@vitejs/plugin-rsc/rsc" : "@vitejs/plugin-rsc/react/rsc", | ||||||||||||||||||||||||
| )}; | ||||||||||||||||||||||||
| import { createClientManifest as _createClientManifest } from "@vitejs/plugin-rsc/core/rsc"; | ||||||||||||||||||||||||
| import { prerender as _prerender } from "@vitejs/plugin-rsc/vendor/react-server-dom/static.edge"; | ||||||||||||||||||||||||
| } from "@vitejs/plugin-rsc/rsc/server"; | ||||||||||||||||||||||||
| import { prerender as _prerender } from "@vitejs/plugin-rsc/rsc/static"; | ||||||||||||||||||||||||
|
Comment on lines
+292
to
+293
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hasServerActions ? "@vitejs/plugin-rsc/rsc" : "@vitejs/plugin-rsc/react/rsc"This vinext/packages/vinext/src/entries/app-rsc-entry.ts Lines 281 to 291 in f91363f
So this has been consolidated to just |
||||||||||||||||||||||||
| import { createRscPrerenderer, createRscRenderer } from ${JSON.stringify(rscStreamHintsPath)}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const renderToReadableStream = createRscRenderer(_renderToReadableStream); | ||||||||||||||||||||||||
| const prerenderToReadableStream = createRscPrerenderer(async (model, options) => | ||||||||||||||||||||||||
| _prerender(model, _createClientManifest(), options), | ||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
| const prerenderToReadableStream = createRscPrerenderer(_prerender); | ||||||||||||||||||||||||
| import { createElement } from "react"; | ||||||||||||||||||||||||
| import { getNavigationContext as _getNavigationContext } from "next/navigation"; | ||||||||||||||||||||||||
| import { configureMemoryCacheHandler as __configureMemoryCacheHandler } from "vinext/shims/cache-handler"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,7 +167,7 @@ export function getCacheContext(): CacheContext | null { | |
| // --------------------------------------------------------------------------- | ||
|
|
||
| /** | ||
| * RSC serialization APIs from @vitejs/plugin-rsc/react/rsc. | ||
| * RSC serialization APIs from @vitejs/plugin-rsc/rsc/server and /rsc/client. | ||
| * Lazily loaded because these are only available in the Vite RSC environment | ||
| * (they depend on virtual modules set up by @vitejs/plugin-rsc). | ||
| * In test environments, the import fails and we fall back to JSON. | ||
|
|
@@ -232,7 +232,11 @@ let _rscModule: RscModule | null | typeof NOT_LOADED = NOT_LOADED; | |
| async function getRscModule(): Promise<RscModule | null> { | ||
| if (_rscModule !== NOT_LOADED) return _rscModule; | ||
| try { | ||
| _rscModule = (await import("@vitejs/plugin-rsc/react/rsc")) as RscModule; | ||
| const [server, client] = await Promise.all([ | ||
| import("@vitejs/plugin-rsc/rsc/server"), | ||
| import("@vitejs/plugin-rsc/rsc/client"), | ||
| ]); | ||
|
Comment on lines
+235
to
+238
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like using I think ideally page router only mode can entirely nullifying
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Attempting to remove "cache-runtime" import from pages router ssr entry 95d9862. The existing test appears to be asserting internal request context, which has no user facing pages router feature, so it's adjusted accordingly. |
||
| _rscModule = { ...server, ...client } as RscModule; | ||
| } catch { | ||
| _rscModule = null; | ||
| } | ||
|
|
||
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if peer dep bump should be breaking change. From the past commit history, there doesn't seem to be strict policy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other times i've switched to new Vite related functionality, i've left the old behaviour behind a version check to avoid breaking changes. Will probably have to see if the same thing can be done for this too. I can have a look at that no worries