-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
perf: Disable all unnecessary default-features #11500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR systematically disables default features across all dependencies in the SWC repository to reduce binary size, following the approach from PR #11208. Key changes: - Add `default-features = false` to nearly every dependency - Explicitly enable only the features that are actually needed - Special features added: - once_cell: ["std"] - pretty_assertions: ["std"] - serde_json: ["alloc"] - rustc-hash: ["std"] - regress: ["std", "backend-pikevm"] - flate2: ["rust_backend"] - lexical: ["parse"] - codspeed-criterion-compat: keeps default-features = true - anyhow: ["std"] - clap: ["std"] where used This transformation significantly reduces binary size by eliminating unnecessary transitive dependencies that were previously pulled in automatically. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
|
|
|
|
|
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
Add cbor4ii, dragonbox_ecma, getrandom, lightningcss, and owo-colors to workspace dependencies that were accidentally removed during the default-features refactoring. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add getrandom to cargo-shear ignored list (used for wasm builds) - Enable serde-impl feature for swc_ecma_transforms_react dependency in swc_ecma_transforms_typescript (required for serde derive) - Update wasmtime and wasi-common from v35 to v38 to fix security vulnerability RUSTSEC-2025-0118 Co-Authored-By: Claude Opus 4.5 <[email protected]>
The serde crate needs the 'std' feature for String deserialization support. Without it, hstr and other crates fail to compile because String::deserialize is not available. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Several crates require std or other features to function: - kstring requires 'std' feature - tracing requires 'std' and 'attributes' features for #[instrument] - base64 requires 'std' feature for encode/decode methods Co-Authored-By: Claude Opus 4.5 <[email protected]>
…, quote - rand requires 'std' and 'std_rng' for thread_rng and sample_string - allocator-api2 requires 'std' for Global allocator - syn requires default features for Clone impls and proc-macro support - proc-macro2 and quote require 'proc-macro' feature Co-Authored-By: Claude Opus 4.5 <[email protected]>
petgraph requires these features for GraphMap and StableGraph types which are used by the bundler crate. Co-Authored-By: Claude Opus 4.5 <[email protected]>
lexical requires std, parse-integers, and parse-floats features for Error, Result, ParseOptions, and FromLexical types. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add fmt feature to tracing-subscriber for FmtSubscriber support - Add clap to workspace deps with std and derive features - Update generate-code and swc-releaser to use workspace clap Co-Authored-By: Claude Opus 4.5 <[email protected]>
Required for with_env_filter() in testing crate Co-Authored-By: Claude Opus 4.5 <[email protected]>
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
- Add std feature to serde_json for from_reader support - Add ansi feature to tracing-subscriber for pretty() method Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add missing typescript feature to swc_ecma_parser dependencies that had default-features = false but needed TypeScript syntax support. Co-Authored-By: Claude Opus 4.5 <[email protected]>
IndexMap requires the std feature to have a default hasher type and the new() method. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add std feature to backtrace for Backtrace type - Add serde-impl feature to swc_estree_ast in swc_estree_compat Co-Authored-By: Claude Opus 4.5 <[email protected]>
path_clean::clean returns String, but Input::File expects PathBuf Co-Authored-By: Claude Opus 4.5 <[email protected]>
Binary Sizes
Commit: 443ed57 |
Wasmer requires at least one compiler backend to function Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add derive feature to shrink-to-fit for ShrinkToFit derive macro - Enable default features for wasmer-wasix (complex crate with many required features) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Default features bring in webpki-roots with CDLA-Permissive-2.0 license which is not allowed by the project's license policy. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Revert to original default-features = false as the PR intended. The swc_plugin_backend_wasmer crate uses its own feature flags. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Description:
This PR systematically disables default features across all dependencies in the SWC repository to reduce binary size. This is a retry of PR #11208 rebased onto the current main branch.
The binary size gain from disabling unnecessary default features is significant - the original PR reported 422.37500KB reduction for
@swc/core.Note that removing a feature flag may break the build of downstream crates, so this should be marked as a breaking change for modified crates.
Changes
default-features = falseto nearly every dependency in workspace and crate Cargo.toml filesSpecial Features Added
Some dependencies require specific features to function properly:
once_cell:["std"]pretty_assertions:["std"]serde_json:["alloc"]rustc-hash:["std"]regress:["std", "backend-pikevm"]flate2:["rust_backend"]lexical:["parse"]anyhow:["std"]clap:["std"]where usedcodspeed-criterion-compat: keepsdefault-features = trueImpact
By disabling default features, this PR eliminates unnecessary transitive dependencies that were previously pulled in automatically, significantly reducing the final binary size.
TODOs
Related: #11208