T
TanStack4mo ago
robust-apricot

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
correct-apricot4mo 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-apricot
robust-apricotOP4mo 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
correct-apricot4mo ago
unclear to me what the setup looks like. can you share a complete example project to show what this looks like?
dependent-tan
dependent-tan4mo ago
📍 interested in hearing how this conversation goes. 👂
robust-apricot
robust-apricotOP4mo ago
hmm, looks like i might have got it to work
robust-apricot
robust-apricotOP4mo ago
No description
robust-apricot
robust-apricotOP4mo ago
No description
robust-apricot
robust-apricotOP4mo 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
correct-apricot4mo ago
you can also use our ClientOnly component instead of handling the useHydration hook yourself
robust-apricot
robust-apricotOP4mo ago
do you have any idea why the title flashes?
robust-apricot
robust-apricotOP4mo ago
robust-apricot
robust-apricotOP4mo ago
happens in dev and build ok i think that's just react internally suspending while the lazy() import loads

Did you find this page helpful?