diff --git a/packages/cli/src/commands/experimental/templates/rsc/entries.ts.template b/packages/cli/src/commands/experimental/templates/rsc/entries.ts.template index bd03abc6d606..f6fc2a9a6d58 100644 --- a/packages/cli/src/commands/experimental/templates/rsc/entries.ts.template +++ b/packages/cli/src/commands/experimental/templates/rsc/entries.ts.template @@ -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 diff --git a/packages/vite/package.json b/packages/vite/package.json index 38fc30a5fa1d..b457dad1a822 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -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" diff --git a/packages/vite/src/waku-server.ts b/packages/vite/src/entries.ts similarity index 71% rename from packages/vite/src/waku-server.ts rename to packages/vite/src/entries.ts index eb6079e2b63d..b0195d10253b 100644 --- a/packages/vite/src/waku-server.ts +++ b/packages/vite/src/entries.ts @@ -5,7 +5,8 @@ export type GetEntry = ( ) => Promise 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]: { @@ -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 } } diff --git a/packages/vite/src/waku-lib/rsc-handler-worker.ts b/packages/vite/src/waku-lib/rsc-handler-worker.ts index fff2308b6cb1..960c7cbd57d4 100644 --- a/packages/vite/src/waku-lib/rsc-handler-worker.ts +++ b/packages/vite/src/waku-lib/rsc-handler-worker.ts @@ -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'