react_on_rails 16.3.0.rc.1 → 16.3.0.rc.2
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/Gemfile.lock +1 -1
- data/lib/generators/react_on_rails/base_generator.rb +37 -21
- data/lib/react_on_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 628677c167f906b22c7997308ed630a4c6b93f9b53b4a81cfcfd2960fd6b2d8e
|
|
4
|
+
data.tar.gz: fc1bd8c3939152cf92f48fa2f2053c8a0a30c4d5503d9468165e08d32f209e50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a895060d8fdae1dbc7f96e43aaabbe97cd62fa9ace58bcf06e151cdd7055245b2d68c45873d5c628faff49f0f3ad53dffe6c9bcf4d314d79a21bdc2eadd28e2d
|
|
7
|
+
data.tar.gz: e66ccf6a13d26760349dfa591125b28e311ef2e28b6c5cde4a3ce10139bf2886719db25c0576b9d5a59d792fb831f2c549a1f4981b7eed27cd3dbe95260759cf
|
data/Gemfile.lock
CHANGED
|
@@ -95,16 +95,20 @@ module ReactOnRails
|
|
|
95
95
|
if File.exist?(".shakapacker_just_installed")
|
|
96
96
|
puts "Skipping Shakapacker config copy (already installed by Shakapacker installer)"
|
|
97
97
|
File.delete(".shakapacker_just_installed") # Clean up marker
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
else
|
|
99
|
+
puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config"
|
|
100
|
+
base_path = "base/base/"
|
|
101
|
+
config = "config/shakapacker.yml"
|
|
102
|
+
# Use template to enable version-aware configuration
|
|
103
|
+
template("#{base_path}#{config}.tt", config)
|
|
100
104
|
end
|
|
101
105
|
|
|
102
|
-
|
|
103
|
-
base_path = "base/base/"
|
|
104
|
-
config = "config/shakapacker.yml"
|
|
105
|
-
# Use template to enable version-aware configuration
|
|
106
|
-
template("#{base_path}#{config}.tt", config)
|
|
106
|
+
# Configure bundler-specific settings
|
|
107
107
|
configure_rspack_in_shakapacker if options.rspack?
|
|
108
|
+
|
|
109
|
+
# Always ensure precompile_hook is configured (Shakapacker 9.0+ only)
|
|
110
|
+
# This handles all scenarios: fresh install, pre-installed Shakapacker, or user declined overwrite
|
|
111
|
+
configure_precompile_hook_in_shakapacker
|
|
108
112
|
end
|
|
109
113
|
|
|
110
114
|
def add_base_gems_to_gemfile
|
|
@@ -298,23 +302,35 @@ module ReactOnRails
|
|
|
298
302
|
|
|
299
303
|
puts Rainbow("🔧 Configuring Shakapacker for Rspack...").yellow
|
|
300
304
|
|
|
301
|
-
#
|
|
302
|
-
#
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
# Older Psych versions don't support the aliases parameter
|
|
307
|
-
YAML.load_file(shakapacker_config_path)
|
|
308
|
-
end
|
|
309
|
-
# Update default section
|
|
310
|
-
config["default"] ||= {}
|
|
311
|
-
config["default"]["assets_bundler"] = "rspack"
|
|
312
|
-
config["default"]["webpack_loader"] = "swc"
|
|
305
|
+
# Use gsub_file to preserve comments and file structure
|
|
306
|
+
# Replace assets_bundler: "webpack" with assets_bundler: "rspack"
|
|
307
|
+
gsub_file shakapacker_config_path,
|
|
308
|
+
/^(\s*)assets_bundler:\s*["']?webpack["']?\s*$/,
|
|
309
|
+
"\\1assets_bundler: \"rspack\""
|
|
313
310
|
|
|
314
|
-
# Write back as YAML
|
|
315
|
-
File.write(shakapacker_config_path, YAML.dump(config))
|
|
316
311
|
puts Rainbow("✅ Updated shakapacker.yml for Rspack").green
|
|
317
312
|
end
|
|
313
|
+
|
|
314
|
+
def configure_precompile_hook_in_shakapacker
|
|
315
|
+
# precompile_hook is only supported in Shakapacker 9.0+
|
|
316
|
+
return unless ReactOnRails::PackerUtils.shakapacker_version_requirement_met?("9.0.0")
|
|
317
|
+
|
|
318
|
+
shakapacker_config_path = "config/shakapacker.yml"
|
|
319
|
+
return unless File.exist?(shakapacker_config_path)
|
|
320
|
+
|
|
321
|
+
content = File.read(shakapacker_config_path)
|
|
322
|
+
|
|
323
|
+
# Already has an active (non-commented) precompile_hook configured? Don't overwrite.
|
|
324
|
+
return if content.match?(/^\s+precompile_hook:\s*['"][^'"]+['"]/)
|
|
325
|
+
|
|
326
|
+
# Replace the commented placeholder with the actual value
|
|
327
|
+
# Shakapacker 9.x default config has: # precompile_hook: ~
|
|
328
|
+
gsub_file shakapacker_config_path,
|
|
329
|
+
/^(\s*)#\s*precompile_hook:\s*~\s*$/,
|
|
330
|
+
"\\1precompile_hook: 'bin/shakapacker-precompile-hook'"
|
|
331
|
+
|
|
332
|
+
puts Rainbow("✅ Configured precompile_hook in shakapacker.yml").green
|
|
333
|
+
end
|
|
318
334
|
end
|
|
319
335
|
end
|
|
320
336
|
end
|