Skip to content
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

JSX Support #53

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

JSX Support #53

wants to merge 9 commits into from

Conversation

jtomaszewski
Copy link

@jtomaszewski jtomaszewski commented Dec 9, 2016

I rebased #22 to current master , added a test for react .jsx file and registered jsx mime_type in sprockets, so now it works out of the box, if only you include babel-preset-react in your .babelrc file.

What do you think?

register_postprocessor 'application/javascript', ::Sprockets::Commoner::Processor
register_transformer 'application/json', 'application/javascript', ::Sprockets::Commoner::JSONProcessor
register_transformer 'application/jsx', 'application/javascript', ::Sprockets::Commoner::JSXProcessor
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this for?

Copy link
Author

Choose a reason for hiding this comment

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

Not much for.. it just tells the sprockets that 'application/jsx' can be transformed into 'application/javascript' so it can be later included in the 'js' files.

Or we could just tell it that '.jsx' files are '.js' files stright away , by:

register_mime_type "application/javascript", extensions: [".js.jsx",".jsx"], charset: :unicode

Or maybe there's some another better way to do it. I'm not sure, I'm not really familiar with sprockets yet

Copy link
Contributor

Choose a reason for hiding this comment

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

I think just adding the .jsx extension as an acceptable application/javascript extension is better

@thijsc
Copy link

thijsc commented Jan 31, 2017

I was also looking into doing a jsx transform and couldn't get it to work out of the box with .coffee files. It does work with .js files by default though. So I'm not sure why you need this pull. Why don't you just rename your js.jsx files to js?

@jtomaszewski
Copy link
Author

Because of highlight syntax in my editor [Atom], I prefer to differentiate my jsx files from js .

Another approach would be to set this up in the editor. (but every dev would propably have to do it on his own because editorconfig/editorconfig#190 )

@thijsc
Copy link

thijsc commented Jan 31, 2017

Ah right, that makes sense. We're also running into a possibly related issue by the way: #59

@thijsc
Copy link

thijsc commented Feb 1, 2017

This pull looks really good to me, anything holding back a merge?

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.

4 participants