Skip to content
Draft
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
21 changes: 19 additions & 2 deletions packages/plugin-rsc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { transformScanBuildStrip } from './plugins/scan'
import { validateImportPlugin } from './plugins/validate-import'
import { vitePluginFindSourceMapURL } from './plugins/find-source-map-url'
import { parseCssVirtual, toCssVirtual, parseIdQuery } from './plugins/shared'
import type { RscModuleInfoMeta } from './types'

const isRolldownVite = 'rolldownVersion' in vite

Expand Down Expand Up @@ -1130,7 +1131,15 @@ function vitePluginUseClient(
}
const importSource = resolvePackage(`${PKG_NAME}/react/rsc`)
output.prepend(`import * as $$ReactServer from "${importSource}";\n`)
return { code: output.toString(), map: { mappings: '' } }
return {
code: output.toString(),
map: { mappings: '' },
meta: {
rsc: {
type: 'client',
},
} satisfies RscModuleInfoMeta,
}
},
},
{
Expand Down Expand Up @@ -1207,7 +1216,15 @@ function vitePluginUseClient(
export const export_${meta.referenceKey} = {${exports}};
`
}
return { code, map: null }
return {
code,
map: null,
meta: {
rsc: {
type: 'client-group',
},
} satisfies RscModuleInfoMeta,
}
}
},
},
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-rsc/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ export interface ServerConsumerManifest {
}

export type CallServerCallback = (id: string, args: unknown[]) => unknown

export type RscModuleInfoMeta = {
rsc: {
type: 'client' | 'client-group'
}
}
Loading