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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1eeac1830a6d09ce4ac9fbaeeadc3fcdcdcaa18742ca780346a08ead846bb51a
4
- data.tar.gz: 0b946d3c72239b0745cadb7a3961a74a73177e9a307ed21f2d1add1006e64fbb
3
+ metadata.gz: 628677c167f906b22c7997308ed630a4c6b93f9b53b4a81cfcfd2960fd6b2d8e
4
+ data.tar.gz: fc1bd8c3939152cf92f48fa2f2053c8a0a30c4d5503d9468165e08d32f209e50
5
5
  SHA512:
6
- metadata.gz: 4c8e8ed2bb0bcf39955c2b8adffa9503160c4f47aa8395d3798f97fd89dfd376588a2356db7673ec69dfe97605b043714923385fda0f92b6b7ce7d30b4e19d7d
7
- data.tar.gz: 7580e935af6eca381be3f7150c3927740a1e33971bcafc00a5d50d1cd17f2d8934172cc80bd67a69b1ec41ef6b1280aec733e59de84632996e584381f17c5228
6
+ metadata.gz: a895060d8fdae1dbc7f96e43aaabbe97cd62fa9ace58bcf06e151cdd7055245b2d68c45873d5c628faff49f0f3ad53dffe6c9bcf4d314d79a21bdc2eadd28e2d
7
+ data.tar.gz: e66ccf6a13d26760349dfa591125b28e311ef2e28b6c5cde4a3ce10139bf2886719db25c0576b9d5a59d792fb831f2c549a1f4981b7eed27cd3dbe95260759cf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (16.3.0.rc.1)
4
+ react_on_rails (16.3.0.rc.2)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
@@ -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
- configure_rspack_in_shakapacker if options.rspack?
99
- return
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
- puts "Adding Shakapacker #{ReactOnRails::PackerUtils.shakapacker_version} config"
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
- # Parse YAML config properly to avoid fragile regex manipulation
302
- # Support both old and new Psych versions
303
- config = begin
304
- YAML.load_file(shakapacker_config_path, aliases: true)
305
- rescue ArgumentError
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "16.3.0.rc.1"
4
+ VERSION = "16.3.0.rc.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.3.0.rc.1
4
+ version: 16.3.0.rc.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon