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

Replace JSXTransformer with babel/browser #4131

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ DEPENDENCIES
rake
rb-fsevent
sanitize (~> 2.0)

BUNDLED WITH
1.10.1
1 change: 1 addition & 0 deletions docs/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('yaml')

desc "generate js from jsx"
task :js do
system "cp ../node_modules/babel/node_modules/babel-core/browser.min.js ./_js"
Copy link
Member

Choose a reason for hiding this comment

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

2 things here. 1 important and the other nitpicky…

  1. The important piece: please copy to js, not _js. We don't want to run the file through babel afterwards :). The less important piece, it might be good to make this a separate rake task but I don't care so much as long as the release task works. I think we'll want to end up checking in the final file, we do now for React and JSXTransformer. cc @spicyj
  2. Can we name the file babel-browser.min.js?

system "../node_modules/.bin/babel _js --out-dir=js"
end

Expand Down
60 changes: 60 additions & 0 deletions docs/_js/browser.min.js

Large diffs are not rendered by default.

18 changes: 0 additions & 18 deletions docs/_js/jsx-compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,16 @@ var HelloMessage = React.createClass({\n\
React.render(<HelloMessage name=\"John\" />, mountNode);\
";

function transformer(harmony, code) {
return JSXTransformer.transform(code, {harmony: harmony}).code;
}

var CompilerPlayground = React.createClass({
getInitialState: function() {
return {harmony: false};
},
handleHarmonyChange: function(e) {
this.setState({harmony: e.target.checked});
},
render: function() {
return (
<div>
<ReactPlayground
codeText={HELLO_COMPONENT}
renderCode={true}
transformer={transformer.bind(null, this.state.harmony)}
showCompiledJSTab={false}
showLineNumbers={true}
/>
<label className="compiler-option">
<input
type="checkbox"
onChange={this.handleHarmonyChange}
checked={this.state.harmony} />{' '}
Enable ES6 transforms (<code>--harmony</code>)
</label>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/_js/live_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var ReactPlayground = React.createClass({
getDefaultProps: function() {
return {
transformer: function(code) {
return JSXTransformer.transform(code).code;
return babel.transform(code).code;
},
editorTabTitle: 'Live JSX Editor',
showCompiledJSTab: true,
Expand Down
2 changes: 1 addition & 1 deletion docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<script type="text/javascript" src="/react/js/es5-shim.min.js"></script>
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
<![endif]-->
<script type="text/javascript" src="/react/js/browser.min.js"></script>
<script type="text/javascript" src="/react/js/codemirror.js"></script>
<script type="text/javascript" src="/react/js/javascript.js"></script>
<script type="text/javascript" src="/react/js/react.js"></script>
<script type="text/javascript" src="/react/js/JSXTransformer.js"></script>
<script type="text/javascript" src="/react/js/live_editor.js"></script>
</head>
<body>
Expand Down