Skip to content

Commit f5fc2e2

Browse files
authored
RSC: Use exported defineEntries() (#8886)
1 parent c1e62c2 commit f5fc2e2

4 files changed

Lines changed: 12 additions & 21 deletions

File tree

packages/cli/src/commands/experimental/templates/rsc/entries.ts.template

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
export type GetEntry = (rscId: string) => Promise<
2-
| React.FunctionComponent
3-
| {
4-
default: React.FunctionComponent
5-
}
6-
| null
7-
>
8-
9-
export function defineEntries(getEntry: GetEntry) {
10-
return {
11-
getEntry,
12-
}
13-
}
1+
import { defineEntries } from '@redwoodjs/vite/entries'
142

153
export default defineEntries(
164
// getEntry

packages/vite/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
"types": "./dist/index.d.ts",
1919
"default": "./dist/index.js"
2020
},
21+
"./entries": {
22+
"types": "./dist/entries.d.ts",
23+
"default": "./dist/entries.js"
24+
},
2125
"./client": {
2226
"types": "./dist/client.d.ts",
2327
"default": "./dist/client.js"
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export type GetEntry = (
55
) => Promise<FunctionComponent | { default: FunctionComponent } | null>
66

77
export type GetBuilder = (
8-
// FIXME can we somehow avoid leaking internal implementation?
8+
// FIXME (from original waku code) can we somehow avoid leaking internal
9+
// implementation?
910
unstable_decodeId: (encodedId: string) => [id: string, name: string]
1011
) => Promise<{
1112
[pathStr: string]: {
@@ -16,12 +17,10 @@ export type GetBuilder = (
1617
}
1718
}>
1819

19-
// This is for ignored dynamic imports
20-
// XXX Are there any better ways?
21-
export type unstable_GetCustomModules = () => Promise<{
22-
[name: string]: string
23-
}>
24-
20+
/**
21+
* Used to look up the component to import when calling `serve('App')` in
22+
* entry.client.tsx
23+
*/
2524
export function defineEntries(getEntry: GetEntry, getBuilder?: GetBuilder) {
2625
return { getEntry, getBuilder }
2726
}

packages/vite/src/waku-lib/rsc-handler-worker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createServer } from 'vite'
1111

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

14-
import { defineEntries } from '../waku-server'
14+
import { defineEntries } from '../entries'
1515
// import type { unstable_GetCustomModules } from '../waku-server'
1616

1717
import { configFileConfig, resolveConfig } from './config'

0 commit comments

Comments
 (0)