Skip to content

Fallback to EnvironmentContainer if assets_manifest is not supported #545

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

Merged
merged 1 commit into from
Jun 16, 2016

Conversation

tf
Copy link
Contributor

@tf tf commented Jun 4, 2016

Support for Rails.application.assets_manifest which is used by
ServerRendering::ManifestContainer has only been added in
sprockets-rails 2.2.2. Rails 4.0.5 depends on sprockets ~> 2.0.0.

  • Feature detect if assets_manifest is present
  • Add appraisal to test with rails-sprockets < 2.2.2

fixes #544

# Rails 3.x doesn't have `application.assets_manifest=`
# I don't think we have to support Rails 3 + Sprockets 3 anyways!
if Rails::VERSION::MAJOR > 3
if React::ServerRendering::ManifestContainer.compatible?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am leaning towards changing this to an explicit check of Sprockets::Rails::VERSION. While this variant is less repetitive, I am afraid some unforeseen future change of the compatible? method might cause the tests to be skipped for unexpected cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree -- better to keep the tests simple so we'll see if a future change causes them to break!

Alternatively, you could add unit tests for .compatible?

@@ -1,6 +1,6 @@
require "test_helper"

if Rails::VERSION::MAJOR == 3
if React::ServerRendering::YamlManifestContainer.compatible?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Considering to revert this change.

@tf tf force-pushed the sprockets-rails-before-2-2 branch 2 times, most recently from a8fedd6 to 319a558 Compare June 16, 2016 08:07
Support for `Rails.application.assets_manifest` which is used by
`ServerRendering::ManifestContainer` has only been added in
sprockets-rails 2.2.2. Rails 4.0.5 depends on sprockets ~> 2.0.0.

* Feature detect if `assets_manifest` is present
* Add appraisal to test with rails-sprockets < 2.2.2
@tf tf force-pushed the sprockets-rails-before-2-2 branch from 319a558 to a48c7e1 Compare June 16, 2016 08:42
@tf
Copy link
Contributor Author

tf commented Jun 16, 2016

I've updated the PR. Checking sprockets-rails versions in the tests was a bit of a pain since some older versions don't even define Sprockets::Rails::VERSION. I still think it's an improvement, though.

@rmosolgo rmosolgo merged commit aec90dd into reactjs:master Jun 16, 2016
@rmosolgo
Copy link
Member

Awesome, thanks so much for the patch on this bug!

@tf tf deleted the sprockets-rails-before-2-2 branch June 16, 2016 13:40
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

Successfully merging this pull request may close these issues.

Server rendering crashes in production with sprockets-rails < 2.2.2
2 participants