Skip to content

Conversation

@kdy1
Copy link
Member

@kdy1 kdy1 commented Oct 30, 2025

Description:

This is to drop dependencies that is not strictly required. The binary size gain of this PR for @swc/core is 422.37500KB

Note that removing a feature flag may break the build of the downstram crates, so I'll mark this as a breaking change of modified crates.


TODOs

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

⚠️ No Changeset found

Latest commit: 970df2c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kdy1 kdy1 added this to the Planned milestone Oct 30, 2025
@kdy1 kdy1 changed the title perf: Disable perf: Disable all unnecessary default-features Oct 30, 2025
@claude
Copy link
Contributor

claude bot commented Oct 30, 2025

Claude finished @kdy1's task —— View job


Comprehensive Code Review ✅

I've completed a thorough analysis of this performance optimization PR that disables unnecessary default-features across the SWC codebase to achieve a 422KB binary size reduction.

Analysis Summary

Code Quality & Best Practices

  • Excellent systematic approach: All ~235 dependency declarations consistently use default-features = false
  • Proper feature management: Essential features are explicitly enabled where needed (e.g., serde_json with ["alloc"], once_cell with ["std"])
  • Workspace standardization: Changes maintain consistency across 100+ Cargo.toml files
  • Follows repository guidelines: Aligns with CLAUDE.md directive to "write performant code, always prefer performance"

⚠️ Potential Issues Found

  1. Missing regex optimization: regex = { version = "1.5.4" } in /Cargo.toml:89 lacks default-features = false - should be consistent with other deps

  2. Breaking change implications: As noted in PR description, this will break downstream crates that rely on transitive default features

  3. Complex feature interactions: Some crates have intricate feature dependencies that could cause subtle runtime issues

🔒 Security Assessment

  • Cryptographic dependencies properly handled: blake3, sha1, sha2 all have default-features = false with no security-critical features disabled
  • No security regressions identified: Essential security features are explicitly preserved where needed

📊 Performance Considerations

  • Significant binary size reduction: 422KB savings represents meaningful improvement
  • No performance regressions expected: Feature disabling only removes unused code paths
  • Memory efficiency: Reduced feature sets should improve memory usage

🧪 Test Coverage Impact

  • Test infrastructure preserved: Key testing features like serde-impl, concurrent are explicitly enabled where needed
  • Feature-gated code: New serde implementation in crates/hstr/src/wtf8_atom.rs properly uses #[cfg(feature = "serde")]
  • Recommendation: Run full test suite to verify no test failures from missing features

📋 Recommendations

  1. Fix regex inconsistency:

    regex = { version = "1.5.4", default-features = false }
  2. Add changeset: As noted by changeset-bot, this needs a proper changeset documenting the breaking nature

  3. Verify Rspack compatibility: Address the TODO item about checking [Bug]: ProgressPlugin containing non-ASCII characters cannot clear the screen web-infra-dev/rspack#10988 (comment)

  4. Test downstream impact: Consider testing major downstream consumers before release

🎯 Overall Assessment

This is a well-executed performance optimization that demonstrates careful attention to detail. The systematic approach to feature management is exemplary, and the binary size reduction is substantial. The main concerns are around downstream compatibility, which is appropriately flagged as a breaking change.

Recommendation: ✅ Approve with minor fixes (regex dependency + changeset)


@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Binary Sizes

File Size
swc.linux-x64-gnu.node 31M (31588832 bytes)

Commit: 844984e

@kdy1 kdy1 self-assigned this Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants