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

Fixing jquery-tmpl-rails Sprockets deprecations #11

Open
Schwad opened this issue Apr 25, 2018 · 4 comments
Open

Fixing jquery-tmpl-rails Sprockets deprecations #11

Schwad opened this issue Apr 25, 2018 · 4 comments

Comments

@Schwad
Copy link

Schwad commented Apr 25, 2018

This is also filed under Sprockets core for guidance here.

Versions

  • Ruby 2.4.3
  • Rails 5.1.3
  • sprockets 3.7.3
  • jquery-tmpl-rails 1.1.0

Issue:

The latest version of jquery-tmpl-rails triggers a sprockets deprecation warning of:

    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 block (2 levels) in <class:Railtie> at /my/path/to/gems/jquery-tmpl-rails-ef6f58001d41/lib/jquery-tmpl-rails/engine.rb:10)

Attempts at resolution:

Following the deprecation warning, the problem within the gem simply resides here: https://github.com/jimmycuadra/jquery-tmpl-rails/blob/master/lib/jquery-tmpl-rails/engine.rb#L10

Which is currently:

app.assets.register_engine(".tmpl", JqueryTemplate)

I then visited the sprockets guide for handling deprecations, extensibility and compliance with sprockets 2,3,4. https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

I made my best attempt at rectifying the problem with a commit on this fork here: oceanshq@de7a598

Which was:

    asset.register_mime_type 'application/javascript', extensions: ['.tmpl'], charset: :unicode
    asset.register_preprocessor 'application/javascript', JqueryTemplate

However, this attempt simply deals out breakages when trying to run the web application at all or test it on the CI. So obviously I've missed something. I am not the gem maintainer but am trying to put this PR together myself as we rely on this gem.

Questions

  • Is there a simple syntactical approach I am missing here?
  • It was unclear to me in the docs, although register_engine is deprecated in Sprockets 3, is it actually possible to migrate from register_engine while staying in Sprockets 3?
  • If we are remaining on Sprockets 3 for the foreseeable future, is it kosher to silence this? Generally I work viewing deprecations as 'bugs that need fixing' and would rather not.
@Schwad
Copy link
Author

Schwad commented Apr 25, 2018

@jimmycuadra

@jimmycuadra
Copy link
Owner

I haven't followed Rails in a while—what is the implication of supporting older versions of Sprockets? Generally I'm supportive of bumping dependencies to more recent versions. Folks using older versions of Rails can continue to use older versions of this gem.

@Schwad
Copy link
Author

Schwad commented Apr 27, 2018 via email

@jimmycuadra
Copy link
Owner

I am okay with doing a major version bump of this gem and requiring whatever version of Sprockets the most recent version of Rails requires.

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