Open Nickersoft opened 2 years ago
If you're creating an SPA, there's no runtime on the server, just some static files that are returned when they are requested specifically. This means that +layout.server.js
can't work when not prerendered, as there's neither a server runtime nor a prerendered __data.json
output. So this behavior is intended, although it would be nice to somehow detect this better and throw a more meaningful error, ideally earlier on, or at least document this somehow.
Yeah, I figured as much :/ From what I can tell, it looks like as long as there is a .server.ts
file, even if there's nothing in it, the site will break. Agreed it would be nice to have a way to catch this earlier or avoid it altogether without just removing the whole file. Took me quite a long while to debug, as I didn't know why it would be looking for a __data.json
file as an SPA haha.
@dummdidumm Is there any kind of workaround for this? Is my only option temporarily renaming +layout.server.js
during the build and then naming it back afterwards? I realized even the mere existence of +layout.server.js
causes the output to look for a __data.json
file.
"the mere existinnce of a layout.server causes to look for a __data file" is tracked in #7967
Describe the bug
Hey folks,
I ran into a bit of an edge-case recently while trying to make a hybrid web + Tauri application (web uses
adapter-node
, Tauri creates an SPA usingadapter-static
). If there exists a+page.server.js
or+layout.server.js
file that exports aload()
function, running the SPA via a basic web server will throw a 500 internal error, complaining that/__data.json
cannot be found. I'm curious if this is an intended bug or if there is a workaround to it.Reproduction
pnpm install
.pnpm build
.http-server build
).Moving or deleting the
+layout.server.js
file will fix the issue.Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
Obviously this isn't completely blocking, from a web standpoint, but it is blocking me from creating a production build of my Tauri app, as I can't create the SPA and my web version (which SSR'd) needs the cookie information passed from
+layout.server.js
.