Skip to content
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

RSC: Random vite package cleanup and tweaks #10239

Merged
merged 2 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const checkStatus = async (

const BASE_PATH = '/rw-rsc/'

export function renderFromRscServer<Props>(rscId: string) {
export function renderFromRscServer<TProps>(rscId: string) {
console.log('serve rscId', rscId)

// Temporarily skip rendering this component during SSR
Expand Down Expand Up @@ -58,6 +58,7 @@ export function renderFromRscServer<Props>(rscId: string) {
// and that element will be FormData
callServer: async function (rsfId: string, args: unknown[]) {
console.log('client.ts :: callServer rsfId', rsfId, 'args', args)

const isMutating = !!mutationMode
const searchParams = new URLSearchParams()
searchParams.set('action_id', rsfId)
Expand Down Expand Up @@ -113,7 +114,7 @@ export function renderFromRscServer<Props>(rscId: string) {

// Create temporary client component that wraps the ServerComponent returned
// by the `createFromFetch` call.
const ServerComponent = (props: Props) => {
const ServerComponent = (props: TProps) => {
console.log('ServerComponent', rscId, 'props', props)

// FIXME we blindly expect JSON.stringify usage is deterministic
Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/rsc/rscBuildForServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// import path from 'node:path'

import { build as viteBuild } from 'vite'

import { getPaths } from '@redwoodjs/project-config'
Expand Down
2 changes: 2 additions & 0 deletions packages/vite/src/rsc/rscWebpackShims.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
export const rscWebpackShims = `globalThis.__rw_module_cache__ = new Map();

globalThis.__webpack_chunk_load__ = (id) => {
console.log('rscWebpackShims chunk load id', id)
return import(id).then((m) => globalThis.__rw_module_cache__.set(id, m))
};

globalThis.__webpack_require__ = (id) => {
console.log('rscWebpackShims require id', id)
return globalThis.__rw_module_cache__.get(id)
};\n`
Loading