TRD: Replace relative imports with path aliases in libs/ui - #456
Merged
Conversation
Plans the migration of 1,664 cross-directory relative imports in libs/ui and 33 in the frontend apps to path aliases, split into 14 PR-sized phases. Key decisions captured: a separate @ui/* namespace for intra-library deep imports so the public @gatherloop-pos/ui entry points stay narrow; path-equivalent rewrites only, so the module graph is unchanged; and a Phase 1 spike to prove the six resolvers (tsc, two Jest configs, Next, Metro, Storybook, Playwright) before 730 files are touched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0184EpDzDv6jRR4pDooUiBCN
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds a Technical Requirements Document (TRD) that proposes a phased migration to replace relative imports with path aliases across
libs/uiand the frontend apps. The migration addresses three concrete costs of relative imports: ambiguous paths that don't indicate their target, cross-project boundary violations, and a load-bearing Jest mapper regex that breaks silently on import shape changes.Key changes
docs/trd-import-alias-migration.md(643 lines)libs/ui/src@ui/*for internal deep paths and@gatherloop-pos/api-contract/clientfor a previously-unaliased exportNotable design decisions
@ui/*namespace, not@gatherloop-pos/ui/*, to preserve the structural guarantee that apps cannot deep-import and to make the distinction visible in diffs.storybook/mocks/mockData.tsfile moves tolibs/ui/src/__fixtures__/mockData.tsto make it addressable by the@ui/*alias and to fix the architectural inversion of unit tests importing from Storybook config.eslintrc.jsonmust allow@ui/*in the@nx/enforce-module-boundariesrule to permit self-imports through the internal aliaseslint-plugin-no-relative-import-pathsand fixing three lint rules the migration invalidatesPhased delivery structure
The migration is split into 13 phases:
Each phase is one PR that leaves
maingreen and the product shippable. Phases 3–11 are independent of each other (D10) and may be parallelized or reordered.Verification strategy
Because CI runs no lint, typecheck, or build (only
npx nx run ui:testandnpx nx run api:test), every phase PR must include output from six targets in its description:npx tsc -p libs/ui/tsconfig.lib.json --noEmitnpx nx run ui:lintnpx nx run ui:testnpx nx run pos-web:buildnpx nx run order-web:buildnpx nx run ui:build-storybookPlus a Metro bundle and e2e suites in Phase 1 and Phase 13.
Open questions for Phase 1 review
@ui/*or@gatherloop-pos/ui/*? (D1 argues for@ui/*; must decide before Phasehttps://claude.ai/code/session_0184EpDzDv6jRR4pDooUiBCN