Link to the code that reproduces this issue
https://github.com/mwskwong/optimize-package-imports-bug
To Reproduce
- Create a Next.js project
- Import any MUI component (
Button in the example) using named import to page.tsx
- Observe the bundle size
Current vs. Expected behavior
Current
The entire @mui/material is included in the client bundle, despite this package is by default included in optimizePackageImports.
Expect
Only Button and its dependencies are included in the client bundle.
Verify canary release
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Home
Binaries:
Node: 18.17.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.0.1-canary.3
eslint-config-next: 14.0.1-canary.3
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Additional context
Downgrade to Next.js 13.5 to observe the expected behavior.
NEXT-1713
Link to the code that reproduces this issue
https://github.com/mwskwong/optimize-package-imports-bug
To Reproduce
Buttonin the example) using named import topage.tsxCurrent vs. Expected behavior
Current
The entire
@mui/materialis included in the client bundle, despite this package is by default included inoptimizePackageImports.Expect
Only
Buttonand its dependencies are included in the client bundle.Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router
Additional context
Downgrade to Next.js 13.5 to observe the expected behavior.
NEXT-1713