Skip to content

Commit 8917ad6

Browse files
authored
Update entry.client and disable vite legacy mode (#8851)
1 parent 0b150eb commit 8917ad6

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

packages/cli/src/commands/experimental/setupRscHandler.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const handler = async ({ force, verbose }) => {
9494
},
9595
},
9696
{
97-
title: 'Updating App.tsx...',
97+
title: 'Overwriting App.tsx...',
9898
task: async () => {
9999
const appTemplate = fs.readFileSync(
100100
path.resolve(__dirname, 'templates', 'rsc', 'App.tsx.template'),
@@ -135,6 +135,24 @@ export const handler = async ({ force, verbose }) => {
135135
})
136136
},
137137
},
138+
{
139+
title: 'Overwrite entry.client.tsx...',
140+
task: async () => {
141+
const entryClientTemplate = fs.readFileSync(
142+
path.resolve(
143+
__dirname,
144+
'templates',
145+
'rsc',
146+
'entry.client.tsx.template'
147+
),
148+
'utf-8'
149+
)
150+
151+
writeFile(rwPaths.web.entryClient, entryClientTemplate, {
152+
overwriteExisting: true,
153+
})
154+
},
155+
},
138156
{
139157
task: () => {
140158
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createRoot } from 'react-dom/client'
2+
3+
import { serve } from '@redwoodjs/vite/client'
4+
5+
const redwoodAppElement = document.getElementById('redwood-app')
6+
7+
const App = serve('App')
8+
9+
const root = createRoot(redwoodAppElement)
10+
root.render(<App name="Redwood RSCc" />)

packages/vite/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ export default function redwoodPluginVite(): PluginOption[] {
170170
manifest: !env.ssrBuild ? 'build-manifest.json' : undefined,
171171
sourcemap: !env.ssrBuild && rwConfig.web.sourceMap, // Note that this can be boolean or 'inline'
172172
},
173-
// To produce a cjs bundle for SSR
174173
legacy: {
175-
buildSsrCjsExternalHeuristics: env.ssrBuild,
174+
buildSsrCjsExternalHeuristics: rwConfig.experimental?.rsc?.enabled
175+
? false
176+
: env.ssrBuild,
176177
},
177178
optimizeDeps: {
178179
esbuildOptions: {

0 commit comments

Comments
 (0)