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

feat(rsc-streaming): Integrating RSC builds with Streaming and Client side hydration #10031

Merged
merged 106 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
e5f7606
just adding some comments for my understanding
dac09 Feb 14, 2024
b7870ee
Add some TODOS
dac09 Feb 14, 2024
a6809a9
Combine builds - rename some functions
dac09 Feb 15, 2024
3147a63
[Paths] Update paths to build into separate client, server and rsc fo…
dac09 Feb 15, 2024
391a145
Rename rscBuildServer -> rscBuildForWorker
dac09 Feb 15, 2024
c43d08a
WIP: getDefines
dac09 Feb 15, 2024
86a4e41
Re-enable routes autoloader
dac09 Feb 16, 2024
979bdd8
Build manifest log
dac09 Feb 16, 2024
a59b10c
Remove viteclient.serve from fixtures and template for RSC
dac09 Feb 16, 2024
fbc3384
Merge branch 'main' of github.com:redwoodjs/redwood into feat/rsc-build
dac09 Feb 16, 2024
b283f05
Serve all static files in the dist.client folder
dac09 Feb 16, 2024
1a882dd
Merge branch 'main' of github.com:redwoodjs/redwood into feat/rsc-build
dac09 Feb 19, 2024
93a3e68
Remove console logs
dac09 Feb 19, 2024
ec3925b
Rename server -> renderFromRscServer
dac09 Feb 19, 2024
fcd596f
Merge branch 'main' of github.com:redwoodjs/redwood into feat/rsc-build
dac09 Feb 19, 2024
5e767b2
Remove index.html requirement
dac09 Feb 19, 2024
7ff0461
Merge branch 'main' into feat/rsc-build
dac09 Feb 19, 2024
310f8eb
Only change client path when ssr or rsc enabled
dac09 Feb 20, 2024
68e6244
Merge branch 'feat/rsc-build' of github.com:dac09/redwood into feat/r…
dac09 Feb 20, 2024
dcade00
FIx entry lookup in fe server
dac09 Feb 20, 2024
29250e0
Add apollo dependency to RSC fixture
dac09 Feb 20, 2024
238e2a5
Merge branch 'main' into feat/rsc-build
dac09 Feb 20, 2024
def1dd9
Unhardcode new paths, add it to rwPaths package
dac09 Feb 20, 2024
ce81604
Merge branch 'feat/rsc-build' of github.com:dac09/redwood into feat/r…
dac09 Feb 20, 2024
43117fa
Merge branch 'main' into feat/rsc-build
Tobbe Feb 23, 2024
46f9499
Apply suggestions from code review
Tobbe Feb 23, 2024
051decf
Tobbe review changes
Tobbe Feb 23, 2024
cc4024e
Rename build functions
dac09 Feb 23, 2024
5a7c550
Fix paths test with new paths
dac09 Feb 23, 2024
9be7278
Another rename of build functions
dac09 Feb 23, 2024
274955d
Lint
dac09 Feb 23, 2024
8cb6645
Remove duplicated file
dac09 Feb 23, 2024
81ddb6e
Update some more comments
dac09 Feb 23, 2024
ffca103
Code comment tweaks/fixes
Tobbe Feb 23, 2024
d624776
Remove `serve` from test fixture
Tobbe Feb 23, 2024
246e045
node-loader should look in distRsc now, not distServer
Tobbe Feb 23, 2024
c4b42ab
doc comment formatting
Tobbe Feb 23, 2024
e81d557
innerText
Tobbe Feb 24, 2024
924d771
no more 'as string', and startsWith instead of includes
Tobbe Feb 24, 2024
229fe35
Remove outdated todo comment. And other comment formatting
Tobbe Feb 24, 2024
c4f59bc
Revert startsWith change
Tobbe Feb 24, 2024
a000c38
Merge branch 'main' into feat/rsc-build
dac09 Feb 24, 2024
4e29a13
@tobbe.dev/rsc-test@0.0.4
Tobbe Feb 25, 2024
881edb6
@tobbe.dev/rsc-test@0.0.5
Tobbe Feb 25, 2024
87d0daf
Merge branch 'main' into feat/rsc-build
dac09 Feb 27, 2024
142f0b7
Update setupRscExternal readme
dac09 Feb 27, 2024
4bf3b03
Merge branch 'main' into feat/rsc-build
Tobbe Feb 27, 2024
ec6497d
emptyOutDir
Tobbe Feb 28, 2024
25b7ede
Consolidate vite settings for rsc build (#262)
dac09 Feb 28, 2024
374ac5e
Allow mjs entry server and document. As string is OK
dac09 Feb 28, 2024
f88424e
Empty outdir for ssr build
dac09 Feb 28, 2024
bb05d58
Silence rscBuildAnalyze
dac09 Feb 28, 2024
92e13bf
Move react plugin into their individual files
dac09 Feb 29, 2024
e717397
Ok
dac09 Feb 29, 2024
a9c2f6b
Merge branch 'main' of github.com:redwoodjs/redwood into feat/rsc-build
dac09 Feb 29, 2024
73961ba
Also change SPA web build
dac09 Feb 29, 2024
afb02ce
Lint
dac09 Feb 29, 2024
b4a7661
Revert "Ok"
dac09 Feb 29, 2024
20488fb
RSC: Make babel insert `renderFromRscServer` calls into Routes.tsx (#…
Tobbe Feb 29, 2024
e556b99
Merge branch 'main' into feat/rsc-build
Tobbe Feb 29, 2024
f22679d
Consistent rsc build logging
Tobbe Feb 29, 2024
44a86bf
Merge branch 'feat/rsc-build' of github.com:dac09/redwood into feat/r…
dac09 Feb 29, 2024
f9799ff
Revert "Move react plugin into their individual files"
dac09 Feb 29, 2024
9e2c3f7
Revert "Also change SPA web build"
dac09 Feb 29, 2024
8e435b4
More bad merging
dac09 Feb 29, 2024
6eb5ca9
MjsOrJs Resolution of paths
dac09 Feb 29, 2024
91cf5af
Remove log
dac09 Feb 29, 2024
350fadc
getMergedConfig
dac09 Feb 29, 2024
089daa9
Undo accidentally changing vscode settings
dac09 Feb 29, 2024
8e05e7f
Remove comment on entries
dac09 Feb 29, 2024
8db7877
Clarify comment on entries vs inputs
dac09 Feb 29, 2024
69abdd8
Remove TODO
dac09 Feb 29, 2024
df5b52f
Merge branch 'main' into feat/rsc-build
Tobbe Feb 29, 2024
e19ed76
chore(refactor): vite - extract into buildRouteHooks.ts (#10080)
Tobbe Feb 29, 2024
9e1f15b
Merge branch 'main' into feat/rsc-build
Tobbe Feb 29, 2024
b37a9c3
Merge branch 'main' into feat/rsc-build
Tobbe Mar 2, 2024
68f34ef
rscEnabled naming everywhere
Tobbe Mar 2, 2024
0b3a49c
getMergedConfig comment format
Tobbe Mar 2, 2024
18b6fd7
More comment formatting
Tobbe Mar 2, 2024
d5eb5d9
paths.ts: Move helper to esm section
Tobbe Mar 2, 2024
91861fd
Merge branch 'main' into feat/rsc-build
Tobbe Mar 2, 2024
49a788e
Merge branch 'main' into feat/rsc-build
Tobbe Mar 3, 2024
ce0e708
Merge branch 'main' into feat/rsc-build
Tobbe Mar 3, 2024
ec443aa
Merge branch 'main' into feat/rsc-build
Tobbe Mar 3, 2024
89040b4
Merge branch 'main' into feat/rsc-build
Tobbe Mar 3, 2024
22d4065
Remove duplicated comment (exists further down)
Tobbe Mar 3, 2024
14b1f47
Only comment about swc in one place
Tobbe Mar 3, 2024
df2ba4c
Merge branch 'main' into feat/rsc-build
Tobbe Mar 3, 2024
e9beff0
Remove handled TODO
Tobbe Mar 3, 2024
7941053
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
3e3f7b9
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
71851bb
Remove redundant cwd check
Tobbe Mar 4, 2024
72f56a0
Comment on ensureProcessDirWeb()
Tobbe Mar 4, 2024
ba48fc3
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
5ac8c2b
Merge branch 'feat/rsc-build' of github.com:dac09/redwood into feat/r…
dac09 Mar 4, 2024
99ca8dc
Hack: Skip calling renderFromRscServer during SSR
dac09 Mar 4, 2024
ab9713e
Undo settings.json
dac09 Mar 4, 2024
f6f0b4d
runFeServer: Always look for client-build-manifest in distClient
Tobbe Mar 4, 2024
ae5c998
Update comments
dac09 Mar 4, 2024
76dda62
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
c760de4
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
f8ec673
node:path
Tobbe Mar 4, 2024
7935477
streamingSsrEnabled rscEnabled
Tobbe Mar 4, 2024
1be4ef1
chore(style): getDefaultViteConfig source format
Tobbe Mar 4, 2024
394a23a
Merge branch 'tobbe-default-vite-config-tweaks' into feat/rsc-build
Tobbe Mar 4, 2024
17b0374
Merge branch 'main' into feat/rsc-build
Tobbe Mar 4, 2024
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: 15 additions & 6 deletions packages/project-config/src/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ const PATH_WEB_DIR_DIST_CLIENT = 'web/dist/client'
const PATH_WEB_DIR_DIST_RSC = 'web/dist/rsc'
const PATH_WEB_DIR_DIST_SERVER = 'web/dist/server'

const PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER = 'web/dist/server/entry.server.js'
const PATH_WEB_DIR_DIST_DOCUMENT = 'web/dist/server/Document.js'
// Don't specify extension, handled by resolve file
const PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER = 'web/dist/server/entry.server'
const PATH_WEB_DIR_DIST_DOCUMENT = 'web/dist/server/Document'

const PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS = 'web/dist/server/routeHooks'
const PATH_WEB_DIR_DIST_RSC_ENTRIES = 'web/dist/rsc/entries.js'
Expand Down Expand Up @@ -246,11 +247,13 @@ export const getPaths = (BASE_DIR: string = getBaseDir()): Paths => {
distClient: path.join(BASE_DIR, PATH_WEB_DIR_DIST_CLIENT),
distRsc: path.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC),
distServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER),
distEntryServer: path.join(
BASE_DIR,
PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER
// Allow for the possibility of a .mjs file
distEntryServer: mjsOrJs(
path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER_ENTRY_SERVER)
),
distDocumentServer: mjsOrJs(
path.join(BASE_DIR, PATH_WEB_DIR_DIST_DOCUMENT)
),
distDocumentServer: path.join(BASE_DIR, PATH_WEB_DIR_DIST_DOCUMENT),
distRouteHooks: path.join(BASE_DIR, PATH_WEB_DIR_DIST_SERVER_ROUTEHOOKS),
distRscEntries: path.join(BASE_DIR, PATH_WEB_DIR_DIST_RSC_ENTRIES),
routeManifest: path.join(BASE_DIR, PATH_WEB_DIR_ROUTE_MANIFEST),
Expand Down Expand Up @@ -430,3 +433,9 @@ export function projectIsEsm() {

return true
}

/** Default to JS path, but if MJS exists, use it instead */
const mjsOrJs = (filePath: string) => {
const mjsPath = resolveFile(filePath, ['.mjs'])
return mjsPath ? mjsPath : filePath + '.js'
}
3 changes: 0 additions & 3 deletions packages/vite/src/buildFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ export const buildFeServer = async ({ verbose, webDir }: BuildOptions = {}) => {
}

await buildRscClientAndServer()

// Write a route manifest
return await buildRouteManifest()
}

// We generate the RSC client bundle in the rscBuildClient function
Expand Down
14 changes: 6 additions & 8 deletions packages/vite/src/buildRouteManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import url from 'node:url'
import type { Manifest as ViteBuildManifest } from 'vite'

import { getProjectRoutes } from '@redwoodjs/internal/dist/routes'
import { getAppRouteHook, getConfig, getPaths } from '@redwoodjs/project-config'
import { getAppRouteHook, getPaths } from '@redwoodjs/project-config'

import type { RWRouteManifest } from './types'

Expand All @@ -14,15 +14,10 @@ import type { RWRouteManifest } from './types'
* Generate a route manifest file for the web server side.
*/
export async function buildRouteManifest() {
const rscEnabled = getConfig()?.experimental?.rsc?.enabled

const rwPaths = getPaths()

const buildManifestUrl = url.pathToFileURL(
path.join(
rscEnabled ? rwPaths.web.distClient : rwPaths.web.dist,
'client-build-manifest.json'
)
path.join(getPaths().web.distClient, 'client-build-manifest.json')
).href
const clientBuildManifest: ViteBuildManifest = (
await import(buildManifestUrl, { with: { type: 'json' } })
Expand All @@ -34,7 +29,10 @@ export async function buildRouteManifest() {
acc[route.pathDefinition] = {
name: route.name,
bundle: route.relativeFilePath
? clientBuildManifest[route.relativeFilePath]?.file ?? null
? // @TODO(RSC_DC): this no longer resolves to anything i.e. its always null
// Because the clientBuildManifest has no pages, because all pages are Server-components?
// This may be a non-issue, because RSC pages don't need a client bundle per page (or atleast not the same bundle)
clientBuildManifest[route.relativeFilePath]?.file ?? null
: null,
matchRegexString: route.matchRegexString,
// NOTE this is the path definition, not the actual path
Expand Down
6 changes: 6 additions & 0 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const BASE_PATH = '/rw-rsc/'
export function renderFromRscServer<Props>(rscId: string) {
Tobbe marked this conversation as resolved.
Show resolved Hide resolved
console.log('serve rscId', rscId)

// Temporarily skip rendering this component during SSR
// I don't know what we actually should do during SSR yet
if (typeof window === 'undefined') {
return null
}

type SetRerender = (
rerender: (next: [ReactElement, string]) => void
) => () => void
Expand Down
7 changes: 5 additions & 2 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { normalizePath } from 'vite'
import { getWebSideDefaultBabelConfig } from '@redwoodjs/babel-config'
import { getConfig, getPaths } from '@redwoodjs/project-config'

import { getDefaultViteConfig } from './lib/getDefaultViteConfig'
import { getMergedConfig } from './lib/getMergedConfig'
import handleJsAsJsx from './plugins/vite-plugin-jsx-loader'
import removeFromBundle from './plugins/vite-plugin-remove-from-bundle'
import swapApolloProvider from './plugins/vite-plugin-swap-apollo-provider'
Expand Down Expand Up @@ -125,7 +125,9 @@ export default function redwoodPluginVite(): PluginOption[] {
},
// ---------- End Bundle injection ----------

config: getDefaultViteConfig(rwConfig, rwPaths),
// @MARK: Using the config hook here let's us modify the config
// but returning plugins will **not** work
config: getMergedConfig(rwConfig, rwPaths),
},
// We can remove when streaming is stable
rwConfig.experimental.streamingSsr.enabled && swapApolloProvider(),
Expand All @@ -146,6 +148,7 @@ export default function redwoodPluginVite(): PluginOption[] {
babel: {
...getWebSideDefaultBabelConfig({
forVite: true,
forRscClient: rwConfig.experimental.rsc?.enabled,
}),
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@ import path from 'node:path'

import type { InputOption } from 'rollup'
import type { ConfigEnv, UserConfig } from 'vite'
import { mergeConfig } from 'vite'

import type { Config, Paths } from '@redwoodjs/project-config'
import { getConfig, getPaths } from '@redwoodjs/project-config'

import { getEnvVarDefinitions } from './envVarDefinitions'

export function getDefaultViteConfig(rwConfig: Config, rwPaths: Paths) {
return (options: UserConfig, env: ConfigEnv): UserConfig => {
/**
* This function will merge in the default Redwood Vite config passed into the
* build function (or in Vite.config.xxx)
*
* Note that returning plugins in this function will have no effect on the
* build
*/
export function getMergedConfig(rwConfig: Config, rwPaths: Paths) {
return (userConfig: UserConfig, env: ConfigEnv): UserConfig => {
let apiHost = process.env.REDWOOD_API_HOST
apiHost ??= rwConfig.api.host
apiHost ??= process.env.NODE_ENV === 'production' ? '0.0.0.0' : '[::]'

const streamingSsrEnabled = rwConfig.experimental.streamingSsr?.enabled
// @MARK: note that most RSC settings sit in their individual build functions
const rscEnabled = rwConfig.experimental.rsc?.enabled

let apiPort
Expand Down Expand Up @@ -101,7 +111,12 @@ export function getDefaultViteConfig(rwConfig: Config, rwPaths: Paths) {
},
},
build: {
outDir: options.build?.outDir || rwPaths.web.dist,
// NOTE this gets overridden when build gets called anyway!
outDir:
// @MARK: For RSC and Streaming, we build to dist/client directory
streamingSsrEnabled || rscEnabled
? rwPaths.web.distClient
: rwPaths.web.dist,
emptyOutDir: true,
manifest: !env.ssrBuild ? 'client-build-manifest.json' : undefined,
// Note that sourcemap can be boolean or 'inline'
Expand All @@ -110,9 +125,8 @@ export function getDefaultViteConfig(rwConfig: Config, rwPaths: Paths) {
input: getRollupInput(!!env.ssrBuild),
},
},
legacy: {
buildSsrCjsExternalHeuristics: rscEnabled ? false : env.ssrBuild,
},
// @MARK: do not set buildSsrCjsExternalHeuristics here
// because rsc builds want false, client and server build wants true
optimizeDeps: {
esbuildOptions: {
// @MARK this is because JS projects in Redwood don't have .jsx
Expand All @@ -130,7 +144,7 @@ export function getDefaultViteConfig(rwConfig: Config, rwPaths: Paths) {
},
}

return defaultRwViteConfig
return mergeConfig(defaultRwViteConfig, userConfig)
}
}

Expand Down
31 changes: 7 additions & 24 deletions packages/vite/src/rsc/rscBuildClient.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import path from 'node:path'

import react from '@vitejs/plugin-react'
import { build as viteBuild } from 'vite'

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

import { getEnvVarDefinitions } from '../lib/envVarDefinitions'
import { onWarn } from '../lib/onWarn'
import { ensureProcessDirWeb } from '../utils'

import { rscIndexPlugin } from './rscVitePlugins'

/**
* RSC build. Step 2.
* buildFeServer -> buildRscFeServer -> rscBuildClient
Expand All @@ -31,31 +24,21 @@ export async function rscBuildClient(clientEntryFiles: Record<string, string>) {
// unintended consequences on CSS processing
ensureProcessDirWeb()

if (!rwPaths.web.entryClient) {
throw new Error('Missing web/src/entry.client')
}

const clientBuildOutput = await viteBuild({
// configFile: viteConfigPath,
root: rwPaths.web.src,
envPrefix: 'REDWOOD_ENV_',
publicDir: path.join(rwPaths.web.base, 'public'),
envFile: false,
define: getEnvVarDefinitions(),
plugins: [
react({
babel: {
...getWebSideDefaultBabelConfig({
forVite: true,
forRscClient: true,
}),
},
}),
rscIndexPlugin(),
],
build: {
outDir: rwPaths.web.distClient,
emptyOutDir: true, // Needed because `outDir` is not inside `root`
rollupOptions: {
onwarn: onWarn,
input: {
main: rwPaths.web.html,
// @MARK: temporary hack to find the entry client so we can get the
// index.css bundle but we don't actually want this on an rsc page!
'rwjs-client-entry': rwPaths.web.entryClient,
// we need this, so that the output contains rsc-specific bundles
// for the client-only components. They get loaded once the page is
// rendered
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/rsc/rscBuildClientEntriesFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import type { rscBuildForServer } from './rscBuildForServer'
* `web/dist/rsc/entries.js` file.
* Only used by the RSC worker.
*/
// TODO(RSC_DC): This function should eventually be removed.
// The dev server will need this implemented as a Vite plugin,
// so worth waiting till implementation to swap out and just include the plugin for the prod build
export function rscBuildClientEntriesMappings(
clientBuildOutput: Awaited<ReturnType<typeof rscBuildClient>>,
serverBuildOutput: Awaited<ReturnType<typeof rscBuildForServer>>,
Expand All @@ -25,6 +28,7 @@ export function rscBuildClientEntriesMappings(
const clientEntries: Record<string, string> = {}
for (const item of clientBuildOutput) {
const { name, fileName } = item

const entryFile =
name &&
// TODO (RSC) Can't we just compare the names? `item.name === name`
Expand Down
19 changes: 4 additions & 15 deletions packages/vite/src/rsc/rscBuildForServer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import path from 'node:path'

import react from '@vitejs/plugin-react'
import { build as viteBuild } from 'vite'

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

import { getEnvVarDefinitions } from '../lib/envVarDefinitions'
import { onWarn } from '../lib/onWarn'

import { rscTransformPlugin } from './rscVitePlugins'
Expand Down Expand Up @@ -40,12 +37,11 @@ export async function rscBuildForServer(

// TODO (RSC): No redwood-vite plugin, add it in here
const rscServerBuildOutput = await viteBuild({
// ...configFileConfig,
root: rwPaths.web.src,
envPrefix: 'REDWOOD_ENV_',
publicDir: path.join(rwPaths.web.base, 'public'),
envFile: false,
define: getEnvVarDefinitions(),
legacy: {
// @MARK: for the worker, we're building ESM! (not CJS)
buildSsrCjsExternalHeuristics: false,
},
ssr: {
// Externalize everything except packages with files that have
// 'use client' in them (which are the files in `clientEntryFiles`)
Expand Down Expand Up @@ -86,13 +82,6 @@ export async function rscBuildForServer(
},
},
plugins: [
react({
babel: {
...getWebSideDefaultBabelConfig({
forVite: true,
}),
},
}),
// The rscTransformPlugin maps paths like
// /Users/tobbe/.../rw-app/node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js
// to
Expand Down
18 changes: 0 additions & 18 deletions packages/vite/src/rsc/rscVitePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ import type { Plugin } from 'vite'
import * as RSDWNodeLoader from '../react-server-dom-webpack/node-loader'
import type { ResolveFunction } from '../react-server-dom-webpack/node-loader'

import { rscWebpackShims } from './rscWebpackShims'

// Used in Step 2 of the build process, for the client bundle
export function rscIndexPlugin(): Plugin {
return {
name: 'rsc-index-plugin',
async transformIndexHtml() {
return [
{
tag: 'script',
children: rscWebpackShims,
injectTo: 'body',
},
]
},
}
}

export function rscTransformPlugin(
clientEntryFiles: Record<string, string>
): Plugin {
Expand Down
Loading
Loading