opal / opal-sprockets

Sprockets support for Opal (used to be embedded into Opal from v0.6 up to v0.10)
29 stars 17 forks source link

Support Sprockets 4.0! #19

Closed hmdne closed 3 years ago

hmdne commented 4 years ago

Noting things of importance:

Things that will need upgrade once this is deployed (or before - backward compatibility is assured): opal-haml, opal-erubi (I already have those and I will reference this PR).

Things that will NOT need upgrade: opal-rspec, opal

Things I'm not sure about, but will probably need some minor work: opal-rails

hmdne commented 4 years ago

Regarding the break:

opal-sprockets was resolved to 0.5.0.1.0.4.0, which depends on
      sprockets (~> 4.0) was resolved to 4.0.2, which depends on
        ruby (>= 2.5.0)

I think this patch is partially compatible with sprockets 3.7 if that's desired.

elia commented 4 years ago

This is amazing! I'll review it as soon as I can 💪 ✨ 🎉

hmdne commented 4 years ago

Regarding opal-rails, Rails changed their Sprockets handling method if Sprockets 4.0 is loaded, it now needs a file app/assets/config/manifest.js. I will try to migrate it, but I have very little experience with Rails. Do note, that nothing changes for other deployments, only Rails is affected.

hmdne commented 4 years ago

I found a problem that dependencies may not work the way they should. While updating my code, the asset (which is now just one asset, it doesn't expand anymore) compiles only the main file without its dependencies and a server restart is required. I will create a test for that instance and try to debug it more.

hmdne commented 4 years ago

Testing this on my application. It works flawlessly if opal-parser isn't included. And without collapsing everything loads very fast - it only recompiles single files from the source code. But if opal-parser is included it breaks and it breaks quite hard - sometimes it even embeds source maps as if they were JS files. Maybe I will try later with increasing the Sprockets cache to more than 1k keys and hopefully this would help.

elia commented 4 years ago

That's great! I need to try it out as well, feel free to update the travis config to avoid unsupported rubies like 2.3 and 2.4 so that the PR becomes green

tobymao commented 4 years ago

the caching support is exciting! any update when this will get in?

hmdne commented 4 years ago

@tobymao I will finalize the patch in a few days. In the meantime you can do

gem 'opal-sprockets', github: 'hmdne/opal-sprockets'

etc. for opal-rails, opal-haml.

elia commented 3 years ago

I merged this with a few adjustments in #23, thanks for the great work!