fix(tsconfig): dedupe project reference dependencies by CPunisher · Pull Request #284 · rstackjs/rspack-resolver · GitHub
Skip to content

fix(tsconfig): dedupe project reference dependencies#284

Open
CPunisher wants to merge 4 commits into
mainfrom
codex/dedupe-tsconfig-reference-deps
Open

fix(tsconfig): dedupe project reference dependencies#284
CPunisher wants to merge 4 commits into
mainfrom
codex/dedupe-tsconfig-reference-deps

Conversation

@CPunisher

@CPunisher CPunisher commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Store tsconfig file dependencies in insertion-ordered sets so extended configs and project references are deduplicated without rebuilding a temporary set on each merge.
  • Precompute flattened transitive project references while loading tsconfig references, preserving the existing nested-reference-first resolution order.
  • Make TsConfig::resolve iterate the flattened reference list directly, removing per-resolve recursive traversal and visited-set hashing.

Verification

  • cargo fmt --check
  • cargo test tsconfig_project_references --lib

cargo test --lib was also run; non-tsconfig PnP tests fail in this local environment (src/tests/pnp.rs), while 143 other tests pass.

Local downstream validation

Earlier in this investigation, built a local Rspack binding against the resolver fix and verified the ccweb Platform build with:

NAPI_RS_NATIVE_LIBRARY_PATH=/Users/bytedance/Projects/rspack/crates/node_binding/rspack.darwin-arm64.node DEBUG=1 IS_OVERSEA=true BUILD_TYPE=online emo run build --filter platform --skip-cache

Result: exit 0, peak RSS around 12.6 GB. Before the dependency dedupe fix, the same validation still hit exit 137 / memory pressure after only adding the reference traversal visited set.

Copilot AI review requested due to automatic review settings June 30, 2026 08:01
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

@codspeed-hq

codspeed-hq Bot commented Jun 30, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing codex/dedupe-tsconfig-reference-deps (7a8f251) with main (b50ffec)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves tsconfig project-reference resolution by preventing redundant work and growth in tracked tsconfig dependency lists, reducing repeated traversals and memory pressure when resolving transitive project references.

Changes:

  • Deduplicate TsConfig.file_dependencies when merging extended configs and project references via a shared helper.
  • Add a visited set to TsConfig::find_reference_paths to avoid re-walking already-seen reference nodes during transitive traversal.
  • Add a regression unit test to ensure dependency deduplication behavior is preserved.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/tsconfig.rs Adds file-dependency dedupe helper and a visited-set guard for reference-path traversal to prevent repeated walking.
src/lib.rs Switches project-reference dependency merging to the new dedupe helper.
src/tests/tsconfig_project_references.rs Adds a regression test verifying file dependency deduplication.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CPunisher CPunisher force-pushed the codex/dedupe-tsconfig-reference-deps branch 2 times, most recently from ee0b90d to 7ead072 Compare June 30, 2026 10:02
@CPunisher CPunisher force-pushed the codex/dedupe-tsconfig-reference-deps branch from 7ead072 to d8610fa Compare June 30, 2026 10:02
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.

2 participants