perf: Disable all unnecessary default-features#11208
Conversation
|
This comment has been minimized.
This comment has been minimized.
…tributes feature - Update swc_atoms from 8.0.2 to 9.0.0 - Update swc_common from 16.0.0 to 18.0.1 - Update swc_ecma_ast from 17.0.0 to 20.0.1 - Update swc_ecma_transforms_base from 29.0.0 to 36.0.1 - Update swc_ecma_utils from 23.0.0 to 26.0.1 - Update swc_ecma_visit from 17.0.0 to 20.0.0 - Add tracing 'attributes' feature required for #[swc_trace] macro Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
@claude fix CI |
This comment has been minimized.
This comment has been minimized.
…r swc_common - hstr: Add `std` feature to serde dependency to enable String::deserialize - swc_common: Add `attributes` feature to tracing dependency to enable #[instrument] macro Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
@claude Fix CI |
|
Claude finished @kdy1's task in 2m 14s —— View job Fixing CI
Fixed issues:
|
PR Review: perf: Disable all unnecessary
|
…r swc_common - Add `derive` feature to shrink-to-fit dependency in swc_common - Add `serde-impl` feature to swc_ecma_transforms_react in swc_core Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR systematically disables default features across hundreds of dependencies in the SWC monorepo to reduce binary size by ~422KB. The changes span workspace-level configuration and individual crate manifests.
Changes:
- Workspace dependencies now specify
default-features = false - Necessary features are explicitly re-enabled (e.g.,
std,allocfor serde_json) - New
swc_ecma_compilercrate added - Test code gated with
#[cfg(feature = "serde")]
Reviewed changes
Copilot reviewed 146 out of 147 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| Cargo.toml | Workspace-level dependency defaults disabled with explicit feature re-enabling |
| crates/*/Cargo.toml | ~100+ crates updated to disable default features |
| crates/swc_ecma_compiler/* | New crate for ES compatibility layer |
| crates/hstr/src/wtf8_atom.rs | Added feature gates for serde-dependent tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| js-sys = { version = "0.3.77", default-features = false } | ||
| jsonc-parser = { version = "0.26.2", default-features = false } | ||
| kstring = { version = "2.0.0", default-features = false } | ||
| lazy_static = { version = "1.4.0", default-features = false } |
There was a problem hiding this comment.
The workspace lexical dependency adds explicit features ["std", "parse-floats", "parse-integers"] when disabling default features. This is good practice as lexical requires these for basic functionality. Consider documenting why these specific features are needed to help future maintainers understand the requirement.
| lazy_static = { version = "1.4.0", default-features = false } | |
| lazy_static = { version = "1.4.0", default-features = false } | |
| # lexical's default features are disabled; `std`, `parse-floats`, and `parse-integers` | |
| # are explicitly enabled because they are required for the crate's basic number | |
| # parsing functionality used across this workspace. |
| st-map = { version = "0.2.0", default-features = false } | ||
| string_cache = { version = "0.8.7", default-features = false } | ||
| swc_sourcemap = { version = "9.3.4", default-features = false } | ||
| syn = { version = "2", default-features = false, features = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] } |
There was a problem hiding this comment.
The syn workspace dependency uses features = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] with default-features = false. However, individual crates using syn (like testing_macros, various codegen_macros crates) specify different feature sets without proc-macro. This could cause issues if the workspace default features don't align with what the crates actually need. Verify that all syn usages have the correct features explicitly listed.
| syn = { version = "2", default-features = false, features = ["derive", "parsing", "printing", "clone-impls", "proc-macro"] } | |
| syn = { version = "2", default-features = false } |
| anyhow = { workspace = true, default-features = false } | ||
| glob = { workspace = true, default-features = false } | ||
| once_cell = { workspace = true, default-features = false } | ||
| proc-macro2 = { workspace = true, default-features = false } | ||
| quote = { workspace = true, default-features = false } |
There was a problem hiding this comment.
The proc-macro2, quote, and syn crates typically require the proc-macro feature to be enabled when used in proc-macro crates. Disabling default features without explicitly enabling necessary features like proc-macro may cause compilation failures. Please verify that these dependencies build correctly without default features, or add the required features explicitly.
| bumpalo = { workspace = true, features = ["allocator-api2"] } | ||
| hashbrown = { workspace = true, optional = true } | ||
| rustc-hash = { workspace = true } | ||
| allocator-api2 = { workspace = true, default-features = true } |
There was a problem hiding this comment.
The allocator-api2 crate has default-features = true which is inconsistent with the PR's goal of disabling default features. This should likely be default-features = false for consistency, unless there's a specific reason to keep defaults enabled for this dependency.
| allocator-api2 = { workspace = true, default-features = true } | |
| allocator-api2 = { workspace = true, default-features = false } |
| compact_str = { workspace = true, default-features = true } | ||
| criterion = { workspace = true, default-features = true } | ||
| kstring = { workspace = true, default-features = true, features = ["std"] } | ||
| num_cpus = { workspace = true, default-features = true } | ||
| par-iter = { workspace = true, default-features = true } | ||
| rand = { workspace = true, default-features = true } | ||
| serde_json = { workspace = true, default-features = true } | ||
| smartstring = { workspace = true, default-features = true } | ||
| smol_str = { workspace = true, default-features = true } | ||
| string_cache = { workspace = true, default-features = true } |
There was a problem hiding this comment.
The workspace configuration sets default-features = true for several dev-dependencies (codspeed-criterion-compat, criterion, compact_str, kstring, etc.) while the PR aims to disable default features. This inconsistency should be reviewed - either these need defaults enabled for a specific reason, or they should be set to false for consistency with the PR's goals.
| compact_str = { workspace = true, default-features = true } | |
| criterion = { workspace = true, default-features = true } | |
| kstring = { workspace = true, default-features = true, features = ["std"] } | |
| num_cpus = { workspace = true, default-features = true } | |
| par-iter = { workspace = true, default-features = true } | |
| rand = { workspace = true, default-features = true } | |
| serde_json = { workspace = true, default-features = true } | |
| smartstring = { workspace = true, default-features = true } | |
| smol_str = { workspace = true, default-features = true } | |
| string_cache = { workspace = true, default-features = true } | |
| compact_str = { workspace = true, default-features = false } | |
| criterion = { workspace = true, default-features = false } | |
| kstring = { workspace = true, default-features = false, features = ["std"] } | |
| num_cpus = { workspace = true, default-features = false } | |
| par-iter = { workspace = true, default-features = false } | |
| rand = { workspace = true, default-features = false } | |
| serde_json = { workspace = true, default-features = false } | |
| smartstring = { workspace = true, default-features = false } | |
| smol_str = { workspace = true, default-features = false } | |
| string_cache = { workspace = true, default-features = false } |
|
@claude fix ci |
|
Claude finished @kdy1's task in 8m 37s —— View job Fixing CI
Fixed issues:
|
- swc_ecma_transforms: Add serde-impl feature to swc_ecma_transforms_react - testing: Add std, fmt, ansi features to tracing-subscriber, std to tracing - swc_config: Add std feature to anyhow for Context trait - Cargo.toml: Add std, unicode features to regex for std::error::Error impl - swc_ecma_transforms_optimization: Add graphmap feature to petgraph - swc_ecma_transforms_react: Add alloc feature to base64 for encode method - swc_ecma_preset_env: Add std to anyhow and rustc-hash in build-deps - swc_ecma_minifier: Add std to tracing for set_default function - swc: Add std to anyhow and base64 for error handling Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
|
@claude fix ci |
|
Claude finished @kdy1's task in 5m 29s —— View job Fixing CI
Fixed issues:
|
- hex: Add alloc feature required for hex::encode - indexmap: Add std feature required for IndexMap::new() - swc_ts_fast_strip: Add serde-impl feature to swc_ecma_transforms_react Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
|
@claude fix ci |
|
Claude finished @kdy1's task in 4m 13s —— View job Fixing CI
Fixed issues:
|
- Cargo.toml: Added `std` feature to `base64` - required for `encode` and `encode_string` methods used in swc_compiler_base and other crates - swc_ecma_transforms_react: Removed explicit `features = ["alloc"]` to inherit workspace's `std` feature for base64 - swc_ecma_transforms_typescript: Added `serde-impl` feature to `swc_ecma_transforms_react` dependency - required for serde imports in jsx/mod.rs and refresh/options.rs during benchmarks Co-authored-by: Donny/강동윤 <kdy1@users.noreply.github.com>
CodSpeed Performance ReportMerging this PR will improve performance by 4.07%Comparing Summary
Performance Changes
Footnotes
|
|
@codex Review |
Description:
This is to drop dependencies that is not strictly required. The binary size gain of this PR for
@swc/coreis422.37500KBNote 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