sprockets icon indicating copy to clipboard operation
sprockets copied to clipboard

Debuggable asset filename extensions

Open schneems opened this issue 9 years ago • 5 comments

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

schneems avatar Apr 21 '16 16:04 schneems

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?

rafaelfranca avatar Apr 21 '16 16:04 rafaelfranca

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 thing, you need to add a gem to be able to compile extension". I don't want to explain this over and over again and I don't think it is a good experience for users. I want to make the solution more discoverable.

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.

schneems avatar Apr 21 '16 16:04 schneems

I'd try to improve the failure case because even with that debugging list people will still open issues like that.

rafaelfranca avatar Apr 21 '16 16:04 rafaelfranca

Agreed

schneems avatar Apr 21 '16 16:04 schneems

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.

schneems avatar Apr 21 '16 16:04 schneems