Client components make bundle size huge #67386
Labels
bug
Issue was opened via the bug report template.
create-next-app
Related to our CLI tool for quickly starting a new Next.js application.
Performance
Anything with regards to Next.js performance.
Webpack
Related to Webpack with Next.js.
Link to the code that reproduces this issue
https://github.com/pepew-le-boss/nextjs-bundle-size-icon-component
To Reproduce
readme.md
client.html
generated by the bundle analyzerCurrent vs. Expected behavior
The bundle size should be optimized but that's not the case
Provide environment information
Which area(s) are affected? (Select all that apply)
create-next-app, Performance, Webpack
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
Repo here: https://github.com/pepew-le-boss/nextjs-bundle-size-icon-component
When building the app with the bundle analyzer, under certain conditions the Icon.tsx chunk (in the client.html) has a huge parsed size (to better view the chunk choose the "Stat" view).
Here's the explanation:
You can find in the code an Icon.tsx component that looks like this:
Then it can be used like this:
When used is server components, there are no problems.
When imported in a client component, a chunk
Icon.tsx
is created with an optimized parsed size (stat size: 195kB / parsed size: 1kB).For example:
And then used like this:
However, when at least another client component that is importing
Icon.tsx
is used anywhere in the app, the bundle analyzer shows that theIcon.tsx
chunk is not optimized at all (stat size: 195kB / parsed size: 168kB).For example:
Is it a normal behavior ? Is there a way to fix that ?
The text was updated successfully, but these errors were encountered: