#Remove node_modules used in SSG from client bundle
12 messages · Page 1 of 1 (latest)
If you would be able to do this work inside your getStaticProps/getServersideProps function, Next.js will automatically not include this node module in the final client side bundle. But not sure if this will be possible for react-markdown..
I tried to, but I doesnt seem like I can render jsx inside getserveside props, I am not sure tho?
Hm no I’m afraid not…
Maybe there is a webpack config or smth to exclude the module from bundle? The webpack docs are a nigjtmare to navigate, I can't find it.
its not possible at the moment
you need to be able to rehydrate the page in the client so the library is necessary
the only exception is if you render the entire thing at once and dont care for interactivity afterwards
then you can render the JSX inside gSP/gSSP and send the built HTML as props to the page
How to do that exactly, I tried but it doesnt seem to work
Ps. The only method that worked was to use ReactDOMServer.renderToStaticMarkup() which returned an html string
yeah thats exactly how you do it