Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Turbopack not tree-shaking unused enum exports | GoodFirstPicks

Turbopack not tree-shaking unused enum exports

vercel/next.js 5 comments 1mo ago
View on GitHub
highopenScope: somewhat clearSkill match: maybeTest focusedNext.jsTypeScriptReact

Why this is a good first issue

Turbopack fails to tree-shake unused enums due to scope hoisting issues.

AI Summary

The issue involves Turbopack not properly tree-shaking unused enums from the final bundle, specifically when scope hoisting is enabled. This results in larger bundle sizes compared to Webpack. The problem appears to be related to scope hoisting losing `/*#__PURE__*/` comments during the process.

Issue Description

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

GitHub Labels

Turbopacklinear: turbopack

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 30 points when you complete it!

Risk Flags

  • requires deep Turbopack knowledge
  • scope hoisting issue
Loading labels...

Details

Points30 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes