Skip to content

Pre-compilation for es6 breaks with version 1.4.2 #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dkln opened this issue Nov 6, 2015 · 9 comments
Closed

Pre-compilation for es6 breaks with version 1.4.2 #395

dkln opened this issue Nov 6, 2015 · 9 comments

Comments

@dkln
Copy link

dkln commented Nov 6, 2015

Upgraded to react-rails gem version 1.4.2 this morning. This unfortunately breaks pre-compilation. es6/jsx files aren't picked up anymore (1.4.1 works fine btw).

I suspect this is due changes made in the Rails Engine?

@rmosolgo
Copy link
Member

rmosolgo commented Nov 6, 2015

Maybe so. How do you set up es6 compilation? If you show me how you do that, I can add a test & try to get it going again!

@dkln
Copy link
Author

dkln commented Nov 6, 2015

Well 😄, This is kinda how my Gemfile looks like:

  • react-rails
  • sprockets
  • sprockets-es6

So my components.js (that lives in app/assets/javascripts) contains something like this:

components.js:

//= require ./video

The filename of video, is in this case: video.es6.jsx. That used to work but now it can't find a suitable format anymore. To be honest, I did not try to change the extension (.jsx.es6 or .jsx.js etc.).

@rmosolgo
Copy link
Member

rmosolgo commented Nov 6, 2015

I think this is the breaking change: #385 But I'm not sure exactly how it broke things.

In your case, do you get an error message? If so, what is the message and what is the stack trace?

Or does it simply fail to transform?

@dkln
Copy link
Author

dkln commented Nov 6, 2015

Yes I get an error message:

Sprockets::FileNotFound: couldn't find file './video' under 'website/app/assets/javascripts' with type 'application/javascript'

And the infamous stacktrace:

/Users/the-user/Projects/website/app/assets/javascripts/components.js:4
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/resolve.rb:64:in `resolve!'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:399:in `resolve'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:207:in `process_require_directive'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:180:in `block in process_directives'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:178:in `each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:178:in `process_directives'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:83:in `_call'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/directive_processor.rb:68:in `call'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:60:in `block in load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:44:in `load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/bundle.rb:23:in `block in call'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/utils.rb:183:in `dfs'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/bundle.rb:24:in `call'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:60:in `block in load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/loader.rb:44:in `load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `yield'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/cached_environment.rb:47:in `load'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/base.rb:66:in `find_asset'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:130:in `block in find'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:129:in `each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:129:in `find'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/manifest.rb:162:in `compile'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/the-user/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/the-user/.rbenv/versions/2.2.3/bin/rake:23:in `load'
/Users/the-user/.rbenv/versions/2.2.3/bin/rake:23:in `<main>

@dkln
Copy link
Author

dkln commented Nov 6, 2015

So I think it just breaks because of the registered file extensions 😄

@eugenijusr
Copy link
Contributor

It seems that the new Sprockets mime type registry no longer matches these chained extensions and you need to explicitly list all the possible variations.

From the upgrade doc (I missed this bit):

However, this requires you whitelist all the compatible extension combinations. Theres no free form chaining. This turned out to be a less useful feature. It meant foo.js.coffee.erb.haml.jst.eco.sass was a legal processor chain, but pretty useless.

E.g. it used to be:

register_engine '.coffee', Tilt::CoffeeScriptTemplate

And now it's:

register_mime_type 'text/coffeescript', extensions: ['.coffee', '.js.coffee']
register_transformer 'text/coffeescript', 'application/javascript', CoffeeScriptProcessor

Note how .coffee and .js.coffee are listed explicitly.

I think it should be enough to add .es6.jsx to the extension list in engine.rb. I'll check it out and propose a small PR if that's the case.

Sorry for messing it up for the ES6 guys.

@dkln
Copy link
Author

dkln commented Nov 23, 2015

Ah right, great find 👍

@eugenijusr
Copy link
Contributor

BTW it seems version 1.4.2 although tagged and released still has 1.4.1 in version.rb and no change log entry. @rmosolgo

@rmosolgo
Copy link
Member

😬 sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants