Eliminate code on Client-side in React Js

Viewed 52

I need help in one of my project. (React based)

scenario : In my project file A has code in which some portion of code utilise on SSR and some on CSR.

Problem facing : when bundling the project(app-shell), in CSR also i am seeing the SSR code.

Goal: Eliminate SSR code when render on CSR. (react based solution) similar behaviour like vercel nextjs: https://next-code-elimination.vercel.app/

please do let me know how to achieve or any reference link would be helpful.

1 Answers
  • used a flag isServer in webpack config and set it to false as default.

  • determine on the basis of proess.isServer

  • Tried AST approach to eliminate the server side code

Related