Skip to content

fix(resolve): treat bare . / .. as relative directory imports (#5141)#5151

Merged
proggeramlug merged 1 commit into
mainfrom
fix/dir-import-dotdot-resolution
Jun 14, 2026
Merged

fix(resolve): treat bare . / .. as relative directory imports (#5141)#5151
proggeramlug merged 1 commit into
mainfrom
fix/dir-import-dotdot-resolution

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #5141 (compilePackages: @tanstack/table-core link failure).

Symptom

Undefined symbols for architecture arm64:
  "__getVisibleLeafColumns", referenced from: ...

Root cause

@tanstack/table-core's source uses the package-barrel idiom — features/ColumnSizing.ts does:

import { _getVisibleLeafColumns } from '..'   // '..' => the package index.ts

and index.ts does export * from './features/ColumnVisibility'.

The import resolver (crates/perry/src/commands/compile/resolve.rs) detected relative imports with starts_with("./") || starts_with("../"). The bare specifiers "." and ".." (current/parent directory imports — valid ECMAScript, resolving to that directory's index) match neither, so import { X } from '..' fell through to bare-package resolution. import.resolved_path was then never matched to the index module in native_modules, so every name imported through it lowered to an unresolved raw extern symbol (_getVisibleLeafColumns, not perry_fn_...) → link failure.

from '../index' worked only because it carries the "../" prefix. The leading underscore was a red herring — a directly-defined index export imported via from '..' failed identically.

Fix

A shared is_relative_specifier() helper that also matches exact "." / "..", used by resolve_relative_import_path, resolve_import, and the declaration-sidecar resolver.

Validation

  • Minimal repro (import { x } from '..' through an export * barrel) — was link-fail, now runs.
  • Real @tanstack/table-core: links and runs; createTable({...}).getRowModel().rows.length3, getAllLeafColumns().length1, matching Node byte-for-byte.
  • No regression: ./ and ../foo imports (uuid, dayjs, re-export repros) still resolve; -p perry resolve tests pass.

This is general — any import … from '.'/'..' (directory→index) was affected.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced module resolution to properly handle bare relative import specifiers (. and ..) consistently with explicit relative paths (./ and ../).

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d740a09-49ef-475a-9670-388c6ce2fc12

📥 Commits

Reviewing files that changed from the base of the PR and between cff3e30 and 90ab37e.

📒 Files selected for processing (1)
  • crates/perry/src/commands/compile/resolve.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/perry/src/commands/compile/resolve.rs

📝 Walkthrough

Walkthrough

is_relative_specifier is introduced in resolve.rs as a pub(super) predicate that returns true for "./", "../", ".", and ".." specifiers. Three existing inline prefix checks in declaration_sidecar_for_resolved_import, resolve_relative_import_path, and resolve_import are replaced with calls to this helper.

Changes

Relative specifier resolver fix

Layer / File(s) Summary
is_relative_specifier helper and call-site wiring
crates/perry/src/commands/compile/resolve.rs
Adds pub(super) fn is_relative_specifier that returns true for "./", "../", ".", and "..", then replaces three separate inline prefix checks in declaration_sidecar_for_resolved_import, resolve_relative_import_path, and resolve_import with calls to this predicate. Absolute "/…" specifiers remain excluded from relative handling.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hopping through the module maze,
A dot alone was lost for days.
Now "." and ".." know the way,
is_relative_specifier saves the day!
Every import finds its den — hooray! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is comprehensive, covering symptom, root cause, fix, and validation. However, required test plan checkboxes are not checked and no evidence of testing is provided in the template format. Mark test plan checkboxes to confirm testing was performed (cargo build, cargo test, etc.) and whether test files or other validation items apply.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: treating bare . and .. as relative directory imports, directly matching the core change in the resolver logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dir-import-dotdot-resolution

Comment @coderabbitai help to get the list of available commands and usage tips.

)

@tanstack/table-core failed to link (Undefined symbols: __getVisibleLeafColumns).
Its source uses 'import { _getVisibleLeafColumns } from ".."' (package barrel),
where '..' resolves to the package index.ts (export * from features/...).

The import resolver detected relative imports via starts_with("./")||"../";
bare '.' and '..' (directory imports resolving to index) matched neither, so
'from ".."' fell through to bare-package resolution, import.resolved_path
never matched the index module, and every name imported through it lowered to
an unresolved raw extern symbol -> link failure. 'from "../index"' worked.

Fix: shared is_relative_specifier() that also matches exact '.' / '..', used by
resolve_relative_import_path, resolve_import, and the declaration-sidecar
resolver. tanstack table-core now links and runs (getRowModel().rows.length=3,
matches Node). No regression on ./ or ../foo imports.
@proggeramlug proggeramlug force-pushed the fix/dir-import-dotdot-resolution branch from cff3e30 to 90ab37e Compare June 14, 2026 19:44
@proggeramlug proggeramlug merged commit bb67839 into main Jun 14, 2026
15 checks passed
@proggeramlug proggeramlug deleted the fix/dir-import-dotdot-resolution branch June 14, 2026 19:45
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.

compilePackages: @tanstack/table-core fails to link — undefined __getVisibleLeafColumns

1 participant