|
180 | 180 | # Matches: |
181 | 181 | # - "^ERROR in ./": Webpack's standard error format for file-specific errors |
182 | 182 | # - "failed to compile": Direct compilation failure message |
183 | | -# - "compilation failed": Explicit failure message |
| 183 | +# - "COMPILATION FAILED": Shakapacker's explicit failure message (uppercase) |
184 | 184 | # - "Module build failed": Loader/build errors (e.g., babel, css-loader failures) |
185 | | -if grep -Ei "^ERROR in [./]|failed to compile|compilation failed|Module build failed" "$OUTPUT_FILE"; then |
| 185 | +if grep -Ei "^ERROR in [./]|failed to compile|COMPILATION FAILED|Module build failed" "$OUTPUT_FILE"; then |
186 | 186 | report_error "Webpack compilation errors detected." |
187 | 187 | echo " Sample matching lines:" |
188 | | - grep -Ei "^ERROR in [./]|failed to compile|compilation failed|Module build failed" "$OUTPUT_FILE" | head -3 |
| 188 | + grep -Ei "^ERROR in [./]|failed to compile|COMPILATION FAILED|Module build failed" "$OUTPUT_FILE" | head -3 |
| 189 | + # Show context around COMPILATION FAILED for more useful error info |
| 190 | + if grep -q "COMPILATION FAILED" "$OUTPUT_FILE"; then |
| 191 | + echo "" |
| 192 | + echo " Context around compilation failure:" |
| 193 | + grep -A 20 "COMPILATION FAILED" "$OUTPUT_FILE" | head -25 |
| 194 | + fi |
| 195 | + FAILURES_FOUND=1 |
| 196 | +fi |
| 197 | + |
| 198 | +# ============================================================================== |
| 199 | +# Pattern 4b: Missing webpack CLI |
| 200 | +# ============================================================================== |
| 201 | +# Prevents: Confusing errors when webpack-cli is not installed. |
| 202 | +# Webpack 5+ requires webpack-cli as a separate dependency. |
| 203 | +# Symptom: "CLI for webpack must be installed" message during compilation. |
| 204 | +if grep -q "CLI for webpack must be installed" "$OUTPUT_FILE"; then |
| 205 | + report_error "webpack-cli is not installed." |
| 206 | + echo " This is a required dependency for webpack builds." |
| 207 | + echo " To fix: pnpm add -D webpack-cli" |
| 208 | + echo " Or: npm install -D webpack-cli" |
189 | 209 | FAILURES_FOUND=1 |
190 | 210 | fi |
191 | 211 |
|
|
0 commit comments