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: Use exported defineEntries() #8886

Merged
merged 2 commits into from
Jul 12, 2023
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
export type GetEntry = (rscId: string) => Promise<
| React.FunctionComponent
| {
default: React.FunctionComponent
}
| null
>

export function defineEntries(getEntry: GetEntry) {
return {
getEntry,
}
}
import { defineEntries } from '@redwoodjs/vite/entries'

export default defineEntries(
// getEntry
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./entries": {
"types": "./dist/entries.d.ts",
"default": "./dist/entries.js"
},
"./client": {
"types": "./dist/client.d.ts",
"default": "./dist/client.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export type GetEntry = (
) => Promise<FunctionComponent | { default: FunctionComponent } | null>

export type GetBuilder = (
// FIXME can we somehow avoid leaking internal implementation?
// FIXME (from original waku code) can we somehow avoid leaking internal
// implementation?
unstable_decodeId: (encodedId: string) => [id: string, name: string]
) => Promise<{
[pathStr: string]: {
Expand All @@ -16,12 +17,10 @@ export type GetBuilder = (
}
}>

// This is for ignored dynamic imports
// XXX Are there any better ways?
export type unstable_GetCustomModules = () => Promise<{
[name: string]: string
}>

/**
* Used to look up the component to import when calling `serve('App')` in
* entry.client.tsx
*/
export function defineEntries(getEntry: GetEntry, getBuilder?: GetBuilder) {
return { getEntry, getBuilder }
}
2 changes: 1 addition & 1 deletion packages/vite/src/waku-lib/rsc-handler-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createServer } from 'vite'

import { getPaths } from '@redwoodjs/project-config'

import { defineEntries } from '../waku-server'
import { defineEntries } from '../entries'
// import type { unstable_GetCustomModules } from '../waku-server'

import { configFileConfig, resolveConfig } from './config'
Expand Down