No successful run was found on main (c2e75f3) during the generation of this report, so e347c5b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
Benchmarks
13 archived benchmarks were run. If they were deleted in another branch, consider rebasing to remove them from the report. .
feat(es/minifier): Add merge_imports optimization pass
Implements a new optimization pass that merges duplicate import statements
from the same module source, reducing bundle size by eliminating redundant imports.
Fixes #11133
## Implementation
- Added `merge_imports.rs` pass that groups imports by source and merges compatible ones
- Handles all valid ES module import combinations:
- Multiple named imports ā merged into single import
- Default + named imports ā merged
- Default + namespace imports ā merged
- Namespace + named imports (without default) ā kept separate (no valid syntax)
- Preserves import attributes/assertions (`with` clause)
- Preserves type-only imports separately
- Preserves side-effect imports (no specifiers)
- Deduplicates exact duplicate imports
- Preserves different aliases for the same export
## Configuration
- Added `merge_imports: bool` option to `CompressOptions` (default: `true`)
- Integrated into minifier pipeline before `merge_exports`
## Testing
- Added comprehensive test fixtures in `tests/fixture/issues/11133/`
- Tests cover:
- Basic duplicate named imports
- Same export with different local names (aliases)
- Default + named imports
- Default + namespace imports
- Namespace + named imports (incompatible, not merged)
- Side-effect imports (preserved)
- Different sources (not merged)
- Exact duplicates (deduplicated)
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
e384c33
2 months ago
by github-actions[bot]
+0.05%
refactor: Integrate merge_imports into postcompress_optimizer
Move merge_imports logic from a standalone visitor into the
postcompress_optimizer function as a method, following the
feedback from PR review.
This change:
- Removes the standalone merge_imports visitor
- Adds merge_imports_in_module function to postcompress.rs
- Integrates the logic directly into the postcompress optimization flow
- Maintains all existing functionality and test compatibility
Addresses PR review feedback: https://github.com/swc-project/swc/pull/11151#pullrequestreview-3354509453
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
925711d
2 months ago
by github-actions[bot]
-0.01%
Apply code formatting with cargo fmt
Address PR review feedback to run cargo fmt on the codebase.
Changes:
- Restructure use statements to use nested imports
- Remove extraneous blank line in merge_imports_in_module
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
037b2d3
2 months ago
by github-actions[bot]
-0.02%
fix(es/minifier): Fix clippy warnings in merge_imports
- Use inline format args for better readability
- Replace or_insert_with(Vec::new) with or_default()
- Use Entry API instead of contains_key + insert pattern
These changes address clippy warnings that were causing CI failures.
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2cbe77b
2 months ago
by github-actions[bot]
0%
fix(es/minifier): Fix merge_imports to handle default + namespace + named correctly
The previous implementation incorrectly tried to merge default, namespace,
and named imports into a single import declaration, which is not valid ES
module syntax and caused a panic in the code generator.
This fix ensures that when all three import types are present, they are
properly split into separate import declarations:
- default + named imports in one declaration
- namespace import in a separate declaration
This follows the ES module specification which only allows:
- default + named
- default + namespace (only these two, no named)
- namespace alone
- named alone
Addresses review feedback from PR #11151
š¤ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>