Open wottpal opened 1 day ago
Disclaimer¹: Sorry for opening all the issues recently, I'm a big fan and just want content-collections to become as good as possible!
No problem; I am grateful when a problem is found and reported.
I'm not sure what i can do when next.js includes content collections twice, but i don't think that this is a problem in the most cases. Its hard to tell which entry point uses which bundle in a next.js application. I think it only becomes a problem if it is in the client bundle. In the case of sitemap and manifest is mostly no problem, because it is generated static at build time.
Disclaimer¹: Sorry for opening all the issues recently, I'm a big fan and just want content-collections to become as good as possible! Disclaimer²: This issue might be Next.js (or even only Next.js v15 related). I'm happy to open a ticket there after hearing your thoughts.
When importing
allPages
fromcontent-collection
in eithermanifest.ts
orsitemap.ts
(the latter is quite common to build a sitemap of your content), the analyzed bundle size* doubles in it's size because the generated.json
is somehow included twice and not deduped correctly. In big projects, where this .json file can grow up to multiple Megabytes, this becomes quite noticeable and could potentially reduce SSR/SSG speeds.*I'm speaking of the Node.js bundle size (the environment where the sitemap but also pages are generated). Next.js differentiates between Node.js|Edge|Client bundle sizes.
Reproduction
You can reproduce it with the same boilerplate project I shared in #309 as shown below. (Btw. if there are more potential contributors, I'm happy to set this to public or invite them as well).
Sample screenshots
Bundle without
src/app/sitemap.ts
&src/app/manifest.ts
:Bundle with
src/app/sitemap.ts
&src/app/manifest.ts
: