Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprockets register_engine deprecated #55

Closed
SidOfc opened this issue Aug 10, 2016 · 4 comments
Closed

Sprockets register_engine deprecated #55

SidOfc opened this issue Aug 10, 2016 · 4 comments

Comments

@SidOfc
Copy link

SidOfc commented Aug 10, 2016

Hello there!

I'm using the skim gem to convert hamljs templates to slim using the .jst.skim extension. It works perfectly but Sprockets as of version 3.7.0 deprecated the register_engine call in favor of a different approach using register_mime_type and either register_compressor or register_transformer.

It shows that they added a deprecation notice in the 3.7.0 section in the release notes

This is the exact error I'm getting:

DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
 (called from <top (required)> at /Users/myusername/.rvm/gems/ruby-2.3.0/gems/skim-0.10.0/lib/skim/sprockets.rb:3)

From what I can find, there is no simple way to get around this deprecation warning due to the fact that version 3.7.0 deprecates the functionality but still requires you to use it :|

I would write something along these lines to fix the registering issue, however the Skim::Template class cannot handle Sprockets 4 yet (which is still in beta at the time of writing). Either way it might give you some inspiration!

if Sprockets.respond_to?(:register_engine)
  args = ['.skim', Skim::Template]
  if Sprockets::VERSION.start_with? '3'
    args << {silence_deprecation: true, mime_type: 'text/skim'}
  end

  Sprockets.register_engine *args
else
  Sprockets.register_mime_type 'text/skim', extensions: ['.skim', '.jst.skim']
  Sprockets.register_transformer 'text/skim', 'application/javascript', Skim::Template
end

Replicating this issue should be simple.

In a fresh Rails (5, using sprockets >= 3.7.0) app,

Gemfile

gem 'skim'
gem 'sprockets', '>= 3.7.0'

Run the bundle or bundle install command
Restart rails server (ctrl+c to stop rails s to start)

The message should appear when starting the server, if not try creating a template

@mohsintahir
Copy link

mohsintahir commented Dec 12, 2020

Any fix to this?

@SidOfc
Copy link
Author

SidOfc commented Dec 13, 2020

@mohsintahir the last commit was on 8th of July 2016, it's been stale for quite a while. Your best chance would be to look at forks to see if anyone continued maintenance.

@mohsintahir
Copy link

Got it. Thanks!

@SidOfc
Copy link
Author

SidOfc commented Aug 14, 2023

It seems that this has been resolved in a118ab7, closing.

@SidOfc SidOfc closed this as completed Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants