Skip to content

Commit

Permalink
RSC: Use exported defineEntries() (#8886)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored Jul 12, 2023
1 parent c1e62c2 commit f5fc2e2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
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

0 comments on commit f5fc2e2

Please sign in to comment.