shakacode / react_on_rails

Integration of React + Webpack + Rails + rails/webpacker including server-side rendering of React, enabling a better developer experience and faster client performance.
https://www.shakacode.com/react-on-rails/docs/
MIT License
5.08k stars 627 forks source link

uninitialized constant `ReactOnRails::Configuration::Webpacker` #1621

Closed adriangohjw closed 4 days ago

adriangohjw commented 1 month ago

Environment

Ruby version: 3.3.1 Rails version: 7.1.3.2 Shakapacke version: 8.0.0 React on Rails version: 14.0.0

Expected behavior

Running rails s should start the server successfully

Actual behavior

Facing this error and server refuse to start up

.rbenv/versions/3.3.1/lib/ruby/gems/3.3.0/gems/react_on_rails-14.0.0/lib/react_on_rails/configuration.rb:261:in `shakapacker_precompile?': uninitialized constant ReactOnRails::Configuration::Webpacker (NameError)

Webpacker.config.shakapacker_precompile?

Details

Changing Webpacker.config.shakapacker_precompile? to Shakapacker.config.shakapacker_precompile? seem to fix the issue (on my end, at least)

https://github.com/shakacode/react_on_rails/blob/36f342c6086718289e4d66d0eea2fbf1f6334a8d/lib/react_on_rails/configuration.rb#L258-L262

justin808 commented 1 month ago

@adriangohjw can you update spec/dummy app to use Shakapacker v8?

adriangohjw commented 1 month ago

@justin808 done! https://github.com/shakacode/react_on_rails/pull/1622/commits/e1c1b2d4512a23cd63f5b91a7fd82dafc5c7e2c4

4-Eyes commented 1 week ago

I can confirm this bug still exists, event though the associated PR has been closed. As a workaround until this is fixed, I've just put an initializer in my app that sets Webpacker to Shakapacker, as shown below:

# app/config/initializers/webpacker.rb
Webpacker = Shakapacker
sophiedeziel commented 1 week ago

I confirm @4-Eyes 's hack worked for me.

aarestad commented 1 week ago

For the record, it looks like a fix was supposed to have be merged in https://github.com/shakacode/react_on_rails/pull/1629.

justin808 commented 1 week ago

1622 will fix this.