Can't use a bundled SolidJS UI library is SSR/SSG contexts (Astro) #2251
Unanswered
jsimonrichard
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a SolidJS UI component library that I'd like to use in both SSR/SSG (Astro) and client-only contexts. I'm currently using vite to bundle the library, and the client-only scenario works as expected, but I can't figure out how to bundle the library so that it works on the server.
I've tried setting the
ssr
option in the vite pluginsolidPlugin
and makingsolid-js
andsolid-js/web
external through therollupOptions
(all in thevite.config.ts
for the UI library). Each of these options result in different errors on the server when building/running Astro.ssr
set to eithertrue
orfalse
):document
is included in the bundle and is evaluated during the SSG buildsolid-js
is external:Cannot read properties of undefined (reading 'get')
ingetNextElement
solid-js
andsolid-js/web
are external:[vite] The requested module 'solid-js/web' does not provide an export named 'template'
I think all of this is stemming from the fact that the bundled code is still meant for the client, not the server. But I could be wrong.
A few related issues/discussions (a solution from which I've been unable to decipher):
Minimum reproducible example (reproduction steps in
README.md
): https://github.com/jsimonrichard/solid-ssr-ui-lib-issueBeta Was this translation helpful? Give feedback.
All reactions