Skip to content

New Babel Transformer #295

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 9 commits into from
Jun 19, 2015
Merged

Conversation

vipulnsward
Copy link
Contributor

  • Added new BabelTransformer to start performing transformation using ruby-babel-transpiler
  • Make new BabelTransformer the default transformer
  • README changes to reflect new Babel Transformer
  • Added deprecation warning for usage of old transformer options
  • Move old transformer to JSXTransformer
  • Fixed component generator test after changes to new transformer

Fixes #292, #278

… ruby-babel-transpiler

- Make new BabelTransformer the default transformer
- README changes to reflect new Babel Transformer
- Added deprecation warning for usage of old transformer options
- Move old transformer to JSXTransformer
- Fixed  component generator test after changes to new transformer

Fixes reactjs#292, reactjs#278
@vipulnsward
Copy link
Contributor Author

Couple of notes about the default transformer options:

@rmosolgo
Copy link
Member

👏 👏 Your implementation looks great!

I don't understand your question about "plugins: [constants]" (I'm not familiar with babel yet), what do you mean by that?

@@ -85,6 +114,8 @@ config.react.jsx_transform_options = {
}
```

#### CoffeeScript
Copy link
Member

Choose a reason for hiding this comment

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

Should we merge this with the "## Coffeescript" section below?

@rmosolgo
Copy link
Member

Could we get a few minimal tests for BabelTransformer ? IMO it doesn't have to be much, but it would be nice to have a test to ensure some future change doesn't totally break it!

@netikular
Copy link

Sorry to just jump in here, but does this implementation by any chance have any relation to the work done to support es6 in sprockets?

https://github.com/TannerRogalsky/sprockets-es6

Thanks for the great work!

@rmosolgo
Copy link
Member

@netikular not at all, "just jumping in" is the beauty of a public project, thanks for speaking up :)

I noticed that project as I was sizing up some options. I didn't it very compelling because:

  • the documentation was quite sparse (how do you pass Babel options? how could we make it process .jsx files?)
  • the readme wasn't compelling ("This plugin is primarily experimental and will never reach a stable 1.0.")

So, I think it's ok to have a custom transformer!

@vipulnsward
Copy link
Contributor Author

I have been using this alongside react-rails in our application without any issues, to support es6.
Right now its on track to be merged in sprockets-rails.
I think we can start looking at handling it, after it lands in sprockets-rails master.

@netikular
Copy link

@rmosolgo I agree that the documentation is quite sparse, it took me a little while to get it working.

@vipulnsward are you using es6 and JSX together or are you writing your react components in the react-rails style and using the helpers? I noticed that I can rename my JSX files to es6 and with some hoisting up to window get them to work, but it seems like a lot of setup work.

I was just wondering how you are handling working between es6 and jsx and if you are using a module loader or just es6 syntax.

@rmosolgo
Copy link
Member

👍 if you guys prefer it, I'm open to it!

@vipulnsward
Copy link
Contributor Author

Ok, here's the current status-

… transformation options

- Fixed passing of transform options to the transformer
@vipulnsward vipulnsward force-pushed the 292-babel-transformer branch from ee02ea5 to caa8df4 Compare June 14, 2015 19:58
@zpao
Copy link
Member

zpao commented Jun 15, 2015

The plugins: constants bit in the React build config shouldn't apply here. That's a custom plugin to transform __DEV__ away. We never shipped that with JSXTransformer.

I don't know how custom plugins would hook into this, I'll let you figure that out :) Might be best to not support them initially unless you've tested and documented how it works.

@rmosolgo
Copy link
Member

Cool, sounds like we don't need plugins: [constants]. I agree, custom plugins can be a "later" thing.

As for coffee-script, what if we left JSXTransformer as the default for 1.1, then switch the default and add a warning for coffee-script users in 1.2? That keeps things working for people now & keeps our project moving forward.

Either way, I don't think it's a deal-breaker. .coffee users have two decent options: use JSXTransformer or disable strict mode in babel. (And a third very good option: switch to JSX :P)

@vipulnsward
Copy link
Contributor Author

Custom plugins are as simple as just passing to plugin transform_options.

I think instead of shipping with JSXTransformer as default, we can ship with Babel as default(to be in sync with React) with disabled strict mode to support both coffeescript + JSX and make it explicit that next version default transformer will break CS. Thoughts?

PS: Even if we ship with breaking changes for CS later, Babel can still be used with passing custom transform options - { blacklist: ['spec.functionName', 'validation.react', 'strict'] }

@vipulnsward
Copy link
Contributor Author

I have pushed an updated version with above changes. I think it makes sense to disable strict by default, to be backwards compatible, since thats how JSXTransformer is handling it.

@vipulnsward
Copy link
Contributor Author

Travis looks happy now :-)

@rmosolgo
Copy link
Member

👍 looks good to me 😀

@vipulnsward vipulnsward mentioned this pull request Jun 18, 2015
rmosolgo pushed a commit that referenced this pull request Jun 19, 2015
@rmosolgo rmosolgo merged commit 614f7e1 into reactjs:master Jun 19, 2015
@rmosolgo
Copy link
Member

🎊 the future is now 😄

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.

5 participants