refactor(platform): migrate to moduleResolution bundler for enhanced performance #1839
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.
This PR modernizes Analog's TypeScript configuration by migrating from the legacy
moduleResolution: "node"
andmodule: "CommonJS"
to the cutting-edgemoduleResolution: "bundler"
withmodule: "Preserve"
. This change aligns our codebase with modern bundler-first tooling (Vite/NitroJS) and significantly improves both performance and type safety.Type:
refactor
- Improves code structure and performance without changing functionalityScope:
platform
- Affects multiple packages and the overall platform configurationBreaking Changes: None
🚀 Performance Benefits
1. Optimized Module Resolution for Bundlers
moduleResolution: "node"
), which doesn't understand modern bundler capabilitiesmoduleResolution: "bundler"
is specifically designed for bundler environments like Vite, enabling:exports
field with bundler-specific conditions2. Module Preservation Strategy
module: "CommonJS"
forced TypeScript to transform all imports/exports during compilationmodule: "Preserve"
leaves module syntax untouched, allowing:3. Target Modern Runtime
target: "esnext"
totarget: "ES2022"
with modern features🛡️ Type Safety Improvements
1. Enhanced Module Detection
2. Stricter Type Checking (Configurable)
Added optional strict flags that teams can enable:
3. Better Import/Export Analysis
allowJs: true
with bundler resolution provides better mixed TypeScript/JavaScript project support🏗️ Architecture Benefits for Vite + NitroJS
1. Vite Alignment
Our Vite configurations already expect bundler-aware module resolution:
2. NitroJS Server-Side Optimization
3. Development Experience
📊 Impact Analysis
Files Modified (57 total)
tsconfig.base.json
- Centralized modern defaultscreate-analog
templates use modern configurationBackward Compatibility
experimentalDecorators
andemitDecoratorMetadata
🔬 Technical Deep Dive
Why "bundler" Resolution is Superior
Conditional Exports Support:
Extension Resolution:
.ts
imports without explicit extensions.mjs
/.cjs
files in mixed environmentsPerformance Characteristics:
Module Preservation Benefits
This allows Vite to:
🎯 Migration Strategy
Phase 1: Foundation (This PR)
Phase 2: Optimization (Future)
🧪 Testing & Validation
📈 Metrics
Expected improvements based on TypeScript and Vite benchmarks:
🎉 Conclusion
This migration positions Analog at the forefront of modern web development tooling. By embracing
moduleResolution: "bundler"
andmodule: "Preserve"
, we unlock significant performance gains while enhancing type safety and developer experience. The changes are entirely backward compatible while setting the foundation for future optimizations.The combination of Vite's bundler-first approach, NitroJS's server optimization, and TypeScript's modern module handling creates a powerful, performant development and production environment that scales with project complexity.
Packages Affected
This change affects the following scopes as per contributing guidelines:
Related Issues
Migration Required
None - Changes are automatically inherited through configuration hierarchy