Asset Pipeline dependencies in Engines

While I was creating a simple engine to wrap a jQuery plugin I realized a strange behavior.

basically, in gemspec there is “s.add_dependency ‘jquery-rails’” and vendor is set as:

  • vendor

  • assets

  • javascripts

  • jquery

  • some-plugin.js

  • jquery-some-plugin.js


// =require jquery

// =require ./jquery/some-plugin

Then, if you have some application.js like this (included in your layout):

// =require jquery

// …

And some specific script like this to the HTML header:

// =require jquery-some-plugin

jQuery will be included twice. One for application.js bundle and another for the other bundle.

This means that any registered jQuery plugins will be removed the next time jQuery is included.

It would be great if we could specify that another-bundle.js is included after (ie. depends on) application.js.

That way, by knowing that there will always be an applications.js included before another-bundle.js the assets pipeline would be able to strip from another-bundle.js all dependecies already included in application.js.

Would that be feasible/wanted?