How to remove a client-specific thing from server bundle
I have say a chat app, and want to remove Markdown entirely from my server bundle since it is 1MB+ of JS (react markdown, syntax highlighters, katex, so on) which is polluting my server bundle when absolutely no markdown is actually rendered in SSR...
I tried using React.lazy(), but this still includes them in the server bundle output (I'm using
cloudflare-module output format)12 Replies
correct-apricot•4mo ago
is the route marked with ssr:false?
if yes we could remove the component from the server build then
not implemented yet but doable
robust-apricotOP•4mo ago
it's not exactly a route
asin it's on the / route, my data layer is convex and i don't ssr convex data so i know that say i won't have the messages in SSR anyway (only once the client connects to the WS will i have the data)
so i wanted some way to inside my tree, exclude the component that goes on to say import markdown from the bundle
without specifically being a route, so that / and other pages can still SSR
correct-apricot•4mo ago
unclear to me what the setup looks like. can you share a complete example project to show what this looks like?
dependent-tan•4mo ago
📍 interested in hearing how this conversation goes. 👂
robust-apricotOP•4mo ago
hmm, looks like i might have got it to work
robust-apricotOP•4mo ago

robust-apricotOP•4mo ago

robust-apricotOP•4mo ago
GitHub
GitHub - f1shy-dev/start-bare-ssr-module-demo
Contribute to f1shy-dev/start-bare-ssr-module-demo development by creating an account on GitHub.
correct-apricot•4mo ago
you can also use our ClientOnly component instead of handling the useHydration hook yourself
robust-apricotOP•4mo ago
do you have any idea why the title flashes?
robust-apricotOP•4mo ago
robust-apricotOP•4mo ago
happens in dev and build
ok i think that's just react internally suspending while the lazy() import loads