Closed atresnjo closed 2 years ago
Does your svelte.config.js have the following? Notably, adding superjson
to the ssr.noExternal
array in production.
kit: {
adapter: adapter(),
vite:
process.env.NODE_ENV === 'production'
? {
ssr: {
noExternal: ['superjson']
}
}
: undefined
}
From this section of the docs.
Yeah. I'm using this repo. 👍
The reason I asked is because when I comment out the enitre vite
property, I get the exact same issue you're getting in the screenshot. To eliminate if your original issue is caused by this, try forcing the condition to true and see if it builds:
kit: {
adapter: adapter(),
vite:
- process.env.NODE_ENV === 'production'
+ true || process.env.NODE_ENV === 'production'
? {
ssr: {
noExternal: ['superjson']
}
}
: undefined
}
That worked, thank you very much. Obviously, I would need to set NODE_ENV to production, for it to work. Duh me, thanks again!
Thanks for clearing things out, @ambiguous48!
It's in the trpc-sveltekit docs: https://github.com/icflorescu/trpc-sveltekit#configure-superjson-to-correctly-handle-decimaljs--prismadecimal
To all: do you have any suggestion on how to make this clearer?
The issue wasn't missing documentation, in my opinion, just a slight oversight not seeing that the NODE_ENV environment variable is not being set anywhere. Maybe for this example just have the build script set the environment variable?
"build": "cross-env NODE_ENV=production && svelte-kit build",
The issue wasn't missing documentation, in my opinion, just a slight oversight not seeing that the NODE_ENV environment variable is not being set anywhere. Maybe for this example just have the build script set the environment variable?
"build": "cross-env NODE_ENV=production && svelte-kit build",
I don't know, is it really necessary? I was under the impression that NODE_ENV
was automatically set to production
when running svelte-kit build
...
The issue wasn't missing documentation, in my opinion, just a slight oversight not seeing that the NODE_ENV environment variable is not being set anywhere. Maybe for this example just have the build script set the environment variable?
"build": "cross-env NODE_ENV=production && svelte-kit build",
I don't know, is it really necessary? I was under the impression that
NODE_ENV
was automatically set toproduction
when runningsvelte-kit build
...
Yep, I thought the same. My env could be somehow broken, at least it didn't set it for me.
Hey, thanks for the great work on setting everything up! Wanted to give tRPC with SvelteKit a try, but the example doesn't build. It works fine when ran locally, but the build itself fails.
Thanks! 💯