Skip to content

refactor: replace cfg-if dependency with std cfg_select! macro#1290

Merged
Boshen merged 5 commits into
mainfrom
cfg-select
Jul 11, 2026
Merged

refactor: replace cfg-if dependency with std cfg_select! macro#1290
Boshen merged 5 commits into
mainfrom
cfg-select

Conversation

@Boshen

@Boshen Boshen commented Jul 11, 2026

Copy link
Copy Markdown
Member

Replaces the cfg-if crate with std::cfg_select!, which was stabilized in Rust 1.95 (its rustdoc even carries doc(alias = "cfg-if") as the intended replacement). This drops one dependency.

  • Sites with real platform/feature branching (metadata, symlink_metadata, read_link, Cache::canonicalize, normalize_with wasm handling, ResolverGeneric::new/clone_with_options) become cfg_select! arms; the two let sites use it in expression position, which cfg_if! could not do.
  • The five Yarn-PnP early-return guards in FileSystemOs and the non-wasm specifier shadowing in require_impl had no else branch, so they become plain #[cfg] attributes instead of a macro with an empty fallback arm.

Verified with just ready (fmt, typos, check incl. s390x target, tests for default and --all-features, napi build + node tests, pnp tests, clippy --deny warnings, doc). Windows and wasm arms are token-identical to before and are covered by CI.

Stacked on #1289 (MSRV 1.95.0 bump); retargets to main once that merges.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.07%. Comparing base (bf4a499) to head (4fcb62c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1290   +/-   ##
=======================================
  Coverage   94.07%   94.07%           
=======================================
  Files          21       21           
  Lines        4285     4288    +3     
=======================================
+ Hits         4031     4034    +3     
  Misses        254      254           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented Jul 11, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.37%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 5 regressed benchmarks
✅ 14 untouched benchmarks
⏩ 5 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
pm/yarn-flat 748.9 µs 850 µs -11.89%
pm/pnpm-hoisted 902.1 µs 961.6 µs -6.19%
complex_real 21.3 µs 22.4 µs -4.75%
resolver_memory[multi-thread] 244.8 µs 255.2 µs -4.07%
pm/yarn-isolated 945.7 µs 975.7 µs -3.07%
pm/pnpm-isolated 962 µs 927.3 µs +3.74%
resolver_real[multi-thread] 253.7 µs 245 µs +3.58%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing cfg-select (4fcb62c) with main (bf4a499)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Base automatically changed from msrv-1.95 to main July 11, 2026 15:21
@Boshen
Boshen merged commit db9fb8b into main Jul 11, 2026
19 checks passed
@Boshen
Boshen deleted the cfg-select branch July 11, 2026 16:04
@oxc-guard oxc-guard Bot mentioned this pull request Jul 11, 2026
Boshen pushed a commit that referenced this pull request Jul 12, 2026
## 🤖 New release

* `oxc_resolver`: 11.23.0 -> 11.24.0
* `oxc_resolver_napi`: 11.23.0 -> 11.24.0

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[11.24.0](v11.23.0...v11.24.0)
- 2026-07-12

### <!-- 0 -->🚀 Features

- expose tsconfig paths resolve method without file existence check
([#1282](#1282)) (by
@sapphi-red)
- add `ResolveError::TsconfigLoadFailed` for tsconfig read and parse
failures
([#1287](#1287)) (by
@shulaoda)

### <!-- 2 -->🚜 Refactor

- replace cfg-if dependency with std cfg_select! macro
([#1290](#1290)) (by
@Boshen)

### <!-- 3 -->📚 Documentation

- normalize README sponsor section
([#1273](#1273)) (by
@Boshen)

### <!-- 4 -->⚡ Performance

- *(cache)* reuse the child path when its parent canonicalizes to itself
([#1288](#1288)) (by
@Boshen)
- *(napi)* shrink release binaries (path remap + build-std without
backtrace)
([#1283](#1283)) (by
@Boshen)

### Contributors

* @sapphi-red
* @Boshen
* @renovate[bot]
* @shulaoda
</blockquote>



</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
@oxc-guard oxc-guard Bot mentioned this pull request Jul 12, 2026
Boshen pushed a commit that referenced this pull request Jul 12, 2026
## 🤖 New release

* `oxc_resolver`: 11.24.0 -> 11.24.1
* `oxc_resolver_napi`: 11.24.0 -> 11.24.1

<details><summary><i><b>Changelog</b></i></summary><p>

## `oxc_resolver`

<blockquote>

##
[11.24.0](v11.23.0...v11.24.0)
- 2026-07-12

### <!-- 0 -->🚀 Features

- expose tsconfig paths resolve method without file existence check
([#1282](#1282)) (by
@sapphi-red)
- add `ResolveError::TsconfigLoadFailed` for tsconfig read and parse
failures
([#1287](#1287)) (by
@shulaoda)

### <!-- 2 -->🚜 Refactor

- replace cfg-if dependency with std cfg_select! macro
([#1290](#1290)) (by
@Boshen)

### <!-- 3 -->📚 Documentation

- normalize README sponsor section
([#1273](#1273)) (by
@Boshen)

### <!-- 4 -->⚡ Performance

- *(cache)* reuse the child path when its parent canonicalizes to itself
([#1288](#1288)) (by
@Boshen)
- *(napi)* shrink release binaries (path remap + build-std without
backtrace)
([#1283](#1283)) (by
@Boshen)

### Contributors

* @sapphi-red
* @Boshen
* @renovate[bot]
* @shulaoda
</blockquote>



</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant