HMR Not Working
Symptoms
The server doesnβt automatically restart when you modify files.Causes
- HMR boundary not properly configured
- File watcher not detecting file changes
- HMR failure due to circular dependencies
Solutions
1. Restart Development Server
2. Check HMR Boundary
HMR boundary is configured inhmr-hook-register.ts:
3. Increase File Watcher Limit (Linux/macOS)
4. Check .gitignore Patterns
Performance issues can occur if HMR watches directories likenode_modules or dist.
Error After File Change
Symptoms
HMR works when you modify files but errors occur:Causes
- Circular dependency
- Dynamic import not properly handled
- ESM/CommonJS mixing
Solutions
1. Check Circular Dependencies
2. Check Dynamic Imports
Avoid dynamic imports within HMR boundaries:Type Error After HMR
Symptoms
TypeScript type errors occur after HMR runs:Cause
TypeScript server didnβt recognize HMR changes.Solutions
1. Restart TypeScript Server
VSCode:2. Restart Editor
3. Check tsconfig.json
HMR Performance Degradation
Symptoms
HMR is slow or server freezes every time you save a file.Causes
- Too many files included in HMR boundary
- Heavy computations running at module loading time
- Memory leak
Solutions
1. Optimize HMR Boundary
Modify boundary pattern inhmr-hook-register.ts:
2. Optimize Module Initialization
Use lazy loading for heavy computations:3. Memory Profiling
HMR Boundary Configuration Error
Symptoms
Cause
HMR boundary pattern is incorrect.Solution
Use correct glob patterns inhmr-hook-register.ts:
HMR Not Working for Specific Files
Symptoms
HMR works fine for most files, but specific files donβt restart when changed.Causes
- File doesnβt match HMR boundary pattern
- File is explicitly excluded
- File is cached by other modules