railsware / js-routes

Brings Rails named routes to javascript
http://railsware.github.io/js-routes/
MIT License
1.61k stars 151 forks source link

JsRoutes::Middleware doesn't work with shakapacker >= 8 #321

Open a3vorobyov opened 8 hours ago

a3vorobyov commented 8 hours ago

Hello,

In the latest versions of Shakapacker, they have completely moved to a new constant and removed all occurrences of Webpacker (https://github.com/shakacode/shakapacker/blob/main/docs/v8_upgrade.md#usages-of-webpacker-must-now-be-shakapacker). Unfortunately, this leads to the error below.

rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /app/app/assets/javascripts/routes.js
/usr/local/bundle/gems/js-routes-2.2.10/lib/js_routes/instance.rb:55:in `initialize'
/usr/local/bundle/gems/js-routes-2.2.10/lib/js_routes/instance.rb:55:in `open'
/usr/local/bundle/gems/js-routes-2.2.10/lib/js_routes/instance.rb:55:in `block in generate!'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:68:in `block in execute_hook'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:42:in `each'
/usr/local/bundle/gems/activesupport-6.1.7.9/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
/usr/local/bundle/gems/railties-6.1.7.9/lib/rails/railtie/configuration.rb:72:in `after_initialize'
/usr/local/bundle/gems/js-routes-2.2.10/lib/js_routes/instance.rb:47:in `generate!'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/call_validation.rb:270:in `bind_call'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/call_validation.rb:270:in `validate_call'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
/usr/local/bundle/gems/js-routes-2.2.10/lib/js_routes.rb:39:in `generate!'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/call_validation.rb:270:in `bind_call'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/call_validation.rb:270:in `validate_call'
/usr/local/bundle/gems/sorbet-runtime-0.5.11602/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
/usr/local/bundle/gems/js-routes-2.2.10/lib/tasks/js_routes.rake:5:in `block (2 levels) in <main>'
/usr/local/bundle/gems/rake-13.2.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => js:routes
(See full trace by running task with --trace)

It looks like a problem is here https://github.com/railsware/js-routes/blob/main/lib/js_routes/configuration.rb#L117. For now, the easiest solution is doing something like this "Webpacker = Shakapacker" :)

bogdan commented 11 minutes ago

I tried to address it in c5675aa9949e8b0c5ce94e37bde84ad3666addab

Can you check current main branch to see if it fixes your problem.