sprockets icon indicating copy to clipboard operation
sprockets copied to clipboard

Filename collisions fail silently

Open bradgreens opened this issue 9 years ago • 5 comments

I have an app that is using sprockets es6 to compile Javascript files. I also am using Angular Rails templates to compile HTML files to Javascript that Angular recognizes.

I'm building out UI modules with file naming conventions like so -

my-feature.es6

and

my-feature.html.slim

This results in both files compiling to my-feature.js, it's not clear to me which pre-processor will win, not that it really matters. The end result is one asset will be overwritten. I can fix this by changing my file naming conventions, but it takes time to debug a problem like this.

It would be nice if sprockets recognized it's overwriting a file it created in the same compilation event, as that's obviously an issue a developer would like to know immediately.

bradgreens avatar May 09 '16 21:05 bradgreens

I agree, can you give me an example app that reproduces this behavior, I'll play around and see what options we have. This should not be a case we fail silently on.

schneems avatar May 10 '16 18:05 schneems

Here's a barebones example - https://github.com/bradgreens/rails-sprockets-filename-collision.

If you fire it up, visit /my-feature in the browser. my-feature.es6 and my-feature.html.slim will compile to the same target. It demonstrates where a filename collision occurs without any notice.

bradgreens avatar May 10 '16 23:05 bradgreens

Note that this is a (clearly undesirable) special case of an intended behaviour, which is that you can override a same-named asset that appears deeper in the search path.

matthewd avatar May 10 '16 23:05 matthewd

I've not heard of that behavior, but it's your discretion if it merits a warning or whatnot.

bradgreens avatar May 10 '16 23:05 bradgreens

@bradgreens I will try to pick it up 😸

Strech avatar Aug 25 '16 19:08 Strech