WIP -- conversion to ES6, npm for react_on_rails#148
Conversation
|
@yorzi Please take a look. I could not get this to start yet. Maybe you'll see the issue. @alexfedoseev can you please take a look as well, both the setup and the ES6 conversion. |
|
@alexfedoseev Please review. |
|
@justin808 👍 awesome work! |
|
@alexfedoseev the node module name of react_on_rails might be awkward. Should it be ReactOnRails? or import ReactOnRails from 'react_on_rails'; |
|
|
There was a problem hiding this comment.
I changed it to just git push, b/c betas can be released from branches.
|
@justin808 LGTM! Few comments. |
|
Looks good! |
|
@yorzi Check out @alexfedoseev suggestions. I'm OK if you apply them. Also, take a look at: https://github.com/umdjs/umd We need to be sure we're properly installing the event handlers only ONCE. Probably can use some debug code until we're sure. Let me know if you have questions. |
|
@yorzi Here's the list to do right now: 0ae1e8d Not yet testing the registerComponent API
TODO:
import ReactOnRails from 'react_on_rails';
|
|
@alexfedoseev I had same idea to split current js into several small ones. Great hints! |
There was a problem hiding this comment.
I can not understand this variable here. If we attach components to this components const, how should it work? (comparing to previous window.component_name or global.component_name) cc @justin808 @alexfedoseev
|
There are some errors which might relate to |
|
@yorzi Try to update to Babel 6 (shakacode/react-webpack-rails-tutorial@d67548b) |
|
@yorzi It's up to you, I'm not sure which would be easier, but another option is to just move the tests from the dummy app to the You will have to refactor some of them since some are server-rendering specific as well as test react-router, which we currently aren't generating. So the dev_tests generator will have to decide which tests to copy over for each of the server-rendering examples. Then we could just get rid of the dummy apps. That way we don't have this problem in the future, because they get stale very easily. This was one of the todo items in #92 However, this is probably a lot of work and you may want to just make a baby step with bringing the dummy apps up to speed first. It's up to you. |
013c761 to
4c587db
Compare
1dbb607 to
8a9a7ac
Compare
|
@alexfedoseev Any suggestions? @yorzi See checklist at top of discussion.
ReactOnRails.registerComponent('HelloWorld', HelloWorld, { generator: true });
ReactOnRails.registerComponent('HelloWorldWithLogAndThrow', HelloWorldWithLogAndThrow);or ReactOnRails.register('HelloWorld', HelloWorld, { generator: true });
ReactOnRails.register('HelloWorldWithLogAndThrow', HelloWorldWithLogAndThrow); |
There was a problem hiding this comment.
could we extract a variable or two just for readability; context is a boolean?
There was a problem hiding this comment.
context is either window or global.
|
@justin808: I finally got it passing in CI. Currently we are using selenium firefox as the driver for spec/dummy and poltergeist for the generated example apps. We could: A) Keep it as is |
|
Selenium is firefox is fine for generated apps on CI. |
|
@robwise I've released rc.1 and I'm done with the tests. I think any remaining JS tests are largely covered by our integration tests. I'd say if no serious issues are uncovered this week, we ship later in the week! |
02fed06 to
10f2e24
Compare
|
@robwise @alexfedoseev How about we change the official linter setup to use: https://github.com/shakacode/style-guide-javascript/tree/master/packages/eslint-config-shakacode |
|
@justin808 That's why we've made it :) |
|
@justin808 @alexfedoseev Yep, definitely! And we need to test if the example apps are actually getting linted once and for all. |
|
Looks like RC2 was tagged on GitHub, but not released to Rubygems or NPM. Can you do this or should I just wait for RC3 / final release? |
|
@bensie Give me a couple hours. I'll push up RC3! |
634988e to
5b3f3c9
Compare
|
@justin808 I'll give it a go shortly...thanks! |
|
I'm going to squash commits and merge to master tomorrow! |
972c205 to
5938d52
Compare
a186ef5 to
8be023b
Compare
- Move JavaScript part of react_on_rails to npm package
'react-on-rails'.
- Converted JavaScript code to ES6! with tests!
- No global namespace pollution. ReactOnRails is the only global added.
- New API. Instead of placing React components on the global namespace,
you instead call ReactOnRails.register, passing an object where keys
are the names of your components.
```
import ReactOnRails from 'react-on-rails';
ReactOnRails.registerComponent({name: component});
```
Best done with Object destructing
```
import ReactOnRails from 'react-on-rails';
ReactOnRails.registerComponent(
{
Component1,
Component2
}
);
```
Previously, you used
```
window.Component1 = Component1;
window.Component2 = Component2;
```
This would pollute the global namespace. See details in the README.md
for more information.
- Your jade template for the WebpackDevServer setup should use the new
API:
`ReactOnRails.render(componentName, props, domNodeId);`
such as:
`ReactOnRails.render("HelloWorldApp", {name: "Stranger"}, 'app');`
- All npm dependency libraries updated. Most notable is going to Babel
6.
- Dropped support for react 0.13.
- JS Linter uses ShakaCode JavaScript style:
https://github.com/shakacode/style-guide-javascript
- Generators account these differences.
Other fixes and changes
* Auto detection of generator function!
* Previously, we could not have react installed as a devDependency at the
top level with react-on-rails, or else we get an obscure 'react is
included multiple times' error.
Fix is to add this to the webpack configs:
resolve: {
root: [path.join(__dirname, 'app')],
extensions: ['', '.js', '.jsx'],
fallback: [path.join(__dirname, 'node_modules')],
alias: {
react: path.resolve('./node_modules/react'),
"react-dom": path.resolve('./node_modules/react-dom'),
},
},
That ensures that react is only loaded from one place.
Also cleaned up linting and test scripts so that it's easier to run all
the tests.
* Finish up the changes to the generators
* Doc updates
* Changed domId to domNodeId (thanks Rob and Alex)
* Fixed generators to use new API of "registration" from "globals"
* Fixed tests for generators
* Updated doc to indicate directories to ignore
* Change example apps to use Poltergeist for integration tests
* Move coveralls push to Rakefile so we don't fail after running tests locally and short circuit the linters
* Update technique for generatorFunction
See discussion on
https://discuss.reactjs.org/t/how-to-determine-if-js-object-is-react-component/2825/2
* Change styling of gen app
* fix issue with ruby-lint.yml
* Fixed display of warning messages and stop app
* add option to override stopping when you get warnings
* Made the dumb component dumber, better formatting
* Allows removal of bootstrap and better styling
* Add resolveLoader to generated example apps' webpack.client.base.config.js
* Shakacode linter style, switch to non-docker lint
* Using eslint-config-shakacode
* Created tutorial
* Create rails3.md
* Add migration steps to changelog.MD
* VersionChecker only warns if major versions are different
8be023b to
f7ef290
Compare
e8fc79d to
0a0b558
Compare
WIP -- conversion to ES6, npm for react_on_rails
* Misc spec example fixes
* Misc spec example fixes

ReactOnRails.register({react1, react2});to integrate with Rails! No more react_on_rails.js asset!'react-on-rails'.
you instead call ReactOnRails.register, passing an object where keys
are the names of your components.
import ReactOnRails from 'react-on-rails'; ReactOnRails.registerComponent({name: component});Best done with Object destructing
import ReactOnRails from 'react-on-rails'; ReactOnRails.registerComponent( { Component1, Component2 } );Previously, you used
window.Component1 = Component1; window.Component2 = Component2;This would pollute the global namespace. See details in the README.md
for more information.
API:
ReactOnRails.render(componentName, props, domNodeId);such as:
ReactOnRails.render("HelloWorldApp", {name: "Stranger"}, 'app');6.
https://github.com/shakacode/style-guide-javascript
Other fixes and changes
Auto detection of generator function!
Previously, we could not have react installed as a devDependency at the
top level with react-on-rails, or else we get an obscure 'react is
included multiple times' error.
Fix is to add this to the webpack configs:
resolve: {
root: [path.join(__dirname, 'app')],
extensions: ['', '.js', '.jsx'],
fallback: [path.join(__dirname, 'node_modules')],
alias: {
react: path.resolve('./node_modules/react'),
"react-dom": path.resolve('./node_modules/react-dom'),
},
},
That ensures that react is only loaded from one place.
Also cleaned up linting and test scripts so that it's easier to run all
the tests.
Finish up the changes to the generators
Doc updates
Changed domId to domNodeId (thanks Rob and Alex)
Fixed generators to use new API of "registration" from "globals"
Fixed tests for generators
Updated doc to indicate directories to ignore
Change example apps to use Poltergeist for integration tests
Move coveralls push to Rakefile so we don't fail after running tests locally and short circuit the linters
Update technique for generatorFunction
See discussion on
https://discuss.reactjs.org/t/how-to-determine-if-js-object-is-react-component/2825/2
Change styling of gen app
fix issue with ruby-lint.yml
Fixed display of warning messages and stop app
add option to override stopping when you get warnings
Made the dumb component dumber, better formatting
Allows removal of bootstrap and better styling
Add resolveLoader to generated example apps' webpack.client.base.config.js
Shakacode linter style, switch to non-docker lint
Using eslint-config-shakacode
Created tutorial
Create rails3.md
Add migration steps to changelog.MD
VersionChecker only warns if major versions are different
See #128