Nextjs app and pages router bundle size
Unanswered
Narrow-barred Spanish mackerel posted this in #help-forum
Narrow-barred Spanish mackerelOP
Hi everyone,
In my production app, I'm currently using the Pages Router. To experiment with the App Router, I created an app directory with a simple SSR page that fetches some data from the server — no external imports other than Next.js itself.
However, when I build the app, I noticed that the Webpack bundle for the new App Router page still includes some code from my Pages Router application. Specifically, it pulls in parts of the main app chunk or other common modules from the pages directory, even though they aren't directly imported anywhere in my new App Router page.
Could someone explain how bundling and code splitting work when using both App Router and Pages Router in the same project?
Is it expected that common chunks from the Pages Router side get included when an App Router page is loaded? How can I better control or optimize this?
Thanks in advance for your help!
In my production app, I'm currently using the Pages Router. To experiment with the App Router, I created an app directory with a simple SSR page that fetches some data from the server — no external imports other than Next.js itself.
However, when I build the app, I noticed that the Webpack bundle for the new App Router page still includes some code from my Pages Router application. Specifically, it pulls in parts of the main app chunk or other common modules from the pages directory, even though they aren't directly imported anywhere in my new App Router page.
Could someone explain how bundling and code splitting work when using both App Router and Pages Router in the same project?
Is it expected that common chunks from the Pages Router side get included when an App Router page is loaded? How can I better control or optimize this?
Thanks in advance for your help!