nksaraf / vinxi

The Full Stack JavaScript SDK
https://vinxi.vercel.app
MIT License
1.33k stars 56 forks source link

example react RSC SSR / build is broken #241

Open aheissenberger opened 4 months ago

aheissenberger commented 4 months ago

Error:

node .output/server/index.mjs    
Listening on http://[::]:3000
[nitro] [request error] [unhandled] Cannot read properties of undefined (reading 'server')
  at Object.handler (./.output/server/chunks/runtime.mjs:5962:56)  
  at Object.handler (./.output/server/chunks/runtime.mjs:2822:31)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async Server.toNodeHandle (./.output/server/chunks/runtime.mjs:3088:7)

The getManifest("ssr") does not return a dev property. https://github.com/nksaraf/vinxi/blob/618149b312423742b8fe592869181ce2aef77744/examples/react/rsc/ssr/app/server.tsx#L38

nksaraf commented 4 months ago

the latest vinxi (0.3.10) has the fix for this, could you try that version?

aheissenberger commented 4 months ago

The error exists with "vinxi": "0.3.10" and I am using a clone of the current main branch with commit 618149b312423742b8fe592869181ce2aef77744.

I did deleted the node_modul folder and build the project before I tried the examples. I tried the example outside the mono repo.

This is a console.log output of the console.log('getManifest("ssr")',getManifest("ssr")) in app/server.tsx:38 in the eventHandler - with no dev property:

export default eventHandler(async (event) => {
    console.log('getManifest("ssr")',getManifest("ssr"))
    globalThis.__vite__ = createModuleLoader(getManifest("ssr").dev.server);

output:

 {
  handler: 'app/server.tsx',
  assets: [AsyncFunction: assets],
  routes: [AsyncFunction: routes],
  json: [AsyncFunction: json],
  chunks: {},
  inputs: {}
}

Here is my build process:

pnpm build                    

> react-rsc-ssr@ build /vinxi-ssr
> vinxi build

vinxi v0.3.10

┌────────────────────────────┐
│ ⚙  Building your app...    │
└────────────────────────────┘
removing /vinxi-ssr/.vinxi/build/rsc
removing /vinxi-ssr/.vinxi/build/ssr
removing /vinxi-ssr/.vinxi/build/client
removing /vinxi-ssr/.vinxi/build/server

┌───────────────────────────────┐
│ 📦 Compiling rsc router...    │
└───────────────────────────────┘
vinxi building router rsc in http mode
vite v5.1.5 building SSR bundle for production...
✓ 54 modules transformed.
.vinxi/build/rsc/_rsc/server-components-manifest.json    0.14 kB
.vinxi/build/rsc/_rsc/.vite/manifest.json                0.27 kB
.vinxi/build/rsc/_rsc/assets/rsc-Bx8cIa-P.css            4.70 kB
.vinxi/build/rsc/_rsc/c_4958.mjs                        13.05 kB
.vinxi/build/rsc/_rsc/rsc.mjs                          209.49 kB
✓ built in 739ms
✔ build done                                                                                                                               9:55:16 AM

┌───────────────────────────────┐
│ 📦 Compiling ssr router...    │
└───────────────────────────────┘
vinxi building router ssr in http mode
vite v5.1.5 building SSR bundle for production...
✓ 5 modules transformed.
.vinxi/build/ssr/.vite/manifest.json  0.12 kB
.vinxi/build/ssr/ssr.js               3.04 kB
✓ built in 18ms
✔ build done                                                                                                                               9:55:16 AM

┌──────────────────────────────────┐
│ 📦 Compiling client router...    │
└──────────────────────────────────┘
vinxi building router client in client mode
vite v5.1.5 building for production...
app/Counter.tsx (1:0) Error when using sourcemap for reporting an error: Can't resolve original location of error.
virtual:#vinxi/handler/client (1:96) "default" is not exported by "app/client.tsx", imported by "virtual:#vinxi/handler/client".
✓ 49 modules transformed.
.vinxi/build/client/_build/server-functions-manifest.json    0.03 kB │ gzip:  0.04 kB
.vinxi/build/client/_build/.vite/manifest.json               0.43 kB │ gzip:  0.19 kB
.vinxi/build/client/_build/c_4941.mjs                        0.24 kB │ gzip:  0.21 kB
.vinxi/build/client/_build/assets/jsx-runtime-B0mOhSSs.js    9.78 kB │ gzip:  3.52 kB
.vinxi/build/client/_build/entry.mjs                       190.64 kB │ gzip: 60.65 kB
✓ built in 334ms
✔ build done                                                                                                                               9:55:16 AM

┌──────────────────────────────────┐
│ 📦 Compiling server router...    │
└──────────────────────────────────┘
vinxi building router server in http mode
vite v5.1.5 building SSR bundle for production...
✓ 31 modules transformed.
.vinxi/build/server/_server/.vite/manifest.json    0.28 kB
.vinxi/build/server/_server/entry.mjs              0.96 kB
.vinxi/build/server/_server/server.node.mjs      204.64 kB
✓ built in 349ms
✔ build done                                                                                                                               9:55:17 AM

┌────────────────────────────────────────┐
│ ⚙  Preparing app for node-server...    │
└────────────────────────────────────────┘
✔ Generated public .output/public                                                                                                    vinxi 9:55:17 AM
ℹ Building Nitro Server (preset: node-server)                                                                                        vinxi 9:55:17 AM
✔ Nitro Server built                                                                                                                 vinxi 9:55:19 AM
✔ You can preview this build using node .output/server/index.mjs     

Thank you for this great project!

nksaraf commented 4 months ago

ohh still errors let me check, I must have screwed something up somewhere

andrewangelle commented 2 months ago

@nksaraf +1 on this. Still broken on vinxi (0.3.11)