Fix/vite path alias configuration 142#202
Merged
Merged
Conversation
Map the @ alias to the src directory so all @/ imports resolve correctly at build time. Without this, Vite cannot resolve modules like @/services/RateLimitService or @/types/rateLimit. Closes #142
index.charting.ts was re-exporting from @/hooks/useChartingHooks which never existed. The charting hooks were split across four separate files: useChartState, useChartIndicators, useChartDrawing, and useChartRendering. Update the re-exports to point to the files that actually exist.
Both configs now use path as a default import and call path.resolve() for the @ alias, keeping the two config files consistent.
vitest.config.ts imports from the node path module and needs to be covered by the node tsconfig so TypeScript resolves the Node types correctly for both config files.
Replace ../services/RateLimitService with @/services/RateLimitService to be consistent with the rest of the codebase and to rely on the resolved path alias rather than a fragile relative path.
All nine re-exports were using ../ relative paths. Replace them with @/ alias imports to match the project convention and ensure they resolve correctly through the Vite alias configuration.
Replace ../services/RateLimitService with @/services/RateLimitService to match the project-wide convention and resolve through the Vite path alias rather than a relative path.
Replace ../types/market with @/types/market for both the type import and the value import to be consistent with the rest of the codebase.
Replace ../utils/networkUtils with @/utils/networkUtils to match the project convention for cross-directory imports.
Replace ../components/* and ../hooks/* relative paths with @/ alias imports for ErrorBoundary, PageErrorBoundary, ErrorMessage, and useErrorHandler.
templateStorage.ts and cacheHelpers.ts both imported GDPRComplianceService and SecureStorageV2Service using ../services/ relative paths. Replace with @/ alias imports to match the project convention.
Replace ../types/market and ../types/analytics relative imports with @/ alias paths in marketValidation.ts and analytics.ts.
…ketAnalyzer Replace ../types/market, ../types/accessibility, and ../types/websocket relative imports with @/ alias paths in the three utility files.
Replace ../types/template and ../types/notifications relative imports with @/ alias paths in templateValidation.ts, notificationTemplates.ts, and templateSuggestions.ts.
Replace ../types/template in config/templates.ts and ../utils/marketCategories in types/filters.ts with @/ alias imports.
Replace ../types/network and ../utils/networkUtils relative imports with @/ alias paths in NetworkContext.tsx.
…listContext Replace ../utils/recentlyViewed and ../utils/watchlist relative imports with @/ alias paths in both context files.
Bulk convert all cross-directory relative imports in src/utils/ and src/constants/ to use the @/ path alias. Covers contractErrorHandler, networkUtils, transactions, gdprInitializer, storageAudit, stakeHistory, referralTracking, explorerLinks, exportHelpers, exportValidator, notificationHelpers, portfolioHelpers, reputationAnalytics, reputationCalculations, reputationHelpers, reputationUtils, stakingHelpers, templateAnalytics, templateHelper, websocketUtils, and constants/index.
Bulk convert all cross-directory relative imports in src/hooks/ and src/services/ to use the @/ path alias. Covers all 66 files including useContract, useMarkets, useStake, useGovernance, useLiquidity, useExport, useNotifications, useRateLimit, ApiClient, ExportService, NotificationService, RealtimeMarketClient, and all other hooks and services that were using ../ relative paths.
Bulk convert all cross-directory relative imports in src/components/, src/pages/, and src/examples/ to use the @/ path alias. Covers all 97 files including MarketForm, MarketCard, Header, Footer, NetworkContext consumers, all page components, and example files that were using ../ relative paths to reach services, types, hooks, utils, and contexts.
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.
What was fixed:
vite.config.ts — added resolve.alias mapping @ to ./src, removed redundant test block and inline comments
index.charting.ts — replaced broken re-export from non-existent useChartingHooks with the four actual hook files that exist
vitest.config.ts — aligned path import style with vite.config.ts for consistency
tsconfig.node.json — added vitest.config.ts to the include array so Node types resolve correctly for both config files
184 source files across middleware/, utils/, constants/, hooks/, services/, components/, pages/, examples/, contexts/, config/, and types/ — all cross-directory ../ relative imports converted to @/ alias imports
Closes #142