Bundling in app directory

Unless I'm misunderstanding, in nextjs you could have a site with 99 plain pages and a hidden admin page with a huge bundle and regardless of the page one visits, the bundle for all the pages will be huge. Is that correct and how would you handle this case? Thank you 🙏
6 Replies
Ray
Ray•14mo ago
no it's not correct
Akutō Ventures
Akutō VenturesOP•14mo ago
That's.. interesting, this isn't the behavior im facing. There's a very client-side js heavy page in my project that cannot be SSR'd ( livestreaming, chat solution etc ) and then there's a very simple profile page, completely unrelated. They're both equally huge. A brand new empty single div with no imports page is equally huge.
Ray
Ray•14mo ago
are they sharing one RootLayout and do have a any provider in it? if so, try creating multiple root layout
Ray
Ray•14mo ago
Rhys
Rhys•14mo ago
For long term app quality, I’d recommend splitting the admin app out into its own package anyways It makes keeping bundle size small easier + you only invalidate what changes
Akutō Ventures
Akutō VenturesOP•14mo ago
They are not unfortunately. For the specific use case yes, however I'm trying to understand why next is doing this. It shouldn't right? Are you sure it's not also happening in your apps? I've got no odd configuration or bad import, this is also happening on a brand new page. It feels like next just bundles everything together regardless You can see this happen in a brand new app too. I'm surprised there is no more complaints about this as this makes next have both the downsides of an spa ( bundle the same on all pages ) and an ssr ( reaching out to the network when navigating ) So odd. It's not exaggeration to say this is the worst of both worlds in that respect. Unless again in missing something but i doubt i am, I'll create a repro project so you can see for yourself.
Want results from more Discord servers?
Add your server