fix: server functions inclusivity + runtime exports#2127
fix: server functions inclusivity + runtime exports#2127
Conversation
|
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
| export function cloneServerReference<T extends any[], R>({ id, fn }: Registration<T, R>) { | ||
| if (typeof fn !== "function") | ||
| throw new Error("Export from a 'use server' module must be a function"); | ||
| let baseURL = import.meta.env.BASE_URL ?? "/"; |
There was a problem hiding this comment.
Running this branch in dev (with vite 8) I now get the following error 🙈:
TypeError: Cannot read properties of undefined (reading 'BASE_URL') at query (file:///...node_modules/.pnpm/...@solidjs/start/dist/fns/server.js:12:35)
There was a problem hiding this comment.
@katywings got that initially too, but I tried running again and it worked. Did you also try clearing node_modules?
There was a problem hiding this comment.
Just did a full clear and multiple restarts of the dev server, the error occurs every time 🤔
There was a problem hiding this comment.
I think it might be some duplicated code being run here yet again. A top level console.log in registrations is executed twice during server init. I do only have one @solidjs/start in node_modules though... Not sure yet where the second instance is coming from - but I do have some idea, let me check...
There was a problem hiding this comment.
Yeah no... If I had to guess my thesis is that this has something to do with the whole server functions preload shenanigans, if the preload means that the code doesn't go through vite's loading behavior that might by the reason for duplicate instances and also for missing import.meta.env. Unfortunately I do not really have the time right now to dig deeper 😅
I've also moved and renamed server fn files since the current ones are too confusing