Skip to content

feat: import aliases setting and glob pattern resolution#2

Merged
runkids merged 3 commits into
runkids:mainfrom
hiro05097952:feat/alias-setting
Jun 9, 2026
Merged

feat: import aliases setting and glob pattern resolution#2
runkids merged 3 commits into
runkids:mainfrom
hiro05097952:feat/alias-setting

Conversation

@hiro05097952

@hiro05097952 hiro05097952 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add configurable importAliases setting (map of package name → repo path) so workspace package imports like @scope/shared-ui/images/icon.svg resolve to their actual repo paths
  • Key-value editor in Settings → Scanning section, alias changes trigger rescan
  • Resolve import.meta.glob patterns (**/*.avif) by expanding relative/alias base paths and matching with the existing matchPathParts glob engine

Screenshots

截圖 2026-06-09 上午11 44 43 截圖 2026-06-09 上午11 46 35

Test plan

  • TestResolveWithImportAliases — alias prefix matching, boundary check, fallback
  • TestBuildMapResolvesImportAliases — end-to-end alias reference detection
  • TestBuildMapResolvesGlobPatternimport.meta.glob with **/*.avif matches multiple assets
  • TestPathAndSpecifierHelpersrewriteSpecifier preserves alias format + query strings
  • All existing reference and action tests pass on both commits independently

hiro05097952 and others added 2 commits June 9, 2026 11:41
…ution

Add configurable importAliases (map[string]string) to settings so that
workspace package imports like @scope/shared-ui/images/icon.svg resolve
to their actual repo paths (packages/shared-ui/images/icon.svg).

Backend: resolveAlias with longest-prefix matching in Resolve and fuzzy
match, rewriteSpecifier preserves alias format during optimization apply,
aliases plumbed through ScanOptions and scanner.Project.

Frontend: key-value editor in ScanningSection, alias changes trigger
rescan via settingsCatalogInputsChanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pattern references like ./images/**/*.avif were matched by literal
suffix comparison which always failed for ** and * wildcards. Add
resolvePattern to expand the relative/alias base path while preserving
glob characters, then match candidates with the existing matchPathParts
glob engine.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for custom import aliases, allowing users to map package names to repository paths for accurate reference resolution. The changes span the Go backend (updating path resolution, reference scanning, and settings storage) and the React frontend (adding a UI section to manage import aliases). The review feedback highlights two key areas for improvement: first, sanitizing alias keys and values in Go (e.g., trimming slashes) to prevent malformed paths; second, avoiding the use of array indices as React keys in the settings UI by introducing unique IDs for alias entries in the draft state.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread internal/references/references.go
Comment thread internal/actions/actions.go
Comment thread ui/src/features/settings/ScanningSection.tsx Outdated
Comment thread ui/src/features/settings/ScanningSection.tsx
Comment thread ui/src/features/settings/helpers.ts
Comment thread ui/src/features/settings/types.ts Outdated
Trim leading/trailing slashes from alias keys and values in resolveAlias
and rewriteSpecifier to prevent double-slash or mismatched paths from
user input. Use filepath.Clean for robust path normalization.

Replace array index with unique id for import alias React list keys to
avoid DOM reuse glitches on add/delete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@runkids runkids merged commit d99ef9e into runkids:main Jun 9, 2026
3 checks passed
runkids added a commit that referenced this pull request Jun 9, 2026
Manual importAliases alone forces users to re-declare aliases their
projects already define in tsconfig/jsconfig paths and vite/next
resolve.alias. Detect those at scan time and merge them into the same
resolution map as the base layer, with manual entries overriding on key
collision, so reference resolution works zero-config for the common case.

- internal/aliasdetect: read tsconfig/jsconfig paths (baseUrl, relative
  extends chain) and vite/next resolve.alias (object + array forms,
  unwrapping path.resolve/fileURLToPath), normalized to repo-relative
- wire detection into scanner reference building and action-rewrite paths
- expose GET /api/settings/detected-aliases and surface detected aliases
  read-only in Scanning settings, grouped by project, marking entries
  overridden by the manual table
- fill ja/ko/zh-CN import-alias keys (PR #2 only added en/zh-TW) and add
  detected-alias keys across all five locales
- fix helpers.test.ts fixture missing importAliases that broke ui build
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