Skip to content

optimizePackageImports does not work with Turbopack #28902

@zhyd1997

Description

@zhyd1997

🐛 Issue Report

Issue Summary

optimizePackageImports configured in next.config.js under apps/web does not appear to take effect when using Turbopack.

https://github.com/calcom/cal.com/blob/a17f28e9ab44d34a24840cff70082470d775b9b1/apps/web/next.config.ts#L236-L238

Based on investigation, this may be because Turbopack's support for optimizePackageImports is not fully implemented yet.

Related discussion: vercel/next.js#75148


Steps to Reproduce

  1. Create a Next.js app using Turbopack (e.g. next dev --turbo)
  2. Configure optimizePackageImports in next.config.js:
module.exports = {
  experimental: {
    optimizePackageImports: ['some-library'],
  },
};
  1. Import from the configured package:
import { Button } from 'some-library';
  1. Start the dev server with Turbopack enabled
  2. Inspect the compiled output or bundle behavior

Actual Results

  • The import is not optimized as expected
  • No transformation or tree-shaking behavior related to optimizePackageImports is observed
  • Behavior appears identical to when the option is not configured

Expected Results

  • Imports should be transformed into per-module imports (or equivalent optimized form)
  • Bundle size / module resolution should reflect optimization
  • Behavior should be consistent with Webpack-based Next.js builds

Technical details

  • Next.js version: (please fill)
  • Turbopack enabled: Yes (next dev --turbo)
  • Node.js version: (please fill)
  • Browser: (please fill)

Additional notes:

  • This may be related to incomplete feature parity between Turbopack and Webpack
  • The behavior aligns with the discussion in the related issue above

Evidence

  • Compared behavior with and without optimizePackageImports — no observable difference
  • Verified import output and bundle structure
  • (Optional) Can provide reproduction repo if needed

Question

Is optimizePackageImports expected to work with Turbopack at this stage, or is this feature still under development?

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions