Skip to content

Commit 594776b

Browse files
committed
Fix compatibility with beta versions of Sprockets
RubyGems made a change that causes this error when you're on a beta version of Sprockets 4: /home/vagrant/code/rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/react-rails-2.6.0/lib/react/jsx/sprockets_strategy.rb:40:in `register_engine_with_mime_type': undefined method `register_engine' for Sprockets:Module (NoMethodError) Here's the relevant commit: rubygems/rubygems@9836549#diff-94d386526b8b558035d4e4c7602d647c And here's how the behavior of `Gemf::Version#<=>` has changed: Before: 1:(main)> `gem --version` => "3.0.3\n" 2:(main)> Gem::Version.new("4.0.0.beta9") >= Gem::Version.new('4.x') => true 3:(main)> Gem::Version.new("4.0.0.beta9") >= Gem::Version.new('4.a') => true After: 1:(main)> `gem --version` => "3.1.2\n" 2:(main)> Gem::Version.new("4.0.0.beta9") >= Gem::Version.new('4.x') => false 3:(main)> Gem::Version.new("4.0.0.beta9") >= Gem::Version.new('4.a') => true Sprockets 4.0 is out now, but this is still a bug, and people shouldn't be forced to upgrade because of it.
1 parent 94f7897 commit 594776b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/react/jsx/sprockets_strategy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def attach_with_strategy(sprockets_env, strategy_or_nil)
2323
# @return [Symbol] based on the environment, return a method name to call with the sprockets environment
2424
def detect_strategy
2525
sprockets_version = Gem::Version.new(Sprockets::VERSION)
26-
if sprockets_version >= Gem::Version.new('4.x')
26+
if sprockets_version >= Gem::Version.new('4.a')
2727
:register_processors
2828
elsif sprockets_version >= Gem::Version.new('3.0.0')
2929
:register_engine_with_mime_type

0 commit comments

Comments
 (0)