Files
bun.sh/src
Jarred Sumner ecd23df4ca Fix banner positioning with --format=cjs --target=bun (#22641)
## Summary
- Fixes incorrect banner positioning when using `--banner` with
`--format=cjs` and `--target=bun`
- Ensures Bun-specific comments (`// @bun @bun-cjs`) appear before user
banner content
- Properly extracts and positions hashbangs from banner content

## Problem
When using `--banner` with `--format=cjs --target=bun`, the banner was
incorrectly placed before the `// @bun @bun-cjs` comment and CJS wrapper
function, breaking the module format that Bun expects.

## Solution
Implemented proper ordering:
1. **Hashbang** (from source file or extracted from banner if it starts
with `#!`)
2. **@bun comments** (e.g., `// @bun`, `// @bun @bun-cjs`, `// @bun
@bytecode`)
3. **CJS wrapper** `(function(exports, require, module, __filename,
__dirname) {`
4. **Banner content** (excluding any extracted hashbang)

## Test plan
- [x] Added comprehensive tests for banner positioning with CJS/ESM and
Bun target
- [x] Tests cover hashbang extraction from banners
- [x] Tests verify proper ordering with bytecode generation
- [x] All existing tests pass

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-09-14 01:01:22 -07:00
..
2025-09-09 20:41:10 -07:00
2025-09-11 17:53:06 -07:00
2025-09-13 14:52:19 -07:00
2025-09-13 14:52:19 -07:00
2025-09-09 20:41:10 -07:00
2025-07-21 13:26:47 -07:00
2025-09-09 20:41:10 -07:00
2025-09-09 20:41:10 -07:00
2025-09-13 14:52:19 -07:00
2025-09-09 20:41:10 -07:00
2025-09-09 20:41:10 -07:00
2025-09-09 20:41:10 -07:00
2025-09-09 20:41:10 -07:00
2025-09-09 20:41:10 -07:00
2025-09-13 14:52:19 -07:00
2025-09-09 23:31:07 -07:00
2025-07-21 13:26:47 -07:00
2025-07-29 19:35:46 -07:00
2025-09-09 20:41:10 -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-08-27 06:39:11 -07:00
2025-09-09 20:41:10 -07:00
2025-09-04 18:06:47 -07:00
2025-09-09 20:41:10 -07:00
2025-09-11 23:29:53 -07:00
2025-09-09 20:41:10 -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-09 20:41:10 -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-09-09 20:41:10 -07:00
2025-07-21 13:26:47 -07:00
2025-07-21 13:26:47 -07:00