rails / sprockets

Rack-based asset packaging system
MIT License
931 stars 791 forks source link

can't find file with wrong mime type? #600

Open michaelglass opened 5 years ago

michaelglass commented 5 years ago

Expected behavior

Sprockets finds a file

Actual behavior

[2019-04-26T10:26:44.842Z] Sprockets::FileNotFound: couldn't find file 'react/react-with-addons.js' with type 'text/coffeescript'

The file missing is in one of the Checked in these paths directory, but it's a regular javascript file. The source file / file being compiled is a coffeescript file.

Could this be similar to https://github.com/rails/sprockets/issues/273?

System configuration

Will try to get an example app built. It appears this behavior is flakey :-/

a2ikm commented 4 years ago

I have the same issue. #= require some_jst_eco_filename in a *.coffee file fails since sprockets 4.0.0.

I guess, this is because sprockets prior to 4.0 treats coffeescript file as application/javascript, but sprockets 4.0 doesn't. More in detail, Sprockets::Transformers#expand_transform_accepts#expand_transform_accepts returns only text/coffeescript and text/coffeescript+ruby types, but doesn't application/javascript or other javacript-like types for text/coffeescript, so sprockets 4.0 can't link a coffeescript file with a regular javascript file.

a2ikm commented 4 years ago

I reproduced the issue with a tiny project. https://github.com/a2ikm/sprockets-test2

Here is a failed test case for 4.0. https://travis-ci.org/github/a2ikm/sprockets-test2