Skip to content

optimizePackageImports no longer functional in v14 #57624

Description

@mwskwong

Link to the code that reproduces this issue

https://github.com/mwskwong/optimize-package-imports-bug

To Reproduce

  1. Create a Next.js project
  2. Import any MUI component (Button in the example) using named import to page.tsx
  3. 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

  • I verified that the issue exists in the latest Next.js 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

Metadata

Metadata

Assignees

Labels

bugIssue was opened via the bug report template.linear: nextConfirmed issue that is tracked by the Next.js team.locked

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions