react_on_rails 16.3.0.rc.1 → 16.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1eeac1830a6d09ce4ac9fbaeeadc3fcdcdcaa18742ca780346a08ead846bb51a
4
- data.tar.gz: 0b946d3c72239b0745cadb7a3961a74a73177e9a307ed21f2d1add1006e64fbb
3
+ metadata.gz: 0ace0aef17c3665d3f573612c0fb1298834237fab6c25c67dc609fcd844efacf
4
+ data.tar.gz: 9768eec151936531996266b8635cfa9431014a98219b76c6a501ccba63a42ab2
5
5
  SHA512:
6
- metadata.gz: 4c8e8ed2bb0bcf39955c2b8adffa9503160c4f47aa8395d3798f97fd89dfd376588a2356db7673ec69dfe97605b043714923385fda0f92b6b7ce7d30b4e19d7d
7
- data.tar.gz: 7580e935af6eca381be3f7150c3927740a1e33971bcafc00a5d50d1cd17f2d8934172cc80bd67a69b1ec41ef6b1280aec733e59de84632996e584381f17c5228
6
+ metadata.gz: c1f027af8612019f38ab829a9b99ca50f869112f9b6f0f47fd0af27aa4bf6cabfb1ab45121ce7c4607d12f364292cecc21e8aba863b791f52d6fa557231e9fa2
7
+ data.tar.gz: 4d6549c75f9615433be29f67d7ea68963e2f7480ad4468f86a9da2f50d1d490f5311ce188ddac3fb422e52cf20aaffa1d24b175214cd4321574fe616b21f42bc
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)
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,45 @@ 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 regex replacement to preserve file structure (comments, anchors, aliases)
306
+ # This replaces ALL occurrences of assets_bundler, not just in default section
307
+ # Using gsub_file (Thor method) for consistency with Rails generator patterns
308
+ gsub_file(
309
+ shakapacker_config_path,
310
+ /^(\s*assets_bundler:\s*)["']?webpack["']?(\s*(?:#.*)?)$/,
311
+ '\1rspack\2'
312
+ )
313
+
314
+ # Update javascript_transpiler to swc (rspack works best with SWC)
315
+ gsub_file(
316
+ shakapacker_config_path,
317
+ /^(\s*javascript_transpiler:\s*)["']?babel["']?(\s*(?:#.*)?)$/,
318
+ '\1swc\2'
319
+ )
313
320
 
314
- # Write back as YAML
315
- File.write(shakapacker_config_path, YAML.dump(config))
316
321
  puts Rainbow("✅ Updated shakapacker.yml for Rspack").green
317
322
  end
323
+
324
+ def configure_precompile_hook_in_shakapacker
325
+ # precompile_hook is only supported in Shakapacker 9.0+
326
+ return unless ReactOnRails::PackerUtils.shakapacker_version_requirement_met?("9.0.0")
327
+
328
+ shakapacker_config_path = "config/shakapacker.yml"
329
+ return unless File.exist?(shakapacker_config_path)
330
+
331
+ content = File.read(shakapacker_config_path)
332
+
333
+ # Already has an active (non-commented) precompile_hook configured? Don't overwrite.
334
+ return if content.match?(/^\s+precompile_hook:\s*['"][^'"]+['"]/)
335
+
336
+ # Replace the commented placeholder with the actual value
337
+ # Shakapacker 9.x default config has: # precompile_hook: ~
338
+ gsub_file shakapacker_config_path,
339
+ /^(\s*)#\s*precompile_hook:\s*~\s*$/,
340
+ "\\1precompile_hook: 'bin/shakapacker-precompile-hook'"
341
+
342
+ puts Rainbow("✅ Configured precompile_hook in shakapacker.yml").green
343
+ end
318
344
  end
319
345
  end
320
346
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "fileutils"
5
- require "yaml"
6
5
  require "json"
7
6
 
8
7
  # Script to switch between webpack and rspack bundlers
@@ -48,16 +47,25 @@ class BundlerSwitcher
48
47
  abort "❌ #{@shakapacker_config} not found" unless File.exist?(@shakapacker_config)
49
48
 
50
49
  puts "📝 Updating #{@shakapacker_config}..."
51
- config = YAML.load_file(@shakapacker_config)
52
-
53
- config["default"] ||= {}
54
- config["default"]["assets_bundler"] = @target_bundler
55
-
56
- # Update webpack_loader based on bundler
57
- # Rspack works best with SWC, webpack typically uses babel
58
- config["default"]["webpack_loader"] = @target_bundler == "rspack" ? "swc" : "babel"
59
-
60
- File.write(@shakapacker_config, YAML.dump(config))
50
+ content = File.read(@shakapacker_config)
51
+
52
+ # Use regex replacement to preserve file structure (comments, anchors, aliases)
53
+ # This replaces ALL occurrences of assets_bundler, not just in default section
54
+ old_bundler = @target_bundler == "rspack" ? "webpack" : "rspack"
55
+ new_content = content.gsub(
56
+ /^(\s*assets_bundler:\s*)["']?#{old_bundler}["']?(\s*(?:#.*)?)$/,
57
+ "\\1#{@target_bundler}\\2"
58
+ )
59
+
60
+ # Update javascript_transpiler based on bundler (rspack works best with SWC)
61
+ new_loader = @target_bundler == "rspack" ? "swc" : "babel"
62
+ old_loader = @target_bundler == "rspack" ? "babel" : "swc"
63
+ new_content = new_content.gsub(
64
+ /^(\s*javascript_transpiler:\s*)["']?#{old_loader}["']?(\s*(?:#.*)?)$/,
65
+ "\\1#{new_loader}\\2"
66
+ )
67
+
68
+ File.write(@shakapacker_config, new_content)
61
69
  puts "✅ Updated assets_bundler to '#{@target_bundler}'"
62
70
  end
63
71
 
@@ -135,6 +143,7 @@ if ARGV.empty?
135
143
  puts "\nExamples:"
136
144
  puts " bin/switch-bundler rspack # Switch to Rspack"
137
145
  puts " bin/switch-bundler webpack # Switch to Webpack"
146
+ puts "\nNote: This also updates javascript_transpiler (rspack uses swc, webpack uses babel)"
138
147
  exit 1
139
148
  end
140
149
 
@@ -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"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-04 00:00:00.000000000 Z
11
+ date: 2026-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable