Skip to content

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Nov 22, 2025

Add a new API to make tsconfig paths work with the auto-discovered tsconfig.

    /// Resolve `specifier` for an absolute path to a file.
    ///
    /// NOTE: [TsconfigDiscovery::Auto] only work for this API, use `ResolverGeneric::resolve_file` instead.
    ///
    /// # Errors
    ///
    /// * See [ResolveError]
    ///
    /// # Panics
    ///
    /// * If the provided path is not a file.
    pub fn resolve_file<P: AsRef<Path>>(
        &self,
        file: P,
        specifier: &str,
    ) -> Result<Resolution, ResolveError> {

New concept:

Given an input file:

  • There is always a tsconfig associated with this file, we call it the resolved tsconfig, or tsconfig solution (in tsconfck)
  • When resolving path aliases, always use the resolved tsconfig.

Copy link
Member Author

Boshen commented Nov 22, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

❌ Patch coverage is 98.54369% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.29%. Comparing base (62c4497) to head (8643c91).

Files with missing lines Patch % Lines
src/tsconfig_resolver.rs 95.91% 2 Missing ⚠️
src/lib.rs 99.36% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                      @@
##           11-18-feat_port_tsconfck     #860      +/-   ##
============================================================
+ Coverage                     94.14%   94.29%   +0.14%     
============================================================
  Files                            17       17              
  Lines                          3092     3208     +116     
============================================================
+ Hits                           2911     3025     +114     
- Misses                          181      183       +2     

☔ View full report in Codecov by Sentry.
📢 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
Copy link

codspeed-hq bot commented Nov 22, 2025

CodSpeed Performance Report

Merging #860 will improve performances by 10.26%

Comparing 11-22-feat_add_resolve_file_api_for_tsconfig_auto_discovery_to_work (d651d00) with 11-18-feat_port_tsconfck (62c4497)

Summary

⚡ 1 improvement
✅ 11 untouched
⏩ 5 skipped1

Benchmarks breakdown

Benchmark BASE HEAD Change
resolver_memory[find tsconfig] 15.4 µs 13.9 µs +10.26%

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 requested a review from shulaoda November 22, 2025 14:58
if !cached_path.path.is_absolute() {
return Ok(None);
match &self.options.tsconfig {
None | Some(TsconfigDiscovery::Auto) => self.find_tsconfig_auto(cached_path),
Copy link
Member

Choose a reason for hiding this comment

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

When tsconfig is set to None, we shouldn’t attempt to look for a tsconfig file.

Comment on lines 264 to 265
let Some(tsconfig) = tsconfig else { return Ok(None) };
let paths = tsconfig.resolve(cached_path.path(), specifier);
Copy link
Member

Choose a reason for hiding this comment

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

In auto mode, the tsconfig may include references, so tsconfig.resolve ends up resolving the paths from those referenced configs too.

pub(crate) fn resolve(&self, path: &Path, specifier: &str) -> Vec<PathBuf> {
let paths = self.resolve_path_alias(specifier);
for tsconfig in &self.references_resolved {
if path.starts_with(tsconfig.base_path()) {
return [tsconfig.resolve_path_alias(specifier), paths].concat();
}
}
paths
}

@Boshen Boshen force-pushed the 11-18-feat_port_tsconfck branch from a0ff198 to 62c4497 Compare November 23, 2025 07:07
@Boshen Boshen force-pushed the 11-22-feat_add_resolve_file_api_for_tsconfig_auto_discovery_to_work branch from b38832c to 24c9f80 Compare November 23, 2025 07:07
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