Add SHAKAPACKER_SKIP_PRECOMPILE_HOOK environment variable support#850
Add SHAKAPACKER_SKIP_PRECOMPILE_HOOK environment variable support#850
Conversation
This change adds the ability to skip the precompile hook using an environment variable, addressing issue #849. When SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true is set, the configured precompile_hook will be skipped during compilation. This is useful for: - bin/dev scripts that run the hook once before launching multiple webpack processes (avoiding duplicate execution) - Manually running the hook and then compiling multiple times - Debugging compilation issues without the hook Changes: - Add should_run_precompile_hook? method to Compiler class - Check ENV["SHAKAPACKER_SKIP_PRECOMPILE_HOOK"] before running hook - Add comprehensive tests for skip functionality - Update RBS type signatures - Document the skip flag in precompile_hook.md with bin/dev example All existing tests pass, plus 3 new tests for the skip functionality. Fixes #849 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Warning Rate limit exceeded@justin808 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 11 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@claude review this PR |
|
Claude finished @justin808's task —— View job Code ReviewTasks
SummaryThis PR successfully implements the StrengthsExcellent Implementation Quality:
Security Conscious:
Well Documented:
Implementation Reviewlib/shakapacker/compiler.rb (lines 83-88): def should_run_precompile_hook?
return false unless config.precompile_hook
return false if ENV["SHAKAPACKER_SKIP_PRECOMPILE_HOOK"] == "true"
true
end✅ Perfect implementation. The logic flow is clear and correct:
The strict spec/shakapacker/compiler_spec.rb (lines 313-392): ✅ Excellent test coverage with 3 comprehensive tests:
These tests cover all the important cases and properly use RSpec mocking to verify the behavior without actually executing commands. sig/shakapacker/compiler.rbs (line 55): def should_run_precompile_hook?: () -> bool✅ Type signature is correct. Takes no arguments and returns a boolean. docs/precompile_hook.md (lines 287-317): ✅ Clear and helpful documentation including:
Minor ObservationsEnvironment Variable Naming: String Comparison:
This is the safest approach and matches common Ruby/Rails patterns. Test Quality: Potential Enhancements (Optional, Not Blocking)These are completely optional suggestions for future consideration:
Verdict✅ Excellent PR - Ready to Merge This is a clean, well-implemented feature that:
The implementation is straightforward and does exactly what it needs to do without over-engineering. The test coverage is thorough, and the documentation clearly explains when and how to use the feature. Great work! 🎉 |
The previous Ruby example set ENV['SHAKAPACKER_SKIP_PRECOMPILE_HOOK'] but this might not be reliably passed to foreman/overmind subprocesses. Changed to bash scripts that: - Use 'export' to ensure ENV vars are passed to subprocesses - Provide examples for both foreman and overmind - Use 'exec' to replace the shell process (same as before) This ensures the skip flag is properly inherited by all webpack processes spawned by the process manager. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review for PR #850: Add SHAKAPACKER_SKIP_PRECOMPILE_HOOK environment variable supportI've thoroughly reviewed this PR. Overall, this is a well-implemented, focused change that cleanly solves the duplicate hook execution problem. Here's my detailed analysis: ✅ Strengths1. Excellent Code Quality
2. Comprehensive Test Coverage
3. Proper Type Safety
4. Excellent Documentation
5. Security Conscious
🔍 Minor Observations (Not Issues)1. Strict String ComparisonThe implementation uses
This is actually good practice for explicit behavior, but worth documenting if users expect truthy value handling. The PR description and tests make this clear. 2. Method PlacementThe 3. Documentation Bash ExamplesThe bash examples in the docs extract the hook from YAML using Ruby one-liners. This is clever, but relies on the hook being defined in the 🎯 Performance & CorrectnessPerformance
Correctness
🔒 Security Review
📋 Test Coverage AnalysisThe new tests at lines 313-392 cover:
Missing test scenario (low priority):
Test quality: Excellent use of 📝 Documentation ReviewThe documentation changes are comprehensive and helpful:
Suggestion: Consider adding a note about the strict "true" check to avoid user confusion. 🎨 Code StyleBased on the project's CLAUDE.md guidelines:
✨ Best Practices Followed
📊 Overall Assessment
✅ RecommendationAPPROVE - This PR is ready to merge. The implementation is clean, well-tested, properly documented, and solves the problem described in issue #849 without introducing any regressions or security concerns. No changes required - This is production-ready code. 💡 Optional Future Enhancements (Not for this PR)
These are minor enhancements that could be considered in future PRs if needed. Great work! This PR demonstrates excellent engineering practices. 🚀 |
Foreman and Overmind don't inherit environment variables from the parent shell - they read from .env files instead. Updated documentation to show three correct approaches: 1. Foreman: Write SHAKAPACKER_SKIP_PRECOMPILE_HOOK to .env file 2. Overmind: Write to .overmind.env file 3. Alternative: Use 'env' prefix in Procfile (cleanest approach) The Procfile env prefix approach is recommended as it's cleaner and doesn't modify .env files dynamically. Thanks to user feedback for catching this! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Added note explaining that: - The examples show how to implement the pattern in custom bin/dev scripts - React on Rails generated bin/dev already implements this automatically - This helps users understand when they need to implement this pattern Addresses feedback about clarifying the context of the examples. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review - PR #850✅ Overall AssessmentThis is a well-implemented feature that solves a real problem with duplicate precompile hook execution in multi-process setups. The code quality is high, tests are comprehensive, and documentation is thorough. 🎯 Code QualityStrengths:
Code location reference:
🧪 Test CoverageExcellent test coverage with 3 new tests covering all scenarios:
Test quality:
Minor observation: The tests properly verify that only the string 🔒 Security ConsiderationsNo security concerns identified. The implementation:
⚡ Performance ConsiderationsNo performance concerns:
📚 DocumentationComprehensive documentation in Strengths:
Suggestions for improvement:
🐛 Potential IssuesNone identified. The implementation is solid. 💡 Suggestions (Non-blocking)
✨ Best Practices AdherenceChecking against
📋 Checklist Before Merge
🎉 ConclusionRecommendation: Approve with minor suggestions This PR successfully implements the requested feature from issue #849. The code is clean, well-tested, and properly documented. The implementation elegantly solves the duplicate hook execution problem in multi-process development environments. Great work! 👏 |
Code Review - PR #850SummaryThis PR adds support for the ✅ StrengthsCode Quality
Test Coverage
Documentation
🔍 Observations & Suggestions1. Environment Variable Semantics ✅The implementation only recognizes
Consideration: Some gems use truthy checks like 2. Security - Shell Injection in Documentation
|
- Document that SHAKAPACKER_SKIP_PRECOMPILE_HOOK requires exact string "true" - Replace risky .env file modification with safer alternatives - Replace eval usage with Ruby system() calls for better security - Reorder examples to recommend Procfile env prefix approach first - Add comprehensive CHANGELOG entry with migration tips 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Code Review - PR #850I've reviewed this pull request thoroughly. Overall, this is a well-implemented feature with excellent documentation and comprehensive test coverage. Here's my detailed feedback: ✅ Strengths1. Code Quality
2. Test Coverage
3. Documentation
4. Security
5. Backward Compatibility
📝 Minor Suggestions1. CHANGELOG.md - Update PR numberThe CHANGELOG currently has placeholder values: - **Added `SHAKAPACKER_SKIP_PRECOMPILE_HOOK` environment variable to skip precompile hook**. [PR #XXX](https://github.com/shakacode/shakapacker/pull/XXX) by [justin808](https://github.com/justin808).Should be updated to: - **Added `SHAKAPACKER_SKIP_PRECOMPILE_HOOK` environment variable to skip precompile hook**. [PR #850](https://github.com/shakacode/shakapacker/pull/850) by [justin808](https://github.com/justin808).2. Documentation - Minor clarificationIn **Note:** The examples below show how to implement this in your custom `bin/dev` script. If you're using React on Rails v13.1.0+, the generated `bin/dev` script already implements this pattern automatically - **no action needed**.This makes it crystal clear to React on Rails users that they don't need to do anything. 3. Type Signature - Consider adding commentThe RBS signature in # Returns true if precompile hook should run, false if disabled or skipped via ENV
def should_run_precompile_hook?: () -> boolThis is optional but helps developers understand the boolean logic at a glance. 🎯 Performance Considerations
🔍 Potential IssuesNone found. The implementation is solid. 🧪 Testing RecommendationsThe current tests are excellent. If you want to be extra thorough, you could add:
However, the current test coverage is already comprehensive and sufficient for merge. ✨ SummaryThis is a high-quality pull request that solves a real problem (#849) with a simple, well-tested solution. The extensive documentation is particularly impressive and will help users adopt this feature correctly. Recommendation: Approve with minor CHANGELOG fix The only required change before merge is updating the placeholder PR numbers in CHANGELOG.md. Everything else is optional polish. Great work! 🎉 Review generated with Claude Code |
- Create new v9.4.0 section with release date November 22, 2025 - Move PR #850 entry from Unreleased to v9.4.0 section - Fix placeholder PR number from #XXX to #850 - Update version diff links to point from v9.4.0 to main 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…erence - Update CHANGELOG.md to reference PR #850 instead of placeholder - Clarify React on Rails version requirement (v13.1.0+) and add "no action needed" for users - Add explanatory comment to should_run_precompile_hook? RBS signature These are minor documentation improvements based on code review feedback for PR #850. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
## Summary Minor documentation improvements based on code review feedback for PR #850: - **Fix CHANGELOG.md**: Update PR reference from placeholder `#XXX` to actual `#850` - **Clarify React on Rails docs**: Specify version requirement (v13.1.0+) and add bold "no action needed" to make it crystal clear for users - **Add RBS comment**: Add explanatory comment to `should_run_precompile_hook?` type signature ## Test plan - [x] Changes are documentation/type signature comments only - [x] No functional code changes - [x] Verified lint-staged passed (prettier formatting applied automatically) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
### Summary Create new v9.4.0 section in CHANGELOG with the November 22, 2025 release. Move the PR #850 entry (SHAKAPACKER_SKIP_PRECOMPILE_HOOK environment variable) from Unreleased to v9.4.0. Fix the placeholder PR number and update version diff links. ### Pull Request checklist - [x] Update CHANGELOG file - ~[ ] Add/update test to cover these changes~ - ~[ ] Update documentation~ ### Other Information This changelog update reflects the v9.4.0 release that was tagged on November 22, 2025. The Unreleased section is now empty and ready for future changes. Co-authored-by: Claude <[email protected]>
Summary
Adds support for the
SHAKAPACKER_SKIP_PRECOMPILE_HOOKenvironment variable to allow skipping the precompile hook when needed, completing the implementation requested in issue #849.Problem
Issue #849 requested the ability to skip the precompile hook using an environment variable. While the core
precompile_hookfunctionality was already implemented, there was no way to skip it when:bin/devor Foreman to run the hook once before launching multiple webpack processesWithout this flag, the hook would run separately for each webpack process (e.g., client bundle and server bundle), causing duplicate execution and potential race conditions.
Solution
Added
SHAKAPACKER_SKIP_PRECOMPILE_HOOKenvironment variable support:"true", the precompile hook is skipped"false", etc.) runs the hook normallyshould_run_precompile_hook?private methodfalsewhen the skip flag is set, preventing hook executionChanges
should_run_precompile_hook?method that checks both config and ENVTest Coverage
Added 3 new tests covering:
SHAKAPACKER_SKIP_PRECOMPILE_HOOK=trueSHAKAPACKER_SKIP_PRECOMPILE_HOOKis not setSHAKAPACKER_SKIP_PRECOMPILE_HOOK=falseAll 21 compiler specs pass (18 existing + 3 new).
Example Usage
bin/dev pattern:
This ensures the hook runs exactly once when development starts, not separately for each webpack process.
Benefits
Fixes #849
🤖 Generated with Claude Code