Skip to content

Commit

Permalink
Update entry.client and disable vite legacy mode (#8851)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe committed Jul 7, 2023
1 parent 0b150eb commit 8917ad6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
20 changes: 19 additions & 1 deletion packages/cli/src/commands/experimental/setupRscHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const handler = async ({ force, verbose }) => {
},
},
{
title: 'Updating App.tsx...',
title: 'Overwriting App.tsx...',
task: async () => {
const appTemplate = fs.readFileSync(
path.resolve(__dirname, 'templates', 'rsc', 'App.tsx.template'),
Expand Down Expand Up @@ -135,6 +135,24 @@ export const handler = async ({ force, verbose }) => {
})
},
},
{
title: 'Overwrite entry.client.tsx...',
task: async () => {
const entryClientTemplate = fs.readFileSync(
path.resolve(
__dirname,
'templates',
'rsc',
'entry.client.tsx.template'
),
'utf-8'
)

writeFile(rwPaths.web.entryClient, entryClientTemplate, {
overwriteExisting: true,
})
},
},
{
task: () => {
printTaskEpilogue(command, description, EXPERIMENTAL_TOPIC_ID)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createRoot } from 'react-dom/client'

import { serve } from '@redwoodjs/vite/client'

const redwoodAppElement = document.getElementById('redwood-app')

const App = serve('App')

const root = createRoot(redwoodAppElement)
root.render(<App name="Redwood RSCc" />)
5 changes: 3 additions & 2 deletions packages/vite/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,10 @@ export default function redwoodPluginVite(): PluginOption[] {
manifest: !env.ssrBuild ? 'build-manifest.json' : undefined,
sourcemap: !env.ssrBuild && rwConfig.web.sourceMap, // Note that this can be boolean or 'inline'
},
// To produce a cjs bundle for SSR
legacy: {
buildSsrCjsExternalHeuristics: env.ssrBuild,
buildSsrCjsExternalHeuristics: rwConfig.experimental?.rsc?.enabled
? false
: env.ssrBuild,
},
optimizeDeps: {
esbuildOptions: {
Expand Down

0 comments on commit 8917ad6

Please sign in to comment.