Skip to content

chore: miscellaneous small cleanups#1268

Merged
Boshen merged 1 commit into
mainfrom
chore/misc-cleanups
Jul 2, 2026
Merged

chore: miscellaneous small cleanups#1268
Boshen merged 1 commit into
mainfrom
chore/misc-cleanups

Conversation

@Boshen

@Boshen Boshen commented Jul 2, 2026

Copy link
Copy Markdown
Member

A batch of tiny, independent cleanups:

  • Derive Clone for Resolution — the manual impl was field-for-field identical to what the derive produces (Debug/PartialEq stay manual, they're genuinely custom).
  • Merge the two byte-identical #[cold] empty-error constructors in Specifier::parse into one.
  • require_hash: .ok_or_else(..) instead of .map_or_else(|| Err(..), Ok).
  • Remove a pointless Some(owned).as_deref().unwrap() dance in the legacy jest-runner-../.. fallback path.
  • Drop a redundant .as_ref() on file_name() in Cache::value (&OsStr == &str already works via OsStr: PartialEq<str>).
  • Remove the napi EnforceExtension::{is_auto,is_enabled,is_disabled} helpers — zero callers anywhere in the repo and not #[napi]-exported, so they never reached JS.
  • Remove a no-op let _ = meta; in the metadata test.
  • Fix the stale doc comment on TsConfig::root / root()": it claimed the field drives final template-variable substitution, but that's keyed off should_buildnow;rootjust records whether the config is the caller's (vs loaded throughextends`).

Split out of #1263.

- Derive `Clone` for `Resolution` (the manual impl was field-for-field
  identical to the derive).
- Merge the two identical #[cold] empty-error constructors in
  `Specifier::parse`.
- `require_hash`: `ok_or_else` instead of `map_or_else(|| Err(..), Ok)`.
- Remove a pointless `Some(owned).as_deref().unwrap()` in the legacy
  `jest-runner-../..` fallback path.
- Drop a redundant `.as_ref()` on `file_name()` in `Cache::value`.
- Remove dead napi `EnforceExtension` helpers (no callers, not
  #[napi]-exported) and a no-op `let _ = meta` in a test.
- Fix stale doc comment on `TsConfig::root`: template variable
  substitution is driven by `should_build` now.
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.83%. Comparing base (4837a2e) to head (3be957c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1268      +/-   ##
==========================================
- Coverage   93.85%   93.83%   -0.03%     
==========================================
  Files          21       21              
  Lines        4313     4298      -15     
==========================================
- Hits         4048     4033      -15     
  Misses        265      265              

☔ 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 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 17 untouched benchmarks
⏩ 5 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
resolver_real[multi-thread] 249.5 µs 261.3 µs -4.54%
pm/yarn-isolated 1 ms 1.1 ms -4.43%
pm/bun-flat 902.6 µs 942.2 µs -4.2%
small 11.5 µs 11.1 µs +3.22%

Tip

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


Comparing chore/misc-cleanups (3be957c) with main (4837a2e)

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.

@Boshen
Boshen merged commit 534280f into main Jul 2, 2026
18 checks passed
@Boshen
Boshen deleted the chore/misc-cleanups branch July 2, 2026 07:31
Boshen added a commit that referenced this pull request Jul 2, 2026
Two cross-file dedups plus stale-allow removal:

- **`push_normalized_component`** existed twice — `path.rs` and
`cache/cached_path.rs` — identical except the cached-path copy trims the
trailing `\0` that uvwasi appends to directory entries on wasm
([nodejs/uvwasi#262](nodejs/uvwasi#262)). This
keeps one `pub` wasm-aware version in `path.rs`. Note this means
`path.rs` callers (tsconfig path joins) now also get the `\0`-trim on
wasm; on native targets the generated code is unchanged, and the helper
stays `#[inline]` so the hot `normalize_with` path keeps its codegen.
- **`manual_tsconfig()`**: the "manually configured tsconfig,
deliberately skipping `Auto` discovery" match block was duplicated
verbatim in `lib.rs` (`resolve`) and `dts_resolver.rs`
(`dts_resolve_tsconfig_paths`). One helper in `tsconfig_resolver.rs` now
owns it, and `find_tsconfig_manual` drops its `pub(crate)`.
- **Stale allows**: `clippy::cognitive_complexity` on `extend_tsconfig`
and `clippy::too_many_lines` on `dts_try_extensions`' neighbor no longer
suppress anything (verified by removing them and running the CI clippy
command); `extend_tsconfig` keeps `too_many_lines` (139/100).

Part of a second cleanup pass; follows #1264#1268.
Boshen added a commit that referenced this pull request Jul 2, 2026
…#1270)

The two "resolve from symlinks" benches did, per timed iteration, 10,000
eager `format!("./file{i}")` allocations plus an `assert!(.. .is_ok())`
branch — unlike every sibling bench in the file, which iterates
precomputed data and discards results with `_ =`. The asserts also
re-checked an invariant already validated once before the benchmark
group runs.

This precomputes the specifiers once (mirroring the `find tsconfig`
bench's hoisting pattern) and drops the in-loop asserts, so the benches
measure symlink resolution rather than resolution + allocation noise.
The validation pass also now constructs one resolver instead of 10,000.

**Heads-up:** this will step-change the CodSpeed series for
`resolver_memory/resolve from symlinks` and `resolver_real/resolve from
symlinks` downward — that's the removed allocation/assert overhead, not
a resolver perf change.

Part of a second cleanup pass; follows #1264#1268.
Boshen added a commit that referenced this pull request Jul 2, 2026
Small leftovers found while sweeping the test suite and the JS side:

- `src/tests/resolve.rs`: the "file in module with query and fragment"
table row appeared twice, byte-identical — the upstream enhanced-resolve
`resolve.test.js` has the case exactly once, so the second row was a
copy-paste in the port. The loop just ran the same assertion twice.
- `src/tests/alias.rs`: `#[allow(clippy::too_many_lines)]` no longer
suppresses anything (verified by removing it and running the CI clippy
command). The same allow in `imports_field.rs` is still load-bearing
(1191/100) and stays.
- `vite.config.ts`: `"napi/browser.js"` was listed twice in
`fmt.ignorePatterns`.
- `napi/test.mjs`: removed a stale comment about a `.ts` extension next
to code that adds `.mjs` and resolves an already-suffixed specifier.
- `napi/webcontainer-fallback.js`: removed an inert lint directive (`//
eslint-disable-next-line: no-console`) — the project lints with oxlint,
the syntax is invalid even for ESLint, and `no-console` isn't enabled.

Part of a second cleanup pass; follows #1264#1268.
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