Sign in

Full-Stack Developer. Cyber-Security Student.

I was trying to reduce the bundle size of the final client bundle, and I found an interesting feature about Next.js. In one file it handles both server and client side code. This is very convenient, however what happens when you import a third party module at the top of the file? Does the client bundle size get increased if the imported module is only used in getStaticProps or getServerSideProps?

For a quick answer, see Conclusions.

Different kinds of imports

There are many ways to import modules and other files in JavaScript, however all methods can be categorized into two main ways: at importing…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store