Skip to content

Directives in erb files ignore subdependencies since Sprockets 4 #470

Open
@GCorbel

Description

@GCorbel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions