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
exotic-emerald•2d 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
future-harlequinOP•2d 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
exotic-emerald•2d ago
unclear to me what the setup looks like. can you share a complete example project to show what this looks like?
correct-apricot•2d ago
📍 interested in hearing how this conversation goes. 👂
future-harlequinOP•2d ago
hmm, looks like i might have got it to work
future-harlequinOP•2d ago

future-harlequinOP•2d ago

future-harlequinOP•2d 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.
exotic-emerald•2d ago
you can also use our ClientOnly component instead of handling the useHydration hook yourself
future-harlequinOP•2d ago
do you have any idea why the title flashes?
future-harlequinOP•2d ago
future-harlequinOP•2d ago
happens in dev and build
ok i think that's just react internally suspending while the lazy() import loads