Skip to content

Turbopack not tree-shaking unused enum exports #88009

@DRoet

Description

@DRoet

Link to the code that reproduces this issue

https://github.com/DRoet/turbo-treeshake-bug

To Reproduce

Create project with client component that imports large .ts file with loads of enum definitions that are not being used. (see listed repository

  1. In the listed repository, run next build
  2. check the Turbopack bundle output using the new analyze command: next experimental-analyze
  3. large-utility.ts will be listed as ~20kb, none of the unused enums are stripped

Current vs. Expected behavior

I would expect the unused enums to be stripped from the final bundle just like next build --webpack

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 63146
  Available CPU cores: 16
Binaries:
  Node: 24.11.0
  npm: 11.6.1
  Yarn: 1.22.22
  pnpm: 9.15.5
Relevant Packages:
  next: 16.1.1 // Latest available version is detected (16.1.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

In our large repository we have a lot of GraphQL-Codegen with enums, so in our case its adding ~300kb to the final output compared to webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.linear: turbopackConfirmed issue that is tracked by the Turbopack team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions