Stuck On A Build Error
I've been stuck on the following build error all day.
It looks like vinxi/nitro is trying to pre-render "@revenuecat/purchases-capacitor" but failing.
"@revenuecat/purchases-capacitor" is a client-side SDK. If Start is trying to render this on the server, that would be an issue.
That said, I have SSR set to
false
in app.config.ts.
Any help would be appreciated.
Happy to provide more context if needed.19 Replies
How do you use the package?
Do you initialise the package in
onMount
?Yes.
I also added it to a context provider, which would be initialized outside of the "App."
The onMount hasn't been an issue in the past.
How to you add it the context?
Do you have any code you can share?
Of course. Would you like to see the context file?
Are you intending for the nitro preset to be
nitro-prerender
? I'd assume that'd solve the issue of it trying to prerender. (though obviously not if it's needed haha)Well, if I'm being fully honest, I'm not even totally sure what nitro-prerender means.
I think it means, pre-render what you can on the server.
This is a purely client-side application that is using SolidStart and Capacitor JS for mobile apps.
So, technically, nothing needs to happen on the server.
If I can just turn
nitro-prerender
off, that would be fine.
@Madaxen86 , sorry for the length of that file. This project has become very complex so I added a lot of comments to keep myself straight.
Even with npm run dev
I'm getting:
I can't spot anything suspicious.
I've just remmbered: https://discord.com/channels/722131463138705510/722131463889223772/1196442069334495263
"pre-render" requires SSR. Have you tried to build without pre-render?
How do I build without pre-render?
don't you have something like
in your
app.config.ts
?
That's my config file
Oh yeah, that the "pre-rendering" of the
index.html
weird that it this throws the error.
Going on from here you could:
1. try to use clientOnly
to import the component which uses the revenuecat pkg.
2. tweak vite config. (Don't know about this one tbh. Maybe noExternal:["@revenuecat/purchases-capacitor"])Ok, thank you. I'll keep troubleshooting.
You could also do a dynamic import in
onMount
and store it in a signal or something (or maybe a clientOnly resource). Should have the same effect as using clientOnly
for the component but might prevent any weirdness with it getting bundled on the serverMaybe something like this could work? (It's a little weird but hopefully would stop any bundling stuff breaking things) https://playground.solidjs.com/anonymous/acc9dc0a-894d-43b1-baa6-278807e84998
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
I solved it.
I was importing the SupabaseAuthContext outside of a component. 🤦♂️
That took about 7 hours to solve.
It would be helpful if the error referenced the file causing the problem. It may be something to consider for the DX team.
Thanks @Madaxen86 and @Tommypop for helping me narrow down this error.
I usually write the useContext like this:
This way the context is never null/undefined and it prevents me from using it outside of the scope.
Yeah, I wonder if there could be a dev warning in dev if the context is undefined. Might make a PR for it and see what happens
I've made a PR https://github.com/solidjs/solid/pull/2466. Not sure if it's at all necessary but the change was pretty simple so thought I may as well do it and hopefully it'd prevent issues like this in the future :)
@Tommypop MUCH appreciated. Thank you.