Closed rubydesign closed 1 year ago
It is much likely this error stems from building a non-Opal application. Let me issue a couple of amendments for it to ignore non-Opal JavaScripts
You can try the master branch now if it has fixed your issue
I'll try, but yes, i do have non opal js
I think it got further
NoMethodError: undefined method `value' for nil:NilClass
3.0.0/bundler/gems/opal-optimizer-a6daa112a401/lib/opal/optimizer.rb:20:in `initialize'
3.0.0/bundler/gems/opal-optimizer-a6daa112a401/lib/opal/optimizer/sprockets.rb:9:in `new'
bundler/gems/opal-optimizer-a6daa112a401/lib/opal/optimizer/sprockets.rb:9:in `call'
I have improved the logic, you can try again now
ok, no more fails.
The reduction i see is about 30% . I think it could possibly be much more. As i really only have 200 lines myself. But as a freeby i'll happily take it and won't complain :-)
I just checked the asset file size, but now i see that it does not work. My fault
I use dynamic sends like send "match_#{somevar}" and in a way it's a good thing that the optimiser cleans those match* methods out
If you want to fix this too i could try. tomorrow. If not also fine, should probably use inheritance instead
Exactly - that is the kind of incompatibility that opal-optimizer introduces about which you must be aware. Opal-Optimizer works in such a way, that it collects all method calls and removes methods that are not called. Due to Ruby highly dynamic nature, we can't go too far in terms of optimizations.
For an equivalent function planned for Opal 2.0, we may introduce some kind of a DSL, perhaps a magic comment, that will allow you to make things work a little bit differently.
ArgumentError: Couldn't deduce Opal version based on this content
3.0.0/bundler/gems/opal-optimizer-8b48ab17fb97/lib/opal/optimizer.rb:40:in
initialize' 3.0.0/bundler/gems/opal-optimizer-8b48ab17fb97/lib/opal/optimizer/sprockets.rb:9:in
new' 3.0.0/bundler/gems/opal-optimizer-8b48ab17fb97/lib/opal/optimizer/sprockets.rb:9:incall' 3.0.0/gems/sprockets-4.2.0/lib/sprockets/processor_utils.rb:84:in
call_processor'rails 7.0.4.2 sprockets 4.2 ruby 3.0.4