rails/sprockets-rails

Directives in erb files ignore subdependencies since Sprockets 4

GCorbel opened this issue · 0 comments

I recently updated the version of Sprockets from version 3.7.2 to 4.0.2. When I have those files :

//dep.js
//= require subdep.js
//subdep.js
console.log('something')
//main_test.js.erb
/*
 *= depend_on_asset "dep.js"
 */

<%= Rails.application.assets['dep.js'].source.html_safe %>

With Sprockets 3, when I edit subdep.js, the result rendered by main_test.js was updated. Since Sprockets 4, it isn't.

It works as expected if I change main_test.js.erb to call the ruby method like this :

//main_test.js.erb
<% depend_on_asset "dep.js" %>

<%= Rails.application.assets['dep.js'].source.html_safe %>

With directives Rails.application.assets.find_asset('main_test.js').metadata[:dependencies] doesn't include subdep.js and it is included when we call the ruby method.

I checked the sprockets source code, and it seems directives are correctly detected.