From 1ac0e305bcdbd4820263db8416e62528536023a1 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 7 May 2024 02:54:50 +0100 Subject: [PATCH 1/6] get it working --- packages/vite/src/buildRscClientAndServer.ts | 4 +- packages/vite/src/clientSsr.ts | 8 +- .../src/plugins/vite-plugin-rsc-analyze.ts | 11 - .../plugins/vite-plugin-rsc-css-preinit.ts | 244 ------------------ packages/vite/src/rsc/rscBuildAnalyze.ts | 6 - packages/vite/src/rsc/rscBuildForServer.ts | 4 - packages/vite/src/rsc/rscCss.ts | 69 +++++ packages/vite/src/runFeServer.ts | 6 +- 8 files changed, 82 insertions(+), 270 deletions(-) delete mode 100644 packages/vite/src/plugins/vite-plugin-rsc-css-preinit.ts create mode 100644 packages/vite/src/rsc/rscCss.ts diff --git a/packages/vite/src/buildRscClientAndServer.ts b/packages/vite/src/buildRscClientAndServer.ts index 1e1e92637eae..6aa210752e83 100644 --- a/packages/vite/src/buildRscClientAndServer.ts +++ b/packages/vite/src/buildRscClientAndServer.ts @@ -7,8 +7,7 @@ import { rscBuildRwEnvVars } from './rsc/rscBuildRwEnvVars.js' export const buildRscClientAndServer = async () => { // Analyze all files and generate a list of RSCs and RSFs - const { clientEntryFiles, serverEntryFiles, componentImportMap } = - await rscBuildAnalyze() + const { clientEntryFiles, serverEntryFiles } = await rscBuildAnalyze() // Generate the client bundle const clientBuildOutput = await rscBuildClient(clientEntryFiles) @@ -18,7 +17,6 @@ export const buildRscClientAndServer = async () => { clientEntryFiles, serverEntryFiles, {}, - componentImportMap, ) // Copy CSS assets from server to client diff --git a/packages/vite/src/clientSsr.ts b/packages/vite/src/clientSsr.ts index 65613992aa4f..86493b9d0cb4 100644 --- a/packages/vite/src/clientSsr.ts +++ b/packages/vite/src/clientSsr.ts @@ -8,6 +8,7 @@ import type { default as RSDWServerModule } from 'react-server-dom-webpack/serve import { getPaths } from '@redwoodjs/project-config' import { StatusError } from './lib/StatusError.js' +import { getRscStylesheetLinkGenerator } from './rsc/rscCss.js' import { moduleMap } from './streaming/ssrModuleMap.js' import { importModule } from './streaming/streamHelpers.js' import { makeFilePath } from './utils.js' @@ -97,6 +98,8 @@ export function renderFromDist>( ) { console.log('renderFromDist rscId', rscId) + const cssLinks = getRscStylesheetLinkGenerator([])() + // Create temporary client component that wraps the component (Page, most // likely) returned by the `createFromReadableStream` call. const SsrComponent = async (props: TProps) => { @@ -153,7 +156,10 @@ export function renderFromDist>( const stream = renderToReadableStream( // createElement(layout, undefined, createElement(page, props)), // @ts-expect-error - WIP - createElement(ServerEntry, { location: { pathname: rscId } }), + createElement(ServerEntry, { + location: { pathname: rscId }, + css: cssLinks, + }), bundlerConfig, ) diff --git a/packages/vite/src/plugins/vite-plugin-rsc-analyze.ts b/packages/vite/src/plugins/vite-plugin-rsc-analyze.ts index 84e919a7717f..47cc8eaa6374 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-analyze.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-analyze.ts @@ -2,17 +2,12 @@ import path from 'node:path' import * as swc from '@swc/core' import type { Plugin } from 'vite' -import { normalizePath } from 'vite' - -import { getPaths } from '@redwoodjs/project-config' export function rscAnalyzePlugin( clientEntryCallback: (id: string) => void, serverEntryCallback: (id: string) => void, - componentImportsCallback: (id: string, importId: readonly string[]) => void, ): Plugin { const clientEntryIdSet = new Set() - const webSrcPath = getPaths().web.src return { name: 'redwood-rsc-analyze-plugin', @@ -42,11 +37,5 @@ export function rscAnalyzePlugin( return code }, - moduleParsed(moduleInfo) { - // TODO: Maybe this is not needed? - if (moduleInfo.id.startsWith(normalizePath(webSrcPath))) { - componentImportsCallback(moduleInfo.id, moduleInfo.importedIds) - } - }, } } diff --git a/packages/vite/src/plugins/vite-plugin-rsc-css-preinit.ts b/packages/vite/src/plugins/vite-plugin-rsc-css-preinit.ts deleted file mode 100644 index 580932d32766..000000000000 --- a/packages/vite/src/plugins/vite-plugin-rsc-css-preinit.ts +++ /dev/null @@ -1,244 +0,0 @@ -import fs from 'fs' -import path from 'path' - -import generate from '@babel/generator' -import { parse as babelParse } from '@babel/parser' -import type { NodePath } from '@babel/traverse' -import traverse from '@babel/traverse' -import * as t from '@babel/types' -import type { Plugin } from 'vite' -import { normalizePath } from 'vite' - -import { getPaths } from '@redwoodjs/project-config' - -export function generateCssMapping(clientBuildManifest: any) { - const clientBuildManifestCss = new Map() - const lookupCssAssets = (id: string): string[] => { - const assets: string[] = [] - const asset = clientBuildManifest[id] - if (!asset) { - return assets - } - if (asset.css) { - assets.push(...asset.css) - } - if (asset.imports) { - for (const importId of asset.imports) { - assets.push(...lookupCssAssets(importId)) - } - } - return assets - } - for (const key of Object.keys(clientBuildManifest)) { - clientBuildManifestCss.set(key, lookupCssAssets(key)) - } - return clientBuildManifestCss -} - -export function splitClientAndServerComponents( - clientEntryFiles: Record, - componentImportMap: Map, -) { - const serverComponentImports = new Map() - const clientComponentImports = new Map() - const clientComponentIds = Object.values(clientEntryFiles) - for (const [key, value] of componentImportMap.entries()) { - if (clientComponentIds.includes(key)) { - clientComponentImports.set(key, value) - } else { - serverComponentImports.set(key, value) - } - } - return { serverComponentImports, clientComponentImports } -} - -export function generateServerComponentClientComponentMapping( - serverComponentImports: Map, - clientComponentImports: Map, -) { - const serverComponentClientImportIds = new Map() - const gatherClientImports = ( - id: string, - clientImports: Set, - ): void => { - const imports = clientComponentImports.get(id) ?? [] - for (const importId of imports) { - if (!clientImports.has(importId)) { - clientImports.add(importId) - gatherClientImports(importId, clientImports) - } - } - } - for (const serverComponentId of serverComponentImports.keys()) { - const clientImports = new Set() - const topLevelClientImports = - serverComponentImports.get(serverComponentId) ?? [] - for (const importId of topLevelClientImports) { - if (clientComponentImports.has(importId)) { - clientImports.add(importId) - } - gatherClientImports(importId, clientImports) - } - serverComponentClientImportIds.set( - serverComponentId, - Array.from(clientImports), - ) - } - return serverComponentClientImportIds -} - -export function rscCssPreinitPlugin( - clientEntryFiles: Record, - componentImportMap: Map, -): Plugin { - const webSrc = getPaths().web.src - - // This plugin is build only and we expect the client build manifest to be - // available at this point. We use it to find the correct css assets names - const manifestPath = path.join( - getPaths().web.distClient, - 'client-build-manifest.json', - ) - const clientBuildManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf-8')) - - // We generate a mapping of all the css assets that a client build manifest - // entry contains (looking deep into the tree of entries) - const clientBuildManifestCss = generateCssMapping(clientBuildManifest) - - // We filter to have individual maps for server components and client - // components - const { serverComponentImports, clientComponentImports } = - splitClientAndServerComponents(clientEntryFiles, componentImportMap) - - // We generate a mapping of server components to all the client components - // that they import (directly or indirectly) - const serverComponentClientImportIds = - generateServerComponentClientComponentMapping( - serverComponentImports, - clientComponentImports, - ) - - return { - name: 'rsc-css-preinit', - apply: 'build', - transform: async function (code, id) { - // We only care about code in the project itself - if (!id.startsWith(normalizePath(webSrc))) { - return null - } - - // We only care about server components - if (!serverComponentImports.has(id)) { - return null - } - - // Get the client components this server component imports (directly or - // indirectly) - const clientImportIds = serverComponentClientImportIds.get(id) ?? [] - if (clientImportIds.length === 0) { - return null - } - - // Extract all the CSS asset names from all the client components that - // this server component imports - const assetNames = new Set() - for (const clientImportId of clientImportIds) { - const shortName = path.basename(clientImportId) - const longName = clientImportId.substring(webSrc.length + 1) - const entries = - clientBuildManifestCss.get(shortName) ?? - clientBuildManifestCss.get(longName) ?? - [] - for (const entry of entries) { - assetNames.add(entry) - } - } - - if (assetNames.size === 0) { - return null - } - - // Analyze the AST to get all the components that we have to insert pre-init - // calls into - const ext = path.extname(id) - - const plugins = [] - if (ext === '.jsx') { - plugins.push('jsx') - } - const ast = babelParse(code, { - sourceType: 'unambiguous', - // @ts-expect-error TODO fix me - plugins, - }) - - // Gather a list of the names of exported components - const namedExportNames: string[] = [] - traverse(ast, { - ExportDefaultDeclaration(path: NodePath) { - const declaration = path.node.declaration - if (t.isIdentifier(declaration)) { - namedExportNames.push(declaration.name) - } - }, - }) - - // Insert: import { preinit } from 'react-dom' - ast.program.body.unshift( - t.importDeclaration( - [t.importSpecifier(t.identifier('preinit'), t.identifier('preinit'))], - t.stringLiteral('react-dom'), - ), - ) - - // TODO: Confirm this is a react component by looking for `jsxs` in the AST - // For each named export, insert a preinit call for each asset that it will - // eventually need for all it's child client components - traverse(ast, { - VariableDeclaration(path: NodePath) { - const declaration = path.node.declarations[0] - if ( - t.isVariableDeclarator(declaration) && - t.isIdentifier(declaration.id) && - namedExportNames.includes(declaration.id.name) - ) { - if (t.isArrowFunctionExpression(declaration.init)) { - const body = declaration.init.body - if (t.isBlockStatement(body)) { - for (const assetName of assetNames) { - body.body.unshift( - t.expressionStatement( - t.callExpression(t.identifier('preinit'), [ - t.stringLiteral(assetName), - t.objectExpression([ - t.objectProperty( - t.identifier('as'), - t.stringLiteral('style'), - ), - t.objectProperty( - t.identifier('precedence'), - t.stringLiteral('medium'), - ), - ]), - ]), - ), - ) - } - } - } - } - }, - }) - - // Just for debugging/verbose logging - console.log( - 'css-preinit:', - id.substring(webSrc.length + 1), - 'x' + assetNames.size, - '(' + Array.from(assetNames).join(', ') + ')', - ) - - return generate(ast).code - }, - } -} diff --git a/packages/vite/src/rsc/rscBuildAnalyze.ts b/packages/vite/src/rsc/rscBuildAnalyze.ts index 2d16fa5a61c0..90bff4c98ed5 100644 --- a/packages/vite/src/rsc/rscBuildAnalyze.ts +++ b/packages/vite/src/rsc/rscBuildAnalyze.ts @@ -21,7 +21,6 @@ export async function rscBuildAnalyze() { const rwPaths = getPaths() const clientEntryFileSet = new Set() const serverEntryFileSet = new Set() - const componentImportMap = new Map() if (!rwPaths.web.viteConfig) { throw new Error('Vite config not found') @@ -43,10 +42,6 @@ export async function rscBuildAnalyze() { rscAnalyzePlugin( (id) => clientEntryFileSet.add(id), (id) => serverEntryFileSet.add(id), - (id, imports) => { - const existingImports = componentImportMap.get(id) ?? [] - componentImportMap.set(id, [...existingImports, ...imports]) - }, ), ], ssr: { @@ -100,6 +95,5 @@ export async function rscBuildAnalyze() { return { clientEntryFiles, serverEntryFiles, - componentImportMap, } } diff --git a/packages/vite/src/rsc/rscBuildForServer.ts b/packages/vite/src/rsc/rscBuildForServer.ts index f43d52103ab9..0006a5f4b978 100644 --- a/packages/vite/src/rsc/rscBuildForServer.ts +++ b/packages/vite/src/rsc/rscBuildForServer.ts @@ -4,7 +4,6 @@ import { getPaths } from '@redwoodjs/project-config' import { getEntries } from '../lib/entries.js' import { onWarn } from '../lib/onWarn.js' -// import { rscCssPreinitPlugin } from '../plugins/vite-plugin-rsc-css-preinit.js' import { rscRoutesAutoLoader } from '../plugins/vite-plugin-rsc-routes-auto-loader.js' import { rscTransformUseClientPlugin } from '../plugins/vite-plugin-rsc-transform-client.js' import { rscTransformUseServerPlugin } from '../plugins/vite-plugin-rsc-transform-server.js' @@ -18,7 +17,6 @@ export async function rscBuildForServer( clientEntryFiles: Record, serverEntryFiles: Record, customModules: Record, - _componentImportMap: Map, ) { console.log('\n') console.log('3. rscBuildForServer') @@ -65,8 +63,6 @@ export async function rscBuildForServer( // (It does other things as well, but that's why it needs clientEntryFiles) rscTransformUseClientPlugin(clientEntryFiles), rscTransformUseServerPlugin(), - // Note: Temporary disabled while we fix the underlying css issue - // rscCssPreinitPlugin(clientEntryFiles, componentImportMap), rscRoutesAutoLoader(), ], build: { diff --git a/packages/vite/src/rsc/rscCss.ts b/packages/vite/src/rsc/rscCss.ts new file mode 100644 index 000000000000..b63f59999449 --- /dev/null +++ b/packages/vite/src/rsc/rscCss.ts @@ -0,0 +1,69 @@ +import fs from 'node:fs' +import path from 'node:path' + +import { getPaths } from '@redwoodjs/project-config' + +export function getRscStylesheetLinkGenerator(existingLinks: string[]) { + const clientBuildManifestPath = path.join( + getPaths().web.distClient, + 'client-build-manifest.json', + ) + const clientBuildManifest = JSON.parse( + fs.readFileSync(clientBuildManifestPath, 'utf-8'), + ) + + const serverBuildManifestPath = path.join( + getPaths().web.distRsc, + 'server-build-manifest.json', + ) + const serverBuildManifest = JSON.parse( + fs.readFileSync(serverBuildManifestPath, 'utf-8'), + ) + + const clientCss = generateCssMapping(clientBuildManifest) + const serverCss = generateCssMapping(serverBuildManifest) + + const allCss = new Set() + for (const [_, value] of clientCss) { + if (value.length > 0) { + for (const css of value) { + allCss.add(css) + } + } + } + for (const [_, value] of serverCss) { + if (value.length > 0) { + for (const css of value) { + allCss.add(css) + } + } + } + + const cssLinks = Array.from(allCss) + + return () => [...existingLinks, ...cssLinks] +} + +function generateCssMapping(manifest: any) { + const manifestCss = new Map() + const lookupCssAssets = (id: string): string[] => { + const assets: string[] = [] + const asset = manifest[id] + if (!asset) { + return assets + } + if (asset.css) { + assets.push(...asset.css) + } + if (asset.imports) { + for (const importId of asset.imports) { + assets.push(...lookupCssAssets(importId)) + } + } + return assets + } + for (const key of Object.keys(manifest)) { + manifestCss.set(key, lookupCssAssets(key)) + } + return manifestCss +} diff --git a/packages/vite/src/runFeServer.ts b/packages/vite/src/runFeServer.ts index 908092565509..05298bfc7a4a 100644 --- a/packages/vite/src/runFeServer.ts +++ b/packages/vite/src/runFeServer.ts @@ -23,6 +23,7 @@ import { registerFwGlobalsAndShims } from './lib/registerFwGlobalsAndShims.js' import { invoke } from './middleware/invokeMiddleware.js' import { createMiddlewareRouter } from './middleware/register.js' import type { Middleware } from './middleware/types.js' +import { getRscStylesheetLinkGenerator } from './rsc/rscCss.js' import { createRscRequestHandler } from './rsc/rscRequestHandler.js' import { setClientEntries } from './rsc/rscWorkerCommunication.js' import { createReactStreamingHandler } from './streaming/createReactStreamingHandler.js' @@ -146,9 +147,12 @@ export async function runFeServer() { // the static assets over any application routing. app.use(express.static(rwPaths.web.distClient, { index: false })) - const getStylesheetLinks = () => clientEntry.css || [] const clientEntryPath = '/' + clientEntry.file + const getStylesheetLinks = rscEnabled + ? getRscStylesheetLinkGenerator(clientEntry.css ?? []) + : () => clientEntry.css || [] + const routeHandler = await createReactStreamingHandler({ routes: Object.values(routeManifest), clientEntryPath, From 71cd535e8b5dc584dc9babf6dde5ac497e0677c5 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 7 May 2024 03:05:19 +0100 Subject: [PATCH 2/6] re-enable smoke tests --- tasks/smoke-tests/rsc-dev/tests/rsc.spec.ts | 3 +-- .../rsc-kitchen-sink/tests/rsc-kitchen-sink.spec.ts | 3 +-- tasks/smoke-tests/rsc/tests/rsc.spec.ts | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tasks/smoke-tests/rsc-dev/tests/rsc.spec.ts b/tasks/smoke-tests/rsc-dev/tests/rsc.spec.ts index f95fb1acb49d..a8c4de8cb83b 100644 --- a/tasks/smoke-tests/rsc-dev/tests/rsc.spec.ts +++ b/tasks/smoke-tests/rsc-dev/tests/rsc.spec.ts @@ -17,8 +17,7 @@ test('Setting up RSC should give you a test project with a client side counter c page.close() }) -// Note: Disabled temporarily while we fix the underlying css issue -test.skip('CSS has been loaded', async ({ page }) => { +test('CSS has been loaded', async ({ page }) => { await page.goto('/') // Check color of server component h3 diff --git a/tasks/smoke-tests/rsc-kitchen-sink/tests/rsc-kitchen-sink.spec.ts b/tasks/smoke-tests/rsc-kitchen-sink/tests/rsc-kitchen-sink.spec.ts index 47b903d8c868..4bbecb8c8dcd 100644 --- a/tasks/smoke-tests/rsc-kitchen-sink/tests/rsc-kitchen-sink.spec.ts +++ b/tasks/smoke-tests/rsc-kitchen-sink/tests/rsc-kitchen-sink.spec.ts @@ -15,8 +15,7 @@ test('Client components should work', async ({ page }) => { page.close() }) -// Note: Disabled temporarily while we fix the underlying css issue -test.skip('CSS has been loaded', async ({ page }) => { +test('CSS has been loaded', async ({ page }) => { await page.goto('/') // Check color of client component h3 diff --git a/tasks/smoke-tests/rsc/tests/rsc.spec.ts b/tasks/smoke-tests/rsc/tests/rsc.spec.ts index 2a834c2cede0..1ecf3317c194 100644 --- a/tasks/smoke-tests/rsc/tests/rsc.spec.ts +++ b/tasks/smoke-tests/rsc/tests/rsc.spec.ts @@ -17,8 +17,7 @@ test('Setting up RSC should give you a test project with a client side counter c page.close() }) -// Note: Disabled temporarily while we fix the underlying css issue -test.skip('CSS has been loaded', async ({ page }) => { +test('CSS has been loaded', async ({ page }) => { await page.goto('/') // Check color of server component h3 From 1b0329d3f415f8409ec19d55c2aba542514ae793 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 7 May 2024 03:15:31 +0100 Subject: [PATCH 3/6] remove unused test --- ...e-plugin-rsc-css-preinit-fixture-values.ts | 723 ------------------ .../vite-plugin-rsc-css-preinit.test.mts | 593 -------------- 2 files changed, 1316 deletions(-) delete mode 100644 packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit-fixture-values.ts delete mode 100644 packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit.test.mts diff --git a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit-fixture-values.ts b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit-fixture-values.ts deleted file mode 100644 index ccee9e4b70db..000000000000 --- a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit-fixture-values.ts +++ /dev/null @@ -1,723 +0,0 @@ -export const clientEntryFiles = { - 'rsc-EmptyUsersCell.tsx-0': - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx', - 'rsc-AboutCounter.tsx-1': - '/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx', - 'rsc-rsc-test.es.js-2': - '/Users/mojombo/rw-app/node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js', - 'rsc-UpdateRandomButton.tsx-3': - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx', - 'rsc-Counter.tsx-4': - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx', - 'rsc-NewEmptyUser.tsx-5': - '/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx', - 'rsc-NewUserExample.tsx-6': - '/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx', - 'rsc-UserExamplesCell.tsx-7': - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx', - 'rsc-CellErrorBoundary.js-8': - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/cell/CellErrorBoundary.js', - 'rsc-DeepSubCounter.tsx-9': - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx', - 'rsc-SubCounter.tsx-10': - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx', - 'rsc-link.js-11': - '/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/link.js', - 'rsc-navLink.js-12': - '/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/navLink.js', - 'rsc-UserExamples.tsx-13': - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx', - 'rsc-UserExample.tsx-14': - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx', - 'rsc-ApolloNextAppProvider.js-15': - '/Users/mojombo/rw-app/node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/ApolloNextAppProvider.js', - 'rsc-hooks.js-16': - '/Users/mojombo/rw-app/node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/hooks.js', - 'rsc-useTransportValue.js-17': - '/Users/mojombo/rw-app/node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/useTransportValue.js', - 'rsc-index.js-18': - '/Users/mojombo/rw-app/node_modules/react-hot-toast/dist/index.js', -} - -export const componentImportMap = new Map([ - [ - '/Users/mojombo/rw-app/web/src/entry.server.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/App.tsx', - '/Users/mojombo/rw-app/web/src/Document.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/entries.ts', - ['/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/entries.js'], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplesPage/UserExamplesPage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/UserExample/NewUserExamplePage/NewUserExamplePage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplePage/UserExamplePage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleServerCell/UserExampleServerCell.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx', - ], - ], - ['/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.css', []], - ['/Users/mojombo/rw-app/web/src/index.css', []], - ['/Users/mojombo/rw-app/web/src/scaffold.css', []], - ['/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.css', []], - [ - '/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx', - ['react/jsx-runtime'], - ], - [ - '/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx', - [ - 'react/jsx-runtime', - 'react', - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx', - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css', - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.css', - ], - ], - ['/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.css', []], - [ - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/HomePage/actions.ts', - ['/Users/mojombo/rw-app/web/src/pages/HomePage/words.ts'], - ], - [ - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts', - [], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx', - ['react/jsx-runtime'], - ], - [ - '/Users/mojombo/rw-app/web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx', - ['react/jsx-runtime'], - ], - [ - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx', - [ - 'react/jsx-runtime', - 'react', - '/Users/mojombo/rw-app/node_modules/client-only/index.js', - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx', - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css', - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.css', - ], - ], - ['/Users/mojombo/rw-app/web/src/components/Counter/Counter.css', []], - [ - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.css', - [], - ], - ['/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.module.css', []], - ['/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css', []], - [ - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx', - [ - 'react/jsx-runtime', - 'react', - '/Users/mojombo/rw-app/node_modules/client-only/index.js', - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css', - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx', - [ - 'react/jsx-runtime', - 'react', - '/Users/mojombo/rw-app/node_modules/client-only/index.js', - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx', - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css', - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.css', - [], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/HomePage/words.ts', - ['/Users/mojombo/rw-app/node_modules/server-only/index.js'], - ], - [ - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css', - [], - ], - [ - '/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css', - [], - ], - [ - '/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css', - [], - ], - ['/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css', []], - [ - '/Users/mojombo/rw-app/web/src/lib/formatters.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/humanize-string/index.js', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/cell/createServerCell.js', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleServerCell/UserExampleServerCell.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/cell/createServerCell.js', - '/Users/mojombo/rw-app/api/src/lib/db.ts', - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/forms/dist/index.js', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/forms/dist/index.js', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js', - '/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx', - '/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.tsx', - '/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx', - '/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js', - '/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx', - '/Users/mojombo/rw-app/web/src/pages/HomePage/actions.ts', - '/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.module.css', - '/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/Document.tsx', - [ - 'react/jsx-runtime', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/App.tsx', - [ - 'react/jsx-runtime', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/apollo/suspense.js', - '/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx', - '/Users/mojombo/rw-app/web/src/Routes.tsx', - '/Users/mojombo/rw-app/web/src/index.css', - '/Users/mojombo/rw-app/web/src/scaffold.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/Routes.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/client.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.tsx', - '/Users/mojombo/rw-app/web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx', - '/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx', - [ - 'react/jsx-runtime', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js', - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js', - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx', - [ - 'react/jsx-runtime', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.tsx', - [ - 'react/jsx-runtime', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.css', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js', - '/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx', - '/Users/mojombo/rw-app/web/src/lib/formatters.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/GraphQLHooksProvider.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js', - '/Users/mojombo/rw-app/web/src/lib/formatters.tsx', - ], - ], - [ - '/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx', - [ - 'react/jsx-runtime', - '/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import', - '\u0000/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import', - '/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js', - '/Users/mojombo/rw-app/web/src/lib/formatters.tsx', - ], - ], -]) - -export const clientBuildManifest = { - '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/ApolloNextAppProvider.js?commonjs-entry': - { - file: 'assets/rsc-ApolloNextAppProvider.js-15-BjjNQa7m.mjs', - src: '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/ApolloNextAppProvider.js?commonjs-entry', - isEntry: true, - imports: ['_ApolloNextAppProvider-5bPKKKc8.mjs'], - }, - '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/hooks.js?commonjs-entry': - { - file: 'assets/rsc-hooks.js-16-B-wbhCo5.mjs', - src: '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/hooks.js?commonjs-entry', - isEntry: true, - imports: [ - '_index-g0M7Bzdc.mjs', - '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/useTransportValue.js?commonjs-entry', - '_RehydrationContext-Dl2W9Kr7.mjs', - ], - }, - '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/useTransportValue.js?commonjs-entry': - { - file: 'assets/rsc-useTransportValue.js-17-DPe60dHv.mjs', - src: '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/useTransportValue.js?commonjs-entry', - isEntry: true, - imports: ['_index-XIvlupAM.mjs', '_RehydrationContext-Dl2W9Kr7.mjs'], - }, - '../../node_modules/@redwoodjs/router/dist/link.js?commonjs-entry': { - file: 'assets/rsc-link.js-11-LeguEpQ6.mjs', - src: '../../node_modules/@redwoodjs/router/dist/link.js?commonjs-entry', - isEntry: true, - imports: ['_link-AMDPp6FV.mjs'], - }, - '../../node_modules/@redwoodjs/router/dist/navLink.js?commonjs-entry': { - file: 'assets/rsc-navLink.js-12-D-x4cO0F.mjs', - src: '../../node_modules/@redwoodjs/router/dist/navLink.js?commonjs-entry', - isEntry: true, - imports: ['_navLink-DO_92T9r.mjs'], - }, - '../../node_modules/@redwoodjs/web/dist/components/cell/CellErrorBoundary.js?commonjs-entry': - { - file: 'assets/rsc-CellErrorBoundary.js-8-CwwdOVwg.mjs', - src: '../../node_modules/@redwoodjs/web/dist/components/cell/CellErrorBoundary.js?commonjs-entry', - isEntry: true, - imports: ['_CellErrorBoundary-DMFDzi5M.mjs'], - }, - '../../node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js': { - file: 'assets/rsc-rsc-test.es.js-2-DlPy-QDf.mjs', - src: '../../node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js', - isEntry: true, - imports: ['_jsx-runtime-CumG5p_V.mjs', '_index-XIvlupAM.mjs'], - }, - '../../node_modules/react-hot-toast/dist/index.js?commonjs-entry': { - file: 'assets/rsc-index.js-18-DAWxXOEp.mjs', - src: '../../node_modules/react-hot-toast/dist/index.js?commonjs-entry', - isEntry: true, - imports: ['_index-tlgoshdH.mjs'], - }, - '_ApolloNextAppProvider-5bPKKKc8.mjs': { - file: 'assets/ApolloNextAppProvider-5bPKKKc8.mjs', - imports: [ - '_index-XIvlupAM.mjs', - '_index-g0M7Bzdc.mjs', - '_RehydrationContext-Dl2W9Kr7.mjs', - ], - }, - '_CellErrorBoundary-DMFDzi5M.mjs': { - file: 'assets/CellErrorBoundary-DMFDzi5M.mjs', - imports: ['_index-XIvlupAM.mjs', '_interopRequireDefault-eg4KyS4X.mjs'], - }, - '_Counter-!~{00n}~.mjs': { - file: 'assets/Counter-BZpJq_HD.css', - src: '_Counter-!~{00n}~.mjs', - }, - '_Counter-Bq0ieMbL.mjs': { - file: 'assets/Counter-Bq0ieMbL.mjs', - css: ['assets/Counter-BZpJq_HD.css'], - }, - '_RehydrationContext-Dl2W9Kr7.mjs': { - file: 'assets/RehydrationContext-Dl2W9Kr7.mjs', - imports: [ - '_index-XIvlupAM.mjs', - '_index-g0M7Bzdc.mjs', - '_index-CCoFRA3G.mjs', - ], - }, - '_formatters-CUUSZ_T1.mjs': { - file: 'assets/formatters-CUUSZ_T1.mjs', - imports: ['_jsx-runtime-CumG5p_V.mjs', '_index-Bweuhc7G.mjs'], - }, - '_index--S8VRXEP.mjs': { - file: 'assets/index--S8VRXEP.mjs', - imports: ['_index-g0M7Bzdc.mjs'], - }, - '_index-Bd_2BODu.mjs': { - file: 'assets/index-Bd_2BODu.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_index-XIvlupAM.mjs', - '_navLink-DO_92T9r.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - ], - }, - '_index-Bweuhc7G.mjs': { - file: 'assets/index-Bweuhc7G.mjs', - }, - '_index-CCoFRA3G.mjs': { - file: 'assets/index-CCoFRA3G.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_index-XIvlupAM.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - ], - }, - '_index-CaDi1HgM.mjs': { - file: 'assets/index-CaDi1HgM.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_index-tlgoshdH.mjs', - ], - }, - '_index-CdhfsYOK.mjs': { - file: 'assets/index-CdhfsYOK.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_link-AMDPp6FV.mjs', - '_navLink-DO_92T9r.mjs', - '_index-XIvlupAM.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - '_values-COtCHOJX.mjs', - ], - }, - '_index-XIvlupAM.mjs': { - file: 'assets/index-XIvlupAM.mjs', - }, - '_index-g0M7Bzdc.mjs': { - file: 'assets/index-g0M7Bzdc.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_values-COtCHOJX.mjs', - '_index-XIvlupAM.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - '_index-CCoFRA3G.mjs', - '_CellErrorBoundary-DMFDzi5M.mjs', - ], - }, - '_index-tlgoshdH.mjs': { - file: 'assets/index-tlgoshdH.mjs', - imports: ['_index-XIvlupAM.mjs'], - }, - '_interopRequireDefault-eg4KyS4X.mjs': { - file: 'assets/interopRequireDefault-eg4KyS4X.mjs', - imports: ['_index-XIvlupAM.mjs'], - }, - '_jsx-runtime-Bx74Uukx.mjs': { - file: 'assets/jsx-runtime-Bx74Uukx.mjs', - imports: ['_index-XIvlupAM.mjs'], - }, - '_jsx-runtime-CumG5p_V.mjs': { - file: 'assets/jsx-runtime-CumG5p_V.mjs', - imports: ['_jsx-runtime-Bx74Uukx.mjs'], - }, - '_link-AMDPp6FV.mjs': { - file: 'assets/link-AMDPp6FV.mjs', - imports: [ - '_index-XIvlupAM.mjs', - '_interopRequireDefault-eg4KyS4X.mjs', - '_values-COtCHOJX.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - ], - }, - '_navLink-DO_92T9r.mjs': { - file: 'assets/navLink-DO_92T9r.mjs', - imports: [ - '_index-XIvlupAM.mjs', - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_link-AMDPp6FV.mjs', - '_values-COtCHOJX.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - ], - }, - '_starts-with-4Ylsn4Ru.mjs': { - file: 'assets/starts-with-4Ylsn4Ru.mjs', - imports: [ - '_interopRequireDefault-eg4KyS4X.mjs', - '_values-COtCHOJX.mjs', - '_index-XIvlupAM.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - ], - }, - '_values-COtCHOJX.mjs': { - file: 'assets/values-COtCHOJX.mjs', - imports: ['_interopRequireDefault-eg4KyS4X.mjs'], - }, - 'components/Counter/AboutCounter.tsx': { - file: 'assets/rsc-AboutCounter.tsx-1-D7GRRRfU.mjs', - src: 'components/Counter/AboutCounter.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-XIvlupAM.mjs', - 'components/DeepSubCounter/DeepSubCounter.tsx', - '_Counter-Bq0ieMbL.mjs', - ], - }, - 'components/Counter/Counter.tsx': { - file: 'assets/rsc-Counter.tsx-4-BozfkEJL.mjs', - src: 'components/Counter/Counter.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-XIvlupAM.mjs', - 'components/SubCounter/SubCounter.tsx', - '_Counter-Bq0ieMbL.mjs', - ], - }, - 'components/DeepSubCounter/DeepSubCounter.tsx': { - file: 'assets/rsc-DeepSubCounter.tsx-9-jD7pNfn4.mjs', - src: 'components/DeepSubCounter/DeepSubCounter.tsx', - isEntry: true, - imports: ['_jsx-runtime-CumG5p_V.mjs', '_index-XIvlupAM.mjs'], - css: ['assets/rsc-DeepSubCounter-DqMovEyK.css'], - }, - 'components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx': { - file: 'assets/rsc-EmptyUsersCell.tsx-0-B-L_MnYe.mjs', - src: 'components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index--S8VRXEP.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - '_index-CaDi1HgM.mjs', - '_formatters-CUUSZ_T1.mjs', - ], - }, - 'components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx': { - file: 'assets/rsc-NewEmptyUser.tsx-5-BLZ1UKnU.mjs', - src: 'components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - '_index--S8VRXEP.mjs', - '_index-CaDi1HgM.mjs', - '_index-Bd_2BODu.mjs', - ], - }, - 'components/RandomNumberServerCell/UpdateRandomButton.tsx': { - file: 'assets/rsc-UpdateRandomButton.tsx-3-C9DK-uNf.mjs', - src: 'components/RandomNumberServerCell/UpdateRandomButton.tsx', - isEntry: true, - imports: ['_jsx-runtime-CumG5p_V.mjs'], - }, - 'components/SubCounter/SubCounter.tsx': { - file: 'assets/rsc-SubCounter.tsx-10-B8AM92Qq.mjs', - src: 'components/SubCounter/SubCounter.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-XIvlupAM.mjs', - 'components/DeepSubCounter/DeepSubCounter.tsx', - ], - css: ['assets/rsc-SubCounter-Bc4odF6o.css'], - }, - 'components/UserExample/NewUserExample/NewUserExample.tsx': { - file: 'assets/rsc-NewUserExample.tsx-6-D27m-VY-.mjs', - src: 'components/UserExample/NewUserExample/NewUserExample.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - '_index--S8VRXEP.mjs', - '_index-CaDi1HgM.mjs', - '_index-Bd_2BODu.mjs', - ], - }, - 'components/UserExample/UserExample/UserExample.tsx': { - file: 'assets/rsc-UserExample.tsx-14-CiDZqyWK.mjs', - src: 'components/UserExample/UserExample/UserExample.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - '_index--S8VRXEP.mjs', - '_index-CaDi1HgM.mjs', - '_index-Bweuhc7G.mjs', - ], - }, - 'components/UserExample/UserExamples/UserExamples.tsx': { - file: 'assets/rsc-UserExamples.tsx-13-B55kMTY0.mjs', - src: 'components/UserExample/UserExamples/UserExamples.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - '_index-CaDi1HgM.mjs', - '_formatters-CUUSZ_T1.mjs', - ], - }, - 'components/UserExample/UserExamplesCell/UserExamplesCell.tsx': { - file: 'assets/rsc-UserExamplesCell.tsx-7-DlCGhOAY.mjs', - src: 'components/UserExample/UserExamplesCell/UserExamplesCell.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index--S8VRXEP.mjs', - '_index-CCoFRA3G.mjs', - '_index-CdhfsYOK.mjs', - 'components/UserExample/UserExamples/UserExamples.tsx', - ], - }, - 'entry.client.tsx': { - file: 'assets/rwjs-client-entry-B1o165l4.mjs', - src: 'entry.client.tsx', - isEntry: true, - imports: [ - '_jsx-runtime-CumG5p_V.mjs', - '_index-g0M7Bzdc.mjs', - '_index--S8VRXEP.mjs', - '_interopRequireDefault-eg4KyS4X.mjs', - '_starts-with-4Ylsn4Ru.mjs', - '_values-COtCHOJX.mjs', - '_index-XIvlupAM.mjs', - '_ApolloNextAppProvider-5bPKKKc8.mjs', - '_RehydrationContext-Dl2W9Kr7.mjs', - '../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/hooks.js?commonjs-entry', - '_index-CCoFRA3G.mjs', - '_jsx-runtime-Bx74Uukx.mjs', - '_index-CdhfsYOK.mjs', - ], - css: ['assets/rwjs-client-entry-79N3uomO.css'], - }, -} diff --git a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit.test.mts b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit.test.mts deleted file mode 100644 index 66909724e5a8..000000000000 --- a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-css-preinit.test.mts +++ /dev/null @@ -1,593 +0,0 @@ -import path from 'node:path' -import { vol } from 'memfs' -import { normalizePath } from 'vite' - -import { generateCssMapping, rscCssPreinitPlugin, generateServerComponentClientComponentMapping, splitClientAndServerComponents } from '../vite-plugin-rsc-css-preinit' -import { afterAll, beforeAll, describe, it, expect, vi } from 'vitest' - -import { - clientBuildManifest, - clientEntryFiles, - componentImportMap, -} from './vite-plugin-rsc-css-preinit-fixture-values' -import { getPaths } from '@redwoodjs/project-config' - -vi.mock('fs', async () => ({ default: (await import('memfs')).fs })) - -const RWJS_CWD = process.env.RWJS_CWD - -let consoleLogSpy -beforeAll(() => { - // Add the toml so that getPaths will work - process.env.RWJS_CWD = '/Users/mojombo/rw-app/' - vol.fromJSON({ - 'redwood.toml': '', - }, process.env.RWJS_CWD) - - // Add the client build manifest - const manifestPath = path.join( - getPaths().web.distClient, - 'client-build-manifest.json', - ).substring(process.env.RWJS_CWD.length) - vol.fromJSON({ - 'redwood.toml': '', - [manifestPath]: JSON.stringify(clientBuildManifest), - }, process.env.RWJS_CWD) - - consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) -}) - -afterAll(() => { - process.env.RWJS_CWD = RWJS_CWD - consoleLogSpy.mockRestore() -}) - -describe('rscCssPreinitPlugin', () => { - it('should insert preinits for all nested client components', async () => { - const plugin = rscCssPreinitPlugin(clientEntryFiles, componentImportMap) - - if (typeof plugin.transform !== 'function') { - return - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const id = path.join(process.env.RWJS_CWD!, 'web', 'src', 'pages', 'HomePage', 'HomePage.tsx') - const output = await plugin.transform.bind({})( - `import { jsx, jsxs } from "react/jsx-runtime"; - import { RscForm } from "@tobbe.dev/rsc-test"; - import { Assets } from "@redwoodjs/vite/assets"; - import { ProdRwRscServerGlobal } from "@redwoodjs/vite/rwRscGlobal"; - import { Counter } from "../../components/Counter/Counter"; - import { onSend } from "./actions"; - import styles from "./HomePage.module.css"; - import "./HomePage.css"; - globalThis.rwRscGlobal = new ProdRwRscServerGlobal(); - const HomePage = ({ - name = "Anonymous" - }) => { - return /* @__PURE__ */ jsxs("div", { className: "home-page", children: [ - /* @__PURE__ */ jsx(Assets, {}), - /* @__PURE__ */ jsxs("div", { style: { - border: "3px red dashed", - margin: "1em", - padding: "1em" - }, children: [ - /* @__PURE__ */ jsxs("h1", { className: styles.title, children: [ - "Hello ", - name, - "!!" - ] }), - /* @__PURE__ */ jsx(RscForm, { onSend }), - /* @__PURE__ */ jsx(Counter, {}) - ] }) - ] }); - }; - export default HomePage;`, - normalizePath(id) - ) - - // You will see that this snapshot contains: - // - an import for the 'preinit' function from 'react-dom' - // - three 'preinit' calls within the HomePage function: - // - one for the Counter component which is a direct child of the HomePage - // - one for the SubCounter component which is a child of the Counter component - // - one for the DeepSubCounter component which is a child of the SubCounter component - expect(output).toMatchInlineSnapshot(` - "import { preinit } from "react-dom"; - import { jsx, jsxs } from "react/jsx-runtime"; - import { RscForm } from "@tobbe.dev/rsc-test"; - import { Assets } from "@redwoodjs/vite/assets"; - import { ProdRwRscServerGlobal } from "@redwoodjs/vite/rwRscGlobal"; - import { Counter } from "../../components/Counter/Counter"; - import { onSend } from "./actions"; - import styles from "./HomePage.module.css"; - import "./HomePage.css"; - globalThis.rwRscGlobal = new ProdRwRscServerGlobal(); - const HomePage = ({ - name = "Anonymous" - }) => { - preinit("assets/Counter-BZpJq_HD.css", { - as: "style", - precedence: "medium" - }); - preinit("assets/rsc-DeepSubCounter-DqMovEyK.css", { - as: "style", - precedence: "medium" - }); - preinit("assets/rsc-SubCounter-Bc4odF6o.css", { - as: "style", - precedence: "medium" - }); - return /* @__PURE__ */jsxs("div", { - className: "home-page", - children: [/* @__PURE__ */jsx(Assets, {}), /* @__PURE__ */jsxs("div", { - style: { - border: "3px red dashed", - margin: "1em", - padding: "1em" - }, - children: [/* @__PURE__ */jsxs("h1", { - className: styles.title, - children: ["Hello ", name, "!!"] - }), /* @__PURE__ */jsx(RscForm, { - onSend - }), /* @__PURE__ */jsx(Counter, {})] - })] - }); - }; - export default HomePage;" - `) - - // We print a log to help with debugging - expect(consoleLogSpy).toHaveBeenCalledWith( - "css-preinit:", - "pages/HomePage/HomePage.tsx", - "x3", - "(assets/rsc-SubCounter-Bc4odF6o.css, assets/rsc-DeepSubCounter-DqMovEyK.css, assets/Counter-BZpJq_HD.css)", - ) - }) - - it('correctly generates css mapping', () => { - const mapping = generateCssMapping(clientBuildManifest) - expect(mapping).toMatchInlineSnapshot(` - Map { - "../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/ApolloNextAppProvider.js?commonjs-entry" => [], - "../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/hooks.js?commonjs-entry" => [], - "../../node_modules/@apollo/experimental-nextjs-app-support/dist/ssr/useTransportValue.js?commonjs-entry" => [], - "../../node_modules/@redwoodjs/router/dist/link.js?commonjs-entry" => [], - "../../node_modules/@redwoodjs/router/dist/navLink.js?commonjs-entry" => [], - "../../node_modules/@redwoodjs/web/dist/components/cell/CellErrorBoundary.js?commonjs-entry" => [], - "../../node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js" => [], - "../../node_modules/react-hot-toast/dist/index.js?commonjs-entry" => [], - "_ApolloNextAppProvider-5bPKKKc8.mjs" => [], - "_CellErrorBoundary-DMFDzi5M.mjs" => [], - "_Counter-!~{00n}~.mjs" => [], - "_Counter-Bq0ieMbL.mjs" => [ - "assets/Counter-BZpJq_HD.css", - ], - "_RehydrationContext-Dl2W9Kr7.mjs" => [], - "_formatters-CUUSZ_T1.mjs" => [], - "_index--S8VRXEP.mjs" => [], - "_index-Bd_2BODu.mjs" => [], - "_index-Bweuhc7G.mjs" => [], - "_index-CCoFRA3G.mjs" => [], - "_index-CaDi1HgM.mjs" => [], - "_index-CdhfsYOK.mjs" => [], - "_index-XIvlupAM.mjs" => [], - "_index-g0M7Bzdc.mjs" => [], - "_index-tlgoshdH.mjs" => [], - "_interopRequireDefault-eg4KyS4X.mjs" => [], - "_jsx-runtime-Bx74Uukx.mjs" => [], - "_jsx-runtime-CumG5p_V.mjs" => [], - "_link-AMDPp6FV.mjs" => [], - "_navLink-DO_92T9r.mjs" => [], - "_starts-with-4Ylsn4Ru.mjs" => [], - "_values-COtCHOJX.mjs" => [], - "components/Counter/AboutCounter.tsx" => [ - "assets/rsc-DeepSubCounter-DqMovEyK.css", - "assets/Counter-BZpJq_HD.css", - ], - "components/Counter/Counter.tsx" => [ - "assets/rsc-SubCounter-Bc4odF6o.css", - "assets/rsc-DeepSubCounter-DqMovEyK.css", - "assets/Counter-BZpJq_HD.css", - ], - "components/DeepSubCounter/DeepSubCounter.tsx" => [ - "assets/rsc-DeepSubCounter-DqMovEyK.css", - ], - "components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx" => [], - "components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx" => [], - "components/RandomNumberServerCell/UpdateRandomButton.tsx" => [], - "components/SubCounter/SubCounter.tsx" => [ - "assets/rsc-SubCounter-Bc4odF6o.css", - "assets/rsc-DeepSubCounter-DqMovEyK.css", - ], - "components/UserExample/NewUserExample/NewUserExample.tsx" => [], - "components/UserExample/UserExample/UserExample.tsx" => [], - "components/UserExample/UserExamples/UserExamples.tsx" => [], - "components/UserExample/UserExamplesCell/UserExamplesCell.tsx" => [], - "entry.client.tsx" => [ - "assets/rwjs-client-entry-79N3uomO.css", - ], - } - `) - }) - - it('correctly splits client and server components', () => { - const { serverComponentImports, clientComponentImports } = - splitClientAndServerComponents(clientEntryFiles, componentImportMap) - - expect(serverComponentImports).toMatchInlineSnapshot(` - Map { - "/Users/mojombo/rw-app/web/src/entry.server.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/App.tsx", - "/Users/mojombo/rw-app/web/src/Document.tsx", - ], - "/Users/mojombo/rw-app/web/src/entries.ts" => [ - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/entries.js", - ], - "/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplesPage/UserExamplesPage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/NewUserExamplePage/NewUserExamplePage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplePage/UserExamplePage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleServerCell/UserExampleServerCell.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.css" => [], - "/Users/mojombo/rw-app/web/src/index.css" => [], - "/Users/mojombo/rw-app/web/src/scaffold.css" => [], - "/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.css" => [], - "/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx" => [ - "react/jsx-runtime", - ], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/actions.ts" => [ - "/Users/mojombo/rw-app/web/src/pages/HomePage/words.ts", - ], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts" => [], - "/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx" => [ - "react/jsx-runtime", - ], - "/Users/mojombo/rw-app/web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx" => [ - "react/jsx-runtime", - ], - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css" => [], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css" => [], - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/words.ts" => [ - "/Users/mojombo/rw-app/node_modules/server-only/index.js", - ], - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css" => [], - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css" => [], - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/humanize-string/index.js", - ], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/cell/createServerCell.js", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.css", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleServerCell/UserExampleServerCell.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/cell/createServerCell.js", - "/Users/mojombo/rw-app/api/src/lib/db.ts", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/forms/dist/index.js", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/forms/dist/index.js", - ], - "/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js", - "/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx", - "/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.css", - ], - "/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.tsx", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx", - "/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.css", - ], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@tobbe.dev/rsc-test/dist/rsc-test.es.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/assets.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/fully-react/rwRscGlobal.js", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx", - "/Users/mojombo/rw-app/web/src/pages/HomePage/actions.ts", - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.module.css", - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.css", - ], - "/Users/mojombo/rw-app/web/src/Document.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - ], - "/Users/mojombo/rw-app/web/src/App.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/apollo/suspense.js", - "/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx", - "/Users/mojombo/rw-app/web/src/Routes.tsx", - "/Users/mojombo/rw-app/web/src/index.css", - "/Users/mojombo/rw-app/web/src/scaffold.css", - ], - "/Users/mojombo/rw-app/web/src/Routes.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/vite/dist/client.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.tsx", - "/Users/mojombo/rw-app/web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx", - "/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx", - ], - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.css", - ], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx", - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx", - ], - } - `) - expect(clientComponentImports).toMatchInlineSnapshot(` - Map { - "/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx" => [ - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css", - ], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts", - ], - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx" => [ - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/node_modules/client-only/index.js", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css", - ], - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx" => [ - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/node_modules/client-only/index.js", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css", - ], - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx" => [ - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/node_modules/client-only/index.js", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css", - ], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/GraphQLHooksProvider.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx" => [ - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx", - ], - } - `) - }) - - it('correctly generates server to client component mapping', () => { - const serverComponentImports = new Map() - const clientComponentImports = new Map() - const clientComponentIds = Object.values(clientEntryFiles) - for (const [key, value] of componentImportMap.entries()) { - if (clientComponentIds.includes(key)) { - clientComponentImports.set(key, value) - } else { - serverComponentImports.set(key, value) - } - } - - const serverComponentClientImportIds = - generateServerComponentClientComponentMapping( - serverComponentImports, - clientComponentImports, - ) - - expect(serverComponentClientImportIds).toMatchInlineSnapshot(` - Map { - "/Users/mojombo/rw-app/web/src/entry.server.tsx" => [], - "/Users/mojombo/rw-app/web/src/entries.ts" => [], - "/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplesPage/UserExamplesPage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamplesCell/UserExamplesCell.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExamples/UserExamples.tsx", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/components/GraphQLHooksProvider.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/NewUserExamplePage/NewUserExamplePage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/UserExample/NewUserExample/NewUserExample.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/UserExample/UserExamplePage/UserExamplePage.tsx" => [], - "/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/EmptyUser/NewEmptyUser/NewEmptyUser.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx", - ], - "/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.css" => [], - "/Users/mojombo/rw-app/web/src/index.css" => [], - "/Users/mojombo/rw-app/web/src/scaffold.css" => [], - "/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.css" => [], - "/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/actions.ts" => [], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts" => [], - "/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx" => [], - "/Users/mojombo/rw-app/web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx" => [], - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css" => [], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css" => [], - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.css" => [], - "/Users/mojombo/rw-app/web/src/pages/HomePage/words.ts" => [], - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css" => [], - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css" => [], - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css" => [], - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx" => [], - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/RandomNumberServerCell.tsx" => [], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleServerCell/UserExampleServerCell.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExample/UserExample.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/toast/index.js", - "/Users/mojombo/rw-app/web/src/lib/formatters.tsx", - ], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUserForm/EmptyUserForm.tsx" => [], - "/Users/mojombo/rw-app/web/src/components/UserExample/UserExampleForm/UserExampleForm.tsx" => [], - "/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/Counter/AboutCounter.tsx", - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx", - "/Users/mojombo/rw-app/node_modules/client-only/index.js", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css", - ], - "/Users/mojombo/rw-app/web/src/pages/MultiCellPage/MultiCellPage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/UpdateRandomButton.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/web/src/components/RandomNumberServerCell/actions.ts", - ], - "/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.tsx", - "react/jsx-runtime", - "react", - "/Users/mojombo/rw-app/node_modules/client-only/index.js", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.tsx", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.tsx", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.module.css", - "/Users/mojombo/rw-app/web/src/components/DeepSubCounter/DeepSubCounter.css", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.module.css", - "/Users/mojombo/rw-app/web/src/components/SubCounter/SubCounter.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.module.css", - "/Users/mojombo/rw-app/web/src/components/Counter/Counter.css", - ], - "/Users/mojombo/rw-app/web/src/Document.tsx" => [], - "/Users/mojombo/rw-app/web/src/App.tsx" => [], - "/Users/mojombo/rw-app/web/src/Routes.tsx" => [], - "/Users/mojombo/rw-app/web/src/layouts/NavigationLayout/NavigationLayout.tsx" => [], - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx" => [ - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsersCell/EmptyUsersCell.tsx", - "react/jsx-runtime", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/web/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/node_modules/graphql-tag/lib/index.js", - "/Users/mojombo/rw-app/node_modules/@redwoodjs/router/dist/index.js?commonjs-es-import", - "/Users/mojombo/rw-app/web/src/components/EmptyUser/EmptyUsers/EmptyUsers.tsx", - ], - } - `) - }) -}) - From 07e199c7fc6da814436361b40a24c7f4670bd847 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 7 May 2024 03:35:13 +0100 Subject: [PATCH 4/6] minor refactoring --- packages/vite/src/rsc/rscCss.ts | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/vite/src/rsc/rscCss.ts b/packages/vite/src/rsc/rscCss.ts index b63f59999449..efd8dd14fd4a 100644 --- a/packages/vite/src/rsc/rscCss.ts +++ b/packages/vite/src/rsc/rscCss.ts @@ -11,6 +11,7 @@ export function getRscStylesheetLinkGenerator(existingLinks: string[]) { const clientBuildManifest = JSON.parse( fs.readFileSync(clientBuildManifestPath, 'utf-8'), ) + const clientCss = extractCssMappingFromManifest(clientBuildManifest) const serverBuildManifestPath = path.join( getPaths().web.distRsc, @@ -19,32 +20,25 @@ export function getRscStylesheetLinkGenerator(existingLinks: string[]) { const serverBuildManifest = JSON.parse( fs.readFileSync(serverBuildManifestPath, 'utf-8'), ) - - const clientCss = generateCssMapping(clientBuildManifest) - const serverCss = generateCssMapping(serverBuildManifest) + const serverCss = extractCssMappingFromManifest(serverBuildManifest) const allCss = new Set() - for (const [_, value] of clientCss) { - if (value.length > 0) { - for (const css of value) { - allCss.add(css) - } + for (const cssList of clientCss.values()) { + for (const css of cssList) { + allCss.add(css) } } - for (const [_, value] of serverCss) { - if (value.length > 0) { - for (const css of value) { - allCss.add(css) - } + for (const cssList of serverCss.values()) { + for (const css of cssList) { + allCss.add(css) } } const cssLinks = Array.from(allCss) - return () => [...existingLinks, ...cssLinks] } -function generateCssMapping(manifest: any) { +function extractCssMappingFromManifest(manifest: Record) { const manifestCss = new Map() const lookupCssAssets = (id: string): string[] => { const assets: string[] = [] From 9c6684b435e7e795e305b559935a218878a0c9d1 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Sat, 11 May 2024 11:31:24 +0200 Subject: [PATCH 5/6] Make existingLinks optional --- packages/vite/src/clientSsr.ts | 2 +- packages/vite/src/rsc/rscCss.ts | 4 ++-- packages/vite/src/runFeServer.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/clientSsr.ts b/packages/vite/src/clientSsr.ts index 86493b9d0cb4..cddc1b6dc110 100644 --- a/packages/vite/src/clientSsr.ts +++ b/packages/vite/src/clientSsr.ts @@ -98,7 +98,7 @@ export function renderFromDist>( ) { console.log('renderFromDist rscId', rscId) - const cssLinks = getRscStylesheetLinkGenerator([])() + const cssLinks = getRscStylesheetLinkGenerator()() // Create temporary client component that wraps the component (Page, most // likely) returned by the `createFromReadableStream` call. diff --git a/packages/vite/src/rsc/rscCss.ts b/packages/vite/src/rsc/rscCss.ts index efd8dd14fd4a..9b1f67cb34f3 100644 --- a/packages/vite/src/rsc/rscCss.ts +++ b/packages/vite/src/rsc/rscCss.ts @@ -3,7 +3,7 @@ import path from 'node:path' import { getPaths } from '@redwoodjs/project-config' -export function getRscStylesheetLinkGenerator(existingLinks: string[]) { +export function getRscStylesheetLinkGenerator(existingLinks?: string[]) { const clientBuildManifestPath = path.join( getPaths().web.distClient, 'client-build-manifest.json', @@ -35,7 +35,7 @@ export function getRscStylesheetLinkGenerator(existingLinks: string[]) { } const cssLinks = Array.from(allCss) - return () => [...existingLinks, ...cssLinks] + return () => [...(existingLinks || []), ...cssLinks] } function extractCssMappingFromManifest(manifest: Record) { diff --git a/packages/vite/src/runFeServer.ts b/packages/vite/src/runFeServer.ts index 05298bfc7a4a..8c46954120b0 100644 --- a/packages/vite/src/runFeServer.ts +++ b/packages/vite/src/runFeServer.ts @@ -150,7 +150,7 @@ export async function runFeServer() { const clientEntryPath = '/' + clientEntry.file const getStylesheetLinks = rscEnabled - ? getRscStylesheetLinkGenerator(clientEntry.css ?? []) + ? getRscStylesheetLinkGenerator(clientEntry.css) : () => clientEntry.css || [] const routeHandler = await createReactStreamingHandler({ From 5b3f87f81661176e190748e120a1ea622bf95680 Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Sat, 11 May 2024 14:56:30 +0100 Subject: [PATCH 6/6] add note in code --- packages/vite/src/rsc/rscCss.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/vite/src/rsc/rscCss.ts b/packages/vite/src/rsc/rscCss.ts index 9b1f67cb34f3..5424aed9fd4a 100644 --- a/packages/vite/src/rsc/rscCss.ts +++ b/packages/vite/src/rsc/rscCss.ts @@ -3,6 +3,14 @@ import path from 'node:path' import { getPaths } from '@redwoodjs/project-config' +// Note: The current implementation here simply aggregates all CSS but inspecting +// the manifest files produced during build. In the future we may wish to move to +// a technique that does not rely on build artifacts. +// We may also wish to look at more sophisticated techniques for selecting specific +// CSS files based on the component(s) being rendered rather than just aggregating +// all CSS. Previously we attempted to inject `preinit` calls into the components +// via a vite plugin but this was reverted due to issues with writing to closed +// streams - which was too difficult to resolve at that time. export function getRscStylesheetLinkGenerator(existingLinks?: string[]) { const clientBuildManifestPath = path.join( getPaths().web.distClient,