PoptimizeImports
Bun

property

BuildConfig.optimizeImports

optimizeImports?: string[]

List of package names whose barrel files (re-export index files) should be optimized. When a named import comes from one of these packages, only the submodules actually used are parsed — unused re-exports are skipped entirely.

This is also enabled automatically for any package with "sideEffects": false in its package.json.

await Bun.build({
  entrypoints: ['./app.ts'],
  optimizeImports: ['antd', '@mui/material', 'lodash-es'],
});