sprockets
sprockets copied to clipboard
Sprockets can't find `.jst.eco.erb` files
Expected behavior
Template files with the .jst.eco.erb extensions should be properly located and loaded.
Actual behavior
Sprockets::FileNotFound: couldn't find file 'templates/foo' with type 'application/javascript'
System configuration
- Sprockets version 4 beta
- Ruby version 2.4
Example App
In this example app, a template plain.jst.eco loads fine but the erb.jst.eco.erb doesn't: https://github.com/divoxx/sprockets-test/blob/master/app/assets/javascripts/application.js#L17-L18
$ ./bin/rake assets:precompile
Running via Spring preloader in process 13359
rake aborted!
Sprockets::FileNotFound: couldn't find file 'templates/erb' with type 'application/javascript'
Checked in these paths:
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/config
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/images
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/javascripts
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/stylesheets
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/vendor/assets/javascripts
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/vendor/assets/stylesheets
/home/divoxx/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
/home/divoxx/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/coffee-rails-4.2.1/lib/assets/javascripts
/home/divoxx/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actioncable-5.0.2/lib/assets/compiled
/home/divoxx/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/turbolinks-source-5.0.0/lib/assets/javascripts
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/config/manifest.js:2
/home/divoxx/Code/src/github.com/divoxx/sprockets-test/app/assets/javascripts/application.js:18
-e:1:in `<main>'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
I am seeing a similar issue with a *.js.jst.ejs.slim file. It tells me:
couldn't find file 'folder/name' with type 'application/javascript' Checked in these paths:
Could you add this to your pull request?
This is how erb is supported
require 'sprockets/erb_processor'
register_transformer_suffix(%w(
application/ecmascript-6
application/javascript
application/json
application/xml
text/coffeescript
text/css
text/html
text/plain
text/sass
text/scss
text/yaml
), 'application/\2+ruby', '.erb', ERBProcessor)
It doesn't look like we're checking for eco files.
@schneems there is a fix for it here: https://github.com/rails/sprockets/pull/491