Commit 9c5422f
Improve pack generation to avoid unnecessary subprocess spawning
Refactors pack_generator.rb to intelligently choose between direct Rake
task execution and bundle exec based on the current context. When running
in a Rails/Bundler environment (e.g., from bin/dev), the pack generation
now runs the Rake task directly, avoiding the overhead of spawning a
subprocess.
Key improvements:
- Adds run_pack_generation method that detects Rails availability
- Implements run_rake_task_directly for in-process execution when Rails is available
- Falls back to run_via_bundle_exec when Rails is not available
- Includes proper silent mode handling for both execution paths
- Prevents dead code by ensuring Rails is always defined before use
This change is based on the optimization from the shakapacker-9.3.0 branch
(commit b716f08), which already excluded the dead code that would have
checked for Rails being defined when it's guaranteed to be present.
Fixes #1909
Generated with Claude Code (https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent fe363a9 commit 9c5422f
1 file changed
+59
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
24 | 81 | | |
25 | 82 | | |
26 | 83 | | |
| |||
0 commit comments