solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.1k stars 137 forks source link

SSR no matching exports #415

Closed QuentinDutot closed 3 weeks ago

QuentinDutot commented 2 months ago

Describe the bug

I'm doing SSR with hono, I use both renderToStringAsync from solid-js/web and Router from @solidjs/router in the pages I want to render on the server. I get following errors:

error: No matching export in "node_modules/solid-js/web/dist/server.js" for import "memo"
at ./node_modules/@solidjs/router/dist/index.js:1:75,

error: No matching export in "node_modules/solid-js/web/dist/server.js" for import "template"
at ./node_modules/@solidjs/router/dist/index.js:1:133

The hack I use is to replace import { Router } from '@solid-js/router' with import { Router } from './node_modules/@solidjs/router/dist/index.jsx'

And so for every imports from @solidjs/router or to create a file that imports everything from node_modules and re-exports it.

Your Example Website or App

^

Steps to Reproduce the Bug or Issue

^

Expected behavior

^

Screenshots or Videos

No response

Platform

Additional context

No response

ryansolid commented 3 weeks ago

It looks like you are getting the client version of router on the server. I'm not sure of your build process but you want to make sure the "solid" export condition is set so that it pulls in source and builds it correctly per environment. Like Vue or Svelte we don't tend to precompile libraries since there can be multiple outputs from the templating. We do precompile a build with the router to support no build environments but the combinatorics start getting prohibitive in other (SSR) scenarios.

I'm going to close the issue as it doesn't appear to be a router bug, but et me know if you need additional help setting this up.