Skip to content

Tree-shaking with getInitialProps? #12607

Answered by timneutkens
mrassili asked this question in Help
Discussion options

You must be logged in to vote

Tree shaking is enabled in Next.js through webpack automatically. You don't need to configure anything to leverage it, it works automatically. As @rafaelalmeidatk said tree shaking of the data fetching solution was previously not possible because of the way getInitialProps was ran server and client side. getStaticProps/getServerSideProps are tree shaken from the browser bundle, which allows you to use any Node.js apis there.

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@willemliu
Comment options

Comment options

You must be logged in to vote
2 replies
@neo
Comment options

@Timer
Comment options

Answer selected by timneutkens
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
6 participants