Files
bun.sh/test/regression/issue
robobun 05434add3e fix(bundler): legal comments no longer break module.exports = require() redirect optimization (#26113)
## Summary

- Legal comments (`/*! ... */`) were preventing the `module.exports =
require()` redirect optimization from being applied to CommonJS wrapper
modules
- The fix scans all parts to find a single meaningful statement,
skipping comments, directives, and empty statements
- If exactly one such statement exists and matches the `module.exports =
require()` pattern, the redirect optimization is now applied

This fixes an issue where wrapper modules like Express's `index.js`:
```js
/*!
 * express
 * MIT Licensed
 */

'use strict';

module.exports = require('./lib/express');
```

Were generating unnecessary wrapper functions instead of being
redirected directly to the target module.

## Test plan

- [x] Added regression test in `test/regression/issue/3179.test.ts`
- [x] Verified test fails with system bun and passes with the fix
- [x] Tested manual reproduction scenario

Fixes #3179

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

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 15:57:27 -08:00
..
2025-08-06 06:44:46 -07:00
2025-01-28 17:23:57 -08:00
2025-06-03 13:23:12 -07:00
2025-06-03 23:41:37 -07:00
2025-01-17 22:08:07 -08:00
2024-06-14 01:50:36 -07:00
2025-03-03 21:38:05 -08:00
2025-05-26 21:18:22 -07:00
2025-07-03 01:06:22 -07:00
2025-07-23 22:31:42 -07:00
2025-10-20 14:07:31 -07:00
2025-11-05 22:04:14 -08:00
2025-11-05 22:04:14 -08:00
2025-11-19 21:17:51 -08:00
2026-01-13 22:38:31 -08:00
2025-07-20 23:02:10 -07:00