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-09-03 15:40:44 -07:00
2025-07-22 17:51:38 -07:00
2025-09-01 02:35:55 -07:00
2025-09-09 23:34:07 +00:00
2025-08-11 20:19:34 -07:00
2025-09-03 15:40:44 -07:00
2025-07-22 17:51:38 -07:00
2025-09-07 00:08:43 -07:00
2025-09-04 18:17:14 -07:00
2025-09-06 13:57:47 -07:00
2025-08-31 13:52:43 -07:00
2025-09-03 15:40:44 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-09-04 15:18:31 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-28 17:34:35 -07:00
2025-09-04 18:06:47 -07:00
2025-07-17 03:13:48 -07:00
2025-09-03 18:57:39 -07:00
2025-08-24 14:06:39 -07:00
2025-08-26 12:50:25 -07:00
2025-09-06 22:40:41 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-31 22:07:17 -07:00
2025-08-11 20:19:34 -07:00
2025-09-04 19:45:05 -07:00
2025-09-01 02:35:55 -07:00
2025-08-28 17:34:35 -07:00
2025-09-03 15:40:44 -07:00
2025-07-23 17:10:58 -07:00
2025-09-03 15:40:44 -07:00
2025-08-26 12:50:25 -07:00
2025-09-03 18:59:15 -07:00
2025-09-03 15:40:44 -07:00
2025-08-26 12:50:25 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 15:40:44 -07:00
2025-09-04 14:25:22 -07:00
2025-06-04 19:41:26 -07:00
2025-08-11 20:19:34 -07:00
2025-09-03 15:40:44 -07:00
2025-08-23 06:55:30 -07:00
2025-05-14 18:42:42 -07:00
2025-07-29 19:35:46 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-04-17 14:17:08 -07:00
2025-07-22 17:51:38 -07:00
2025-09-03 18:57:39 -07:00
2025-07-22 17:51:38 -07:00
2025-07-20 23:04:17 -07:00
2025-09-01 01:12:11 -07:00
2025-09-03 15:40:44 -07:00
2025-08-26 12:50:25 -07:00
2025-06-12 14:20:28 -07:00
2025-08-11 20:19:34 -07:00
2025-07-21 13:26:47 -07:00
2025-09-07 00:46:36 -07:00
2025-08-28 17:34:35 -07:00
2025-09-03 18:57:39 -07:00
2025-07-31 00:56:50 -07:00
2025-08-11 20:19:34 -07:00
2025-09-04 18:14:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-09-09 13:42:10 +00:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-28 00:13:17 -07:00
2025-08-22 23:04:58 -07:00
2025-05-08 23:22:16 -07:00
2025-05-08 23:22:16 -07:00
2025-08-14 18:03:26 -07:00
2025-08-27 06:39:11 -07:00
2025-05-08 23:22:16 -07:00
2025-08-21 15:28:15 -07:00
2025-08-30 02:50:35 -07:00
2025-08-23 06:55:30 -07:00
2025-06-03 23:51:03 -07:00
2025-08-01 23:38:34 -07:00
2025-08-26 12:50:25 -07:00
2025-09-03 15:40:44 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-28 17:34:35 -07:00
2025-09-04 18:06:47 -07:00
2025-07-09 00:19:57 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-23 06:55:30 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-09-09 14:30:18 +00:00
2025-09-01 02:56:59 -07:00
2025-07-21 13:26:47 -07:00
2025-03-26 23:57:10 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-08-14 21:12:22 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-09-03 15:40:44 -07:00
2025-09-03 15:40:44 -07:00
2025-07-22 17:51:38 -07:00
2025-07-22 17:51:38 -07:00
2025-09-09 15:33:11 +00:00
2025-08-18 20:02:08 -07:00
2025-07-22 17:51:38 -07:00
2025-08-26 12:50:25 -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-22 17:51:38 -07:00
2025-08-26 12:50:25 -07:00
2025-06-22 20:51:45 -07:00
2025-07-22 17:51:38 -07:00
2025-09-03 15:40:44 -07:00
2025-07-21 13:26:47 -07:00
2025-09-04 18:17:14 -07:00
2025-07-21 13:26:47 -07:00
2025-08-31 18:27:51 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-07-13 04:27:43 -07:00
2025-07-25 12:38:06 -07:00
2025-09-04 18:17:14 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 15:40:44 -07:00
2025-07-25 12:38:06 -07:00
2025-07-21 13:26:47 -07:00
2025-08-26 12:50:25 -07:00
2025-05-08 23:22:16 -07:00
2025-07-21 13:26:47 -07:00
2025-08-11 20:19:34 -07:00
2025-07-21 13:26:47 -07:00
2025-08-26 12:50:25 -07:00
2025-08-26 12:50:25 -07:00
2025-07-22 17:51:38 -07:00
2025-08-11 20:19:34 -07:00
2025-07-20 23:04:17 -07:00
2025-08-23 06:55:30 -07:00
2025-07-21 13:26:47 -07:00
2025-07-22 17:51:38 -07:00
2025-07-21 13:26:47 -07:00
2025-09-03 18:57:39 -07:00