Skip to content

fix(vfs): port the include base path computation from Go - #1052

Merged
camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/include-base-path-normalize
Nov 20, 2026
Merged

camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/include-base-path-normalize

Conversation

@magurotuna

Copy link
Copy Markdown
Member

tsrs missed files for two kinds of include entries:

  • An absolute entry with a . or .. segment, such as <abs>/shared/./*.ts: tsrs found no files (TS18003), where tsgo compiles ../shared/a.ts. For <abs>/shared/sub/.., tsrs found only the files below sub.
  • "include": ["^/*"] with the file ^/a.ts: tsgo compiles ^/a.ts, and tsrs found no files.

Go getBasePaths normalizes an absolute entry before it takes the base path of the walk, and getIncludeBasePath keeps at least the root (^/, not ^). tsrs skipped both steps. This PR ports them, and wraps the base path as Go's ToRootedDirectoryPath does.

Tests: include_rooted_dot_segments and the include-wildcard-below-caret-root regression. All fail without the fix.

AI assistance: written with Claude Code.

`get_base_paths` and `get_include_base_path` compute the directories that
the `include` walk starts from. Two steps differed from Go's
`getBasePaths` and `getIncludeBasePath` (`vfsmatch.go`):

- `get_base_paths` kept an absolute include entry as written. Go
  normalizes it first. So `<shared>/./*.ts` (outside the project) started
  the walk at `<shared>/./`, and no visited name matched the normalized
  include pattern (TS18003). `<shared>/sub/..` walked only `sub`.
- `get_include_base_path` cut the path at the last `/` before the first
  wildcard. Go keeps at least the root
  (`max(LastIndex(...), GetRootLength(absolute))`). So `^/*` gave the
  base path `^`, which `contains_path` treats as relative and inside the
  project, and the walk never visited `^/`.

This change ports both expressions as they are, and wraps the base path
in `get_normalized_absolute_path(.., path)` and
`ensure_rooted_path_root_separator`, as Go's
`ToRootedDirectoryPath(getIncludeBasePath(absolute), path)` does.

Tests: `include_rooted_dot_segments` in the `tsrs_cli` integration tests
(the expected output names a file outside the project, so the test builds
the project at run time) and the regression case
`include-wildcard-below-caret-root`. Expected results are from tsgo at the
pinned commit. All fail without the fix.

AI assistance: written with Claude Code.
@camc314
camc314 added this pull request to the merge queue Nov 20, 2026
Merged via the queue into oxc-project:main with commit 2ea07c8 Nov 20, 2026
69 checks passed
@codspeed

codspeed Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

βœ… 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing magurotuna:fix/include-base-path-normalize (61341fe) with main (9f74013)

Open in CodSpeed

Footnotes

  1. 8 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. ↩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants