feat: import aliases setting and glob pattern resolution#2
Conversation
…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>
There was a problem hiding this comment.
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.
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>
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
Summary
importAliasessetting (map of package name → repo path) so workspace package imports like@scope/shared-ui/images/icon.svgresolve to their actual repo pathsimport.meta.globpatterns (**/*.avif) by expanding relative/alias base paths and matching with the existingmatchPathPartsglob engineScreenshots
Test plan
TestResolveWithImportAliases— alias prefix matching, boundary check, fallbackTestBuildMapResolvesImportAliases— end-to-end alias reference detectionTestBuildMapResolvesGlobPattern—import.meta.globwith**/*.avifmatches multiple assetsTestPathAndSpecifierHelpers—rewriteSpecifierpreserves alias format + query strings