No successful run was found on main (0fc7496) during the generation of this report, so c1e32fa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
fix(es/codegen): Restore missing top-level comments
This fixes an issue where top-level comments (like copyright headers)
were being lost after PR #11199 changed Module/Script spans to start
at position 0.
The problem was that Module::emit() was taking and emitting all leading
comments before any body items were processed. When helper imports were
injected at the beginning, comments would either appear before them
(wrong) or be lost entirely.
The fix is to skip emitting leading comments at Module/Script level when
the body is non-empty. Instead, comments are emitted by the first body
item with a real source span. Injected imports have DUMMY_SP, so they
skip comment emission, and the original source items emit their comments
correctly after the imports.
This ensures:
- Comments appear after injected imports (maintains fix for #11167)
- Comments are not lost (fixes regression from PR #11199)
- Module span still starts at position 0 (maintains PR #11199 changes)
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Donny/ź°ėģ¤ <kdy1@users.noreply.github.com>