Debuggable asset filename extensions
Right now sprockets API is based off of file name extension i.e.foo.html.erbversusfoo.js.erb. If you're trying to load a file that sprockets does not know what to do with likewhatever.js.es6` it's not clear that the problem is sprockets can find the file but doesn't know what to do with it. In this case you would need to add the babel gem.
We should add some debugging around this use case. We could add a rake task like
$ rake assets:extensions:list
That would list all known extensions for starters. Ideally an error could be raised saying that the file with an extension that cannot be understood was found.
Re: https://github.com/rails/sprockets/issues/279
Sprockets doesn't know anything about filename extensions. The only thing it knows is about mime types (and with a mime type you can see file extensions related to it).
I'm not sure what are we trying to archive with this new rake task. How that information could be useful?
It has to know extensions to convert from extension to mime type
https://github.com/rails/sprockets/blob/b7a86f3216564d17d5c537ddbc41a127bde390e6/lib/sprockets.rb#L48
There have been several issues that were solved by saying "Hey Sprockets doesn't ship with support for
This failure case isn't handled very gracefully by sprockets. We don't give any hints at what the problem might be. I think we can do a better job.
I'd try to improve the failure case because even with that debugging list people will still open issues like that.
Agreed
Right now I'm trying to document my wishlist of ways I think sprockets could fail better. I think we need to also do some work in Rails so we're allowed to fail more often, this is a good start https://github.com/rails/sprockets/issues/281#issuecomment-212529330.