Commit bafac33
Replace fragile regex validation with Shakapacker 9.0+ integration
Addresses code review feedback about fragile regex matching by implementing
a proper integration with Shakapacker 9.0+ private_output_path.
**Key Changes:**
**1. Auto-Detection from Shakapacker (configuration.rb)**
- New `auto_detect_server_bundle_path_from_shakapacker` method
- Automatically reads `private_output_path` from Shakapacker 9.0+ config
- Only applies if user hasn't explicitly set `server_bundle_output_path`
- Gracefully falls back to default if detection fails
- Logs info message when auto-detection succeeds
**2. Removed Fragile Regex Validation (doctor.rb)**
- Removed `validate_server_bundle_path_sync` method (regex matching)
- Removed `extract_webpack_output_path` method (pattern detection)
- Removed `normalize_path` method (no longer needed)
- Replaced with `check_shakapacker_private_output_path` method
**3. Recommendation-Based Doctor Checks (doctor.rb)**
- Detects Shakapacker version and capabilities
- Pre-9.0: Recommends upgrading for better DX
- 9.0+ without config: Shows how to configure private_output_path
- 9.0+ with config matching: Success message
- 9.0+ with config mismatch: Warning with fix instructions
- No Shakapacker: Informs about manual configuration
**4. Updated Generator Templates**
- **React on Rails initializer**: Documents Shakapacker 9.0+ approach first
- **Webpack config**: Shows config.privateOutputPath pattern
- Both templates emphasize single source of truth in shakapacker.yml
- Clear migration path for older Shakapacker versions
**5. Comprehensive Test Coverage (8 new tests)**
- Shakapacker not defined scenario
- Pre-9.0 Shakapacker (no private_output_path support)
- 9.0+ with matching config
- 9.0+ with mismatched config
- 9.0+ without config
- Error handling
- All tests passing
**Benefits:**
- No fragile regex parsing of webpack configs
- Single source of truth in shakapacker.yml
- Automatic configuration for Shakapacker 9.0+ users
- Backward compatible with older Shakapacker versions
- Clear upgrade path and recommendations
- Robust error handling
**Breaking Changes:** None
- Existing configurations continue to work
- Auto-detection only applies to default values
- Explicit user configuration always takes precedence
Addresses: @justin's feedback on PR #1967
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent dd0d5ba commit bafac33
File tree
5 files changed
+165
-234
lines changed- lib
- generators/react_on_rails/templates/base/base/config
- initializers
- webpack
- react_on_rails
- spec/lib/react_on_rails
5 files changed
+165
-234
lines changedLines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
52 | 53 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | 48 | | |
51 | | - | |
52 | | - | |
| 49 | + | |
53 | 50 | | |
54 | | - | |
55 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
56 | 62 | | |
57 | 63 | | |
58 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
217 | 247 | | |
218 | 248 | | |
219 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
689 | | - | |
| 688 | + | |
| 689 | + | |
690 | 690 | | |
691 | 691 | | |
692 | 692 | | |
| |||
1158 | 1158 | | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | | - | |
1162 | | - | |
1163 | | - | |
1164 | | - | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1168 | 1166 | | |
1169 | 1167 | | |
1170 | 1168 | | |
1171 | | - | |
1172 | | - | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
1173 | 1173 | | |
1174 | | - | |
1175 | | - | |
| 1174 | + | |
| 1175 | + | |
1176 | 1176 | | |
1177 | | - | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
1178 | 1184 | | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
1182 | 1188 | | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
| 1189 | + | |
| 1190 | + | |
1188 | 1191 | | |
1189 | | - | |
1190 | | - | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
1191 | 1198 | | |
1192 | | - | |
1193 | | - | |
| 1199 | + | |
| 1200 | + | |
1194 | 1201 | | |
1195 | | - | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1196 | 1209 | | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
| 1210 | + | |
| 1211 | + | |
1200 | 1212 | | |
1201 | | - | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
1202 | 1217 | | |
1203 | 1218 | | |
1204 | 1219 | | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
1215 | | - | |
1216 | | - | |
1217 | | - | |
1218 | | - | |
1219 | | - | |
1220 | | - | |
1221 | | - | |
1222 | | - | |
1223 | | - | |
1224 | | - | |
1225 | | - | |
| 1220 | + | |
1226 | 1221 | | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | 1222 | | |
| 1223 | + | |
1246 | 1224 | | |
1247 | 1225 | | |
1248 | 1226 | | |
0 commit comments