Skip to content

Commit 85b91b3

Browse files
justin808claude
andcommitted
Improve precompile validation error messages
- Show context (20 lines) after COMPILATION FAILED to reveal actual error - Add specific pattern to detect missing webpack-cli with actionable fix - The validation script now provides much clearer error messages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3a58396 commit 85b91b3

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

script/validate-precompile-output

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,32 @@ fi
180180
# Matches:
181181
# - "^ERROR in ./": Webpack's standard error format for file-specific errors
182182
# - "failed to compile": Direct compilation failure message
183-
# - "compilation failed": Explicit failure message
183+
# - "COMPILATION FAILED": Shakapacker's explicit failure message (uppercase)
184184
# - "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
186186
report_error "Webpack compilation errors detected."
187187
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"
189209
FAILURES_FOUND=1
190210
fi
191211

0 commit comments

Comments
 (0)