Skip to content

fix(tsconfig): stop reporting tsconfig files as file dependencies - #291

Merged
stormslowly merged 2 commits into
mainfrom
fix/skip-tsconfig-file-dependencies
Aug 11, 2026
Merged

fix(tsconfig): stop reporting tsconfig files as file dependencies#291
stormslowly merged 2 commits into
mainfrom
fix/skip-tsconfig-file-dependencies

Conversation

@stormslowly

@stormslowly stormslowly commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Why

load_tsconfig_paths pushed the whole accumulated tsconfig.file_dependencies set — the root tsconfig, everything it extends, and every transitive project reference — into ResolveContext on every resolution that hit a tsconfig path alias.

In a monorepo with project references that set is large, and the consumer keeps it per module, so the cost scales as module count × tsconfig count. That is the memory burst this PR addresses.
Here is an issue from user web-infra-dev/rspack#15021

Resolving @/index.ts in the project_references fixture:

Before — 6 tsconfig paths on top of the real dependencies:

app/tsconfig.json
tsconfig.base.json
project_a/conf.json
project_b/tsconfig.json
project_c/tsconfig.json
paths_template_variable/tsconfig2.json
project_b/src/aliased/index.ts
fixtures/tsconfig/package.json

After:

project_b/src/aliased/index.ts
fixtures/tsconfig/package.json

Trade-off

This is a temporary workaround, not a fix. Editing a tsconfig.json, a config it extends, or a referenced tsconfig no longer invalidates anything in watch mode — a dev server restart is required.

It is written to be undone in one commit:

  • the loop in load_tsconfig_paths is commented out rather than deleted, with a TODO pointing at the test
  • tsconfig_file_as_file_dependencies is marked #[ignore] rather than removed, so the expected dependency set stays recorded
  • TsConfig::file_dependencies and its accumulation in extend_tsconfig / load_references are untouched

Restoring means uncommenting the loop and dropping the #[ignore].

Temporary workaround for the memory burst in monorepos with project
references. Restoring is a one-commit revert: uncomment the loop in
`load_tsconfig_paths` and drop the `#[ignore]` on
`tsconfig_file_as_file_dependencies`.
Copilot AI lite review requested due to automatic review settings August 11, 2026 02:46

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

Reduces per-module memory growth during tsconfig path-alias resolution by no longer copying the accumulated TsConfig::file_dependencies set into ResolveContext (which downstream consumers keep per module).

Changes:

  • Stop adding tsconfig.file_dependencies into ResolveContext during load_tsconfig_paths.
  • Ignore the existing test that asserted tsconfig configs/references are reported as file dependencies (preserving it as a reference for later restoration).

Reviewed changes

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

File Description
src/lib.rs Disables propagation of tsconfig.file_dependencies into ResolveContext to prevent module count × tsconfig count scaling in downstream memory usage.
src/tests/tsconfig_project_references.rs Marks the prior “tsconfig configs are file deps” assertion test as ignored while the workaround is in place.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib.rs Outdated
Comment thread src/tests/tsconfig_project_references.rs
@codspeed-hq

codspeed-hq Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing fix/skip-tsconfig-file-dependencies (8baf259) with main (ab14d9d)

Open in CodSpeed

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@stormslowly
stormslowly merged commit 5355169 into main Aug 11, 2026
25 checks passed
@stormslowly
stormslowly deleted the fix/skip-tsconfig-file-dependencies branch August 11, 2026 05:08
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.

3 participants