-
Notifications
You must be signed in to change notification settings - Fork 29k
Description
Link to the code that reproduces this issue
https://github.com/gonmpablo/NextDynamicIssue
To Reproduce
Next.js 14:
Go to this URL: https://next-dynamic-issue-git-ec7cb0-pablo-gonzalez-martinezs-projects.vercel.app/
Observe: Only the used component’s chunk is included in the client bundle.
Next.js 15:
Go to this URL: https://next-dynamic-issue-git-09c334-pablo-gonzalez-martinezs-projects.vercel.app/
Observe: Both chunks for ClientA and ClientB are included, despite the conditional rendering
Current vs. Expected behavior
Current (Next.js 15):
When using next/dynamic() to conditionally import two client components (e.g., ClientA, ClientB), both chunks are sent to the client, even though only one is rendered at runtime.
Expected (Next.js 14 behavior):
Only the chunk of the component actually rendered should be sent to the client. This was working correctly in v14 and helped significantly reduce TBT.
Provide environment information
NEXT JS 15:
{
"dependencies": {
"next": "15.3.3",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint/eslintrc": "^3",
"@next/bundle-analyzer": "^15.3.3",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "15.3.3",
"typescript": "^5"
}
}
NEXT JS 14:
{
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
"next": "14.2.28"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@next/bundle-analyzer": "14.2.28",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"eslint-config-next": "14.2.28",
"@eslint/eslintrc": "^3"
}
}
Which area(s) are affected? (Select all that apply)
dynamicIO, Performance
Which stage(s) are affected? (Select all that apply)
Other (Deployed), Vercel (Deployed), next start (local), next build (local), next dev (local)
Additional context
Could be something related to this change? #65486