Files
bun.sh/src
Claude Bot 7fb2b7a12d Implement typeof evaluation for defined globals at build time
Major improvement: typeof expressions for defined globals like Bun are now
evaluated at build time, enabling much better dead code elimination.

Changes:
- typeof Bun evaluates to "object" for --target=bun, "undefined" for --target=browser
- typeof globalThis.Bun also evaluates at build time
- Const expressions like `const isBun = typeof Bun !== 'undefined'` now become
  `var isBun = !0` (true) or `var isBun = !1` (false) at build time

This enables automatic DCE for patterns like:
- if (typeof Bun === "object") { /* bun code */ }
- if (typeof Bun !== "undefined") { /* bun code */ }

The implementation checks for defined identifiers and dot expressions in the
typeof operator and replaces them with the appropriate string literal based on
the define configuration.

Note: While typeof is now evaluated, full constant propagation for local
variables is not yet implemented, so patterns like:
`const isBun = typeof Bun !== 'undefined'; if (isBun) { ... }`
still require the if statement optimization separately.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 23:34:07 +00:00
..
2025-07-21 13:26:47 -07:00
2025-09-04 18:06:47 -07:00
2025-09-03 18:59:15 -07:00
2025-07-21 13:26:47 -07:00
2025-07-29 19:35:46 -07:00
2025-09-03 15:40:44 -07:00
2025-07-21 13:26:47 -07:00
2025-09-07 00:46:36 -07:00
2025-07-21 13:26:47 -07:00
2025-09-09 13:42:10 +00:00
2025-07-21 13:26:47 -07:00
2025-08-27 06:39:11 -07:00
2025-09-04 18:06:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 15:40:44 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00