Commit 850deed
fix: Add Rspack and TypeScript support to shared JS dependency manager
This commit addresses critical issues identified in code review:
### 1. Added Missing Rspack Support
- **Problem**: Rspack dependencies were lost during the refactor to shared module
- **Solution**: Added RSPACK_DEPENDENCIES and RSPACK_DEV_DEPENDENCIES constants
- **Implementation**:
- Created `add_rspack_dependencies` method in shared module
- Modified `add_dev_dependencies` to use Rspack-specific dev deps when `options.rspack?` is true
- Conditional installation in `add_js_dependencies` checks for `options.rspack?`
- **Impact**: Users with --rspack flag now get proper Rspack packages installed
### 2. Fixed TypeScript Dependency Consistency
- **Problem**: TypeScript dependency handling was inconsistent with shared module pattern
- **Solution**: Extracted TypeScript dependencies into shared module
- **Implementation**:
- Added TYPESCRIPT_DEPENDENCIES constant
- Created `add_typescript_dependencies` method following same pattern as other deps
- Updated `install_generator.rb` to delegate to shared method
- Removed manual instance variable setting
- **Impact**: Consistent error handling and pattern across all dependency types
### 3. Documented Unconditional Install Behavior
- **Problem**: Unclear why `install_js_dependencies` is called unconditionally
- **Solution**: Added comprehensive documentation explaining the design decision
- **Rationale**:
- package_json gem's install is idempotent - only installs what's needed
- Prevents edge cases where package.json modified but dependencies not installed
- Safer and simpler than conditional logic that could miss cases
- **Impact**: Future maintainers understand why the unconditional call is correct
### 4. Enhanced Module Documentation
- **Updated Instance Variables section**: Clarified module initializes variables
- **Added Optional Methods section**: Documents options.rspack? and options.typescript?
- **Added Installation Behavior section**: Explains idempotent install behavior
- **Impact**: Clear contract for classes including the module
### 5. Constants Usage Verification
- Verified all constants (REACT_DEPENDENCIES, CSS_DEPENDENCIES, DEV_DEPENDENCIES) are properly used
- All dependency methods use their corresponding constants correctly
### Testing
- ✅ All tests pass (6 examples, 0 failures)
- ✅ bundle exec rubocop passes with zero offenses
- ✅ Git hooks (pre-commit, pre-push) verified clean
### Files Changed
- `lib/generators/react_on_rails/js_dependency_manager.rb`: Added Rspack, TypeScript support, enhanced docs
- `lib/generators/react_on_rails/install_generator.rb`: Simplified TypeScript method to delegate to shared module
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 9fb7ffa commit 850deed
File tree
2 files changed
+80
-22
lines changed- lib/generators/react_on_rails
2 files changed
+80
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 368 | + | |
| 369 | + | |
385 | 370 | | |
386 | 371 | | |
387 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
| |||
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
46 | | - | |
| 58 | + | |
47 | 59 | | |
48 | 60 | | |
49 | 61 | | |
50 | 62 | | |
51 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
52 | 85 | | |
53 | 86 | | |
54 | 87 | | |
55 | 88 | | |
56 | 89 | | |
57 | 90 | | |
58 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
59 | 98 | | |
60 | 99 | | |
61 | 100 | | |
62 | 101 | | |
63 | 102 | | |
64 | 103 | | |
65 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
66 | 108 | | |
67 | 109 | | |
68 | 110 | | |
| |||
104 | 146 | | |
105 | 147 | | |
106 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
107 | 173 | | |
108 | 174 | | |
109 | 175 | | |
110 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
111 | 184 | | |
112 | 185 | | |
113 | 186 | | |
114 | | - | |
| 187 | + | |
115 | 188 | | |
116 | 189 | | |
117 | 190 | | |
| |||
0 commit comments