-
Notifications
You must be signed in to change notification settings - Fork 755
Switch to the new Sprockets processor #385
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
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
end | ||
|
||
def call(input) | ||
@output ||= JSX::transform(input[:data]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm as you can see in the specs, this @output
is getting assigned in the first use, but then never being reassigned. This causes all inputs to have the same output!
Is there a downside to simply
class Processor
def self.call(input)
JSX::transform(input[:data])
end
end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was done for performance reasons in the Tilt template version of this. For these Sprocket processors there is a way to do a similar thing by implementing an optional cache_key
method.
Thanks for updating us! I don't think there is a special mime type for |
fdb6a0f
to
c8ecba2
Compare
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
end | ||
|
||
def call(input) | ||
{data: JSX::transform(input[:data])} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from https://github.com/rails/sprockets#return-hash:
Returning a String is shorthand for returning
{ data: str }
Can we return a string only? Do we need any metadata?
✨ Thanks again for getting us up-to-date (and getting me up to date 😝) ! |
Switch to the new Sprockets processor
Starting version 4 Sprockets is removing the
register_engine
method which registers JSX transformers using Tilt based templates breaking this gem for the current Rails 5master
. This has been deprecated since Sprockets version 3:https://github.com/rails/sprockets/blob/master/UPGRADING.md
This PR adds a JSX Processor and registers it via
register_processor
asapplication/jsx
mime type. Is there a reserved mime type for JSX templates?