shakapacker 9.3.4 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/docs/precompile_hook.md +98 -0
- data/lib/shakapacker/compiler.rb +8 -1
- data/lib/shakapacker/version.rb +1 -1
- data/package.json +1 -1
- data/sig/shakapacker/compiler.rbs +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a0519c935e0e3d98204aeaeec6cc35b57fa13be1fe8a6f62e5e6cd5124d09c7
|
|
4
|
+
data.tar.gz: 7f6fe4134fd9b17de2dcd26b5c9e80f1f41d2019dfa0ed337092c1d23a9aa077
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8789ef5d5cf102254f27c0833b3a7bd8239b5b97d2dfa97ac79fb01827931397dc71dd35f82971a61354a1751f6dafd80d91a322e51b6390f83132f17a786626
|
|
7
|
+
data.tar.gz: 3a6cff63ba261b9cec55cdd683e7cfa96a24e52b753639643bf2f6874ed49c0f50a990a771a85c4265e9e6394a8fc7e8b4e3440ed5d62982f89b98cddadf9450
|
data/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
|
|
12
12
|
Changes since the last non-beta release.
|
|
13
13
|
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **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). Set `SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true` to skip the precompile hook during compilation. This is useful when using process managers like Foreman or Overmind to run the hook once before starting multiple webpack processes, preventing duplicate hook execution. **Migration tip:** If you have a custom `bin/dev` script that starts multiple webpack processes, you can now run the precompile hook once in the script and set this environment variable to prevent each webpack process from running the hook again. See the [precompile hook documentation](./docs/precompile_hook.md#skipping-the-hook) for implementation examples.
|
|
17
|
+
|
|
14
18
|
## [v9.3.4-beta.0] - November 17, 2025
|
|
15
19
|
|
|
16
20
|
### Fixed
|
data/Gemfile.lock
CHANGED
data/docs/precompile_hook.md
CHANGED
|
@@ -284,6 +284,104 @@ default:
|
|
|
284
284
|
|
|
285
285
|
## Advanced Usage
|
|
286
286
|
|
|
287
|
+
### Skipping the Hook
|
|
288
|
+
|
|
289
|
+
You can skip the precompile hook using the `SHAKAPACKER_SKIP_PRECOMPILE_HOOK` environment variable:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true bin/shakapacker
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Important:** The environment variable must be set to the exact string `"true"` to skip the hook. Any other value (including `"false"`, `"1"`, or empty string) will run the hook normally.
|
|
296
|
+
|
|
297
|
+
This is useful when:
|
|
298
|
+
|
|
299
|
+
- Using `bin/dev` or Foreman to run the hook once before starting multiple webpack processes
|
|
300
|
+
- Running the hook manually and then compiling multiple times
|
|
301
|
+
- Debugging compilation issues without the hook
|
|
302
|
+
|
|
303
|
+
**Note:** The examples below show how to implement this in your custom `bin/dev` script. If you're using React on Rails, the generated `bin/dev` script already implements this pattern automatically - it runs the precompile hook once before launching processes, then sets `SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true` to prevent duplicate execution.
|
|
304
|
+
|
|
305
|
+
**Recommended: Use Procfile env prefix**
|
|
306
|
+
|
|
307
|
+
The cleanest approach is to set the environment variable per-process in your Procfile:
|
|
308
|
+
|
|
309
|
+
```procfile
|
|
310
|
+
# Procfile.dev
|
|
311
|
+
web: env SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true bin/rails server
|
|
312
|
+
webpack-client: env SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true bin/shakapacker --watch
|
|
313
|
+
webpack-server: env SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true bin/shakapacker --watch --config-name server
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Then your `bin/dev` can run the hook once and launch the process manager:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
#!/usr/bin/env bash
|
|
320
|
+
# bin/dev
|
|
321
|
+
|
|
322
|
+
# Run the hook once before launching all processes
|
|
323
|
+
bundle exec ruby -r ./config/boot -e "
|
|
324
|
+
hook = Shakapacker.config.precompile_hook
|
|
325
|
+
if hook
|
|
326
|
+
puts \"Running precompile hook: #{hook}\"
|
|
327
|
+
system(hook) or exit(1)
|
|
328
|
+
end
|
|
329
|
+
"
|
|
330
|
+
|
|
331
|
+
exec foreman start -f Procfile.dev
|
|
332
|
+
# or: exec overmind start -f Procfile.dev
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Alternative: Export environment variable**
|
|
336
|
+
|
|
337
|
+
You can export the environment variable before starting your process manager:
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
#!/usr/bin/env bash
|
|
341
|
+
# bin/dev
|
|
342
|
+
|
|
343
|
+
# Run the hook once before launching all processes
|
|
344
|
+
bundle exec ruby -r ./config/boot -e "
|
|
345
|
+
hook = Shakapacker.config.precompile_hook
|
|
346
|
+
if hook
|
|
347
|
+
puts \"Running precompile hook: #{hook}\"
|
|
348
|
+
system(hook) or exit(1)
|
|
349
|
+
end
|
|
350
|
+
"
|
|
351
|
+
|
|
352
|
+
# Export skip flag for all subprocesses
|
|
353
|
+
export SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true
|
|
354
|
+
|
|
355
|
+
exec foreman start -f Procfile.dev
|
|
356
|
+
# or: exec overmind start -f Procfile.dev
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Alternative: Use .env.local (not tracked by git)**
|
|
360
|
+
|
|
361
|
+
For Foreman or Overmind, you can create a `.env.local` file (typically gitignored):
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
#!/usr/bin/env bash
|
|
365
|
+
# bin/dev
|
|
366
|
+
|
|
367
|
+
# Run the hook once before launching all processes
|
|
368
|
+
bundle exec ruby -r ./config/boot -e "
|
|
369
|
+
hook = Shakapacker.config.precompile_hook
|
|
370
|
+
if hook
|
|
371
|
+
puts \"Running precompile hook: #{hook}\"
|
|
372
|
+
system(hook) or exit(1)
|
|
373
|
+
end
|
|
374
|
+
"
|
|
375
|
+
|
|
376
|
+
# Create .env.local for process manager subprocesses
|
|
377
|
+
echo "SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true" > .env.local
|
|
378
|
+
|
|
379
|
+
exec foreman start -f Procfile.dev
|
|
380
|
+
# or: exec overmind start -f Procfile.dev
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
This pattern ensures the hook runs once when development starts, not separately for each webpack process.
|
|
384
|
+
|
|
287
385
|
### Conditional Execution
|
|
288
386
|
|
|
289
387
|
```bash
|
data/lib/shakapacker/compiler.rb
CHANGED
|
@@ -27,7 +27,7 @@ class Shakapacker::Compiler
|
|
|
27
27
|
true
|
|
28
28
|
else
|
|
29
29
|
acquire_ipc_lock do
|
|
30
|
-
run_precompile_hook if
|
|
30
|
+
run_precompile_hook if should_run_precompile_hook?
|
|
31
31
|
run_webpack.tap do |success|
|
|
32
32
|
after_compile_hook
|
|
33
33
|
end
|
|
@@ -80,6 +80,13 @@ class Shakapacker::Compiler
|
|
|
80
80
|
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
def should_run_precompile_hook?
|
|
84
|
+
return false unless config.precompile_hook
|
|
85
|
+
return false if ENV["SHAKAPACKER_SKIP_PRECOMPILE_HOOK"] == "true"
|
|
86
|
+
|
|
87
|
+
true
|
|
88
|
+
end
|
|
89
|
+
|
|
83
90
|
def run_precompile_hook
|
|
84
91
|
hook_command = config.precompile_hook
|
|
85
92
|
hook_spec = validate_precompile_hook(hook_command)
|
data/lib/shakapacker/version.rb
CHANGED
data/package.json
CHANGED
|
@@ -52,8 +52,12 @@ class Shakapacker::Compiler
|
|
|
52
52
|
|
|
53
53
|
def bin_shakapacker_path: () -> Pathname
|
|
54
54
|
|
|
55
|
+
def should_run_precompile_hook?: () -> bool
|
|
56
|
+
|
|
55
57
|
def run_precompile_hook: () -> void
|
|
56
58
|
|
|
59
|
+
def validate_precompile_hook: (String hook_command) -> Hash[Symbol, untyped]
|
|
60
|
+
|
|
57
61
|
def run_webpack: () -> bool
|
|
58
62
|
|
|
59
63
|
def webpack_env: () -> Hash[String, String]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shakapacker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 9.
|
|
4
|
+
version: 9.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -413,7 +413,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
|
413
413
|
licenses:
|
|
414
414
|
- MIT
|
|
415
415
|
metadata:
|
|
416
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.
|
|
416
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.4.0
|
|
417
417
|
rdoc_options: []
|
|
418
418
|
require_paths:
|
|
419
419
|
- lib
|