Using renderToString in node

I have a file that looks roughly like this:
import { renderToString } from "solid-js/web"

...

const htmlString = renderToString(() => (
<PageComponent />
))
import { renderToString } from "solid-js/web"

...

const htmlString = renderToString(() => (
<PageComponent />
))
How can I run this in node? What configuration, etc., would I need?
4 Replies
thetarnav
thetarnav17mo ago
not sure if you need anything special to just run it in node I'm using renderToString to test components in "SSR" and it "just works" but I guess that's in vitest, so it has something configured like the babel plugin
foolswisdom
foolswisdom17mo ago
Yeah, maybe what I'm missing is the babel plugin
thetarnav
thetarnav17mo ago
no idea how to add it to node, but the only setting it needs to work there would be { generate: "ssr" } I think
foolswisdom
foolswisdom17mo ago
There isn't really a practical way to do this. There is @babel/node, but I need it to treat everything as ESM modules, which it won't for some reason Problem seems to be that I don't have type: module set, but unfortunately I don't think I can set it...