react_on_rails 12.0.1 → 12.0.5.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -1
  3. data/.eslintrc +0 -1
  4. data/.github/workflows/lint-js-and-ruby.yml +53 -0
  5. data/.github/workflows/main.yml +178 -0
  6. data/.github/workflows/package-js-tests.yml +35 -0
  7. data/.github/workflows/rspec-package-specs.yml +45 -0
  8. data/.rubocop.yml +15 -44
  9. data/.travis.yml +3 -1
  10. data/CHANGELOG.md +20 -1
  11. data/CONTRIBUTING.md +1 -1
  12. data/Gemfile +1 -33
  13. data/Gemfile.development_dependencies +50 -0
  14. data/NEWS.md +5 -0
  15. data/README.md +26 -20
  16. data/SUMMARY.md +1 -1
  17. data/docs/additional-reading/recommended-project-structure.md +69 -0
  18. data/docs/basics/client-vs-server-rendering.md +2 -0
  19. data/docs/basics/hmr-and-hot-reloading-with-the-webpack-dev-server.md +64 -9
  20. data/docs/basics/installation-into-an-existing-rails-app.md +11 -4
  21. data/docs/basics/react-server-rendering.md +8 -5
  22. data/docs/basics/upgrading-react-on-rails.md +37 -14
  23. data/docs/basics/webpack-configuration.md +12 -18
  24. data/docs/misc/doctrine.md +0 -1
  25. data/docs/outdated/code-splitting.md +2 -2
  26. data/docs/tutorial.md +19 -21
  27. data/lib/generators/react_on_rails/base_generator.rb +8 -1
  28. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +4 -1
  29. data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +1 -1
  30. data/lib/react_on_rails/configuration.rb +2 -0
  31. data/lib/react_on_rails/git_utils.rb +3 -3
  32. data/lib/react_on_rails/helper.rb +10 -9
  33. data/lib/react_on_rails/locales/base.rb +3 -3
  34. data/lib/react_on_rails/locales/to_js.rb +0 -4
  35. data/lib/react_on_rails/locales/to_json.rb +0 -4
  36. data/lib/react_on_rails/prerender_error.rb +1 -1
  37. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +6 -6
  38. data/lib/react_on_rails/test_helper.rb +2 -0
  39. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
  40. data/lib/react_on_rails/utils.rb +8 -2
  41. data/lib/react_on_rails/version.rb +1 -1
  42. data/lib/react_on_rails/webpacker_utils.rb +4 -4
  43. data/lib/tasks/assets.rake +6 -6
  44. data/package.json +1 -1
  45. data/rakelib/docker.rake +0 -5
  46. data/rakelib/lint.rake +3 -9
  47. data/rakelib/release.rake +9 -11
  48. data/rakelib/run_rspec.rake +10 -11
  49. data/rakelib/task_helpers.rb +2 -3
  50. data/react_on_rails.gemspec +3 -17
  51. metadata +16 -194
  52. data/docs/additional-reading/webpack-dev-server.md +0 -15
  53. data/docs/basics/recommended-project-structure.md +0 -77
  54. data/ruby-lint.yml +0 -25
@@ -1,15 +0,0 @@
1
- ## Developing with the Webpack Dev Server
2
- One of the benefits of using webpack is access to [webpack's dev server](https://webpack.github.io/docs/webpack-dev-server.html) and its [hot module replacement](https://webpack.github.io/docs/hot-module-replacement-with-webpack.html) functionality.
3
-
4
- The webpack dev server with HMR will apply changes from the code (or styles!) to the browser as soon as you save whatever file you're working on. You won't need to reload the page, and your data will still be there. Start foreman as normal (it boots up the Rails server *and* the webpack HMR dev server at the same time).
5
-
6
- ```bash
7
- foreman start -f Procfile.dev
8
- ```
9
-
10
- Open your browser to [localhost:3000](http://localhost:3000). Whenever you make changes to your JavaScript code in the `client` folder, they will automatically show up in the browser. Hot module replacement is already enabled by default.
11
-
12
- Note that **React-related error messages are possibly more helpful when encountered in the dev server** than the Rails server as they do not include noise added by the React on Rails gem.
13
-
14
- ### Adding Additional Routes for the Dev Server
15
- As you add more routes to your front-end application, you will need to make the corresponding API for the dev server in `client/server.js`. See our example `server.js` from our [tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client%2Fserver-express.js).
@@ -1,77 +0,0 @@
1
- # Recommended Project structure
2
-
3
- The React on Rails generator uses the standard `rails/webpacker` convention of this structure:
4
-
5
- ```yml
6
- app/javascript:
7
- ├── bundles:
8
- │ # Logical groups of files that can be used for code splitting
9
- │ └── hello-world-bundle.js
10
- ├── packs:
11
- │ # only webpack entry files here
12
- │ └── hello-world-bundle.js
13
- ```
14
-
15
- However, you may wish to move all your client side files to a single directory called something like `/client`.
16
-
17
- ## Steps to convert from the generator defaults to use a `/client` directory structure.
18
-
19
- 1. Move the directory:
20
-
21
- ```
22
- mv app/javascript client
23
- ```
24
-
25
- 2. Edit your `/config/webpacker.yml` file. Change the `default/source_path`:
26
-
27
- ```yml
28
- source_path: client
29
- ```
30
-
31
- ## Moving node_modules from `/` to `/client` with a custom webpack setup.
32
-
33
- `rails/webpacker` probably doesn't support having your main node_modules directory under `/client`, so only follow these steps if you want to use your own webpack configuration.
34
-
35
- 1. Move the `/package.json` to `/client/package.json`
36
- 2. Create a `/package.json` that delegates to `/client/package.json`. See the example in [spec/dummy/package.json](../../spec/dummy/package.json).
37
- 3. See the webpack configuration in [spec/dummy/client](../../spec/dummy/client) for a webpack configuration example.
38
-
39
-
40
- ## JavaScript Assets
41
- 1. `/client`: All client side JavaScript goes under the `/client` directory. Place all the major domains of the client side app under client.
42
- 1. `/client/app`: All application JavaScript. Note the adherence to the [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript#naming-conventions) where we name the files to correspond to exported Objects (PascalCase) or exported functions (camelCase). We don't use dashes or snake_case for JavaScript files, except for possibly some config files.
43
- 1. `/client/app/bundles`: Top level of different app domains. Use a name within this directory for you app domains. For example, if you had a domain called `widget-editing`, then you would have: `/client/app/bundles/widget-editing`
44
- 1. `/client/app/lib`: Common code for bundles
45
- 1. Within each bundle directory (or the lib directory), such as a domain named "comments"
46
- `/client/app/bundles/comments`, use following directory structure, if you're using redux. However, with React hooks, this will probably be a bit different:
47
-
48
- * `/actions`: Redux actions.
49
- * `/components`: "dumb" components (no connections to Redux or Ajax). These get props and can render themselves and children.
50
- * `/constants`: Constants used by Redux actions and reducers.
51
- * `/containers`: "smart" components. These components are bound to Redux.
52
- * `/reducers`: Reducers for redux.
53
- * `/routes`: Routes for React Router.
54
- * `/store`: Store, which might be [configured differently for dev vs. production](https://github.com/reactjs/redux/tree/master/examples/real-world/store).
55
- * `/startup`: Component bindings to stores, with registration of components and stores.
56
- * `/schemas`: Schemas for AJAX JSON requests and responses, as used by the [Normalizr](https://github.com/gaearon/normalizr) package.
57
-
58
- ## CSS, Sass, Fonts, and Images
59
- Should you move your styling assets to Webpack? Or stick with the plain Rails asset pipeline. It depends! You have 2 basic choices:
60
-
61
- ### Simple Rails Way
62
- This isn't really any technique, as you keep handling all your styling assets using Rails standard tools, such as using the [sass-rails gem](https://rubygems.org/gems/sass-rails/versions/5.0.4). Basically, Webpack doesn't get involved with styling. Your Rails layouts just doing the styling the standard Rails way.
63
-
64
- #### Advantages
65
- 1. Much simpler! There's no changes really from your current processes.
66
-
67
- ### Using Webpack to Manage Styling Assets
68
- This technique involves customization of the webpack config files to generate CSS, image, and font assets.
69
-
70
- #### Directory structure
71
- 1. `/client/app/assets`: Assets for CSS for client app.
72
- 1. `/client/app/assets/fonts` and `/client/app/assets/styles`: Globally shared assets for styling. Note, most Sass and image assets will be stored next to the JavaScript files.
73
-
74
- #### Advantages
75
- 1. You can use [CSS modules](https://github.com/css-modules/css-modules), which is super compelling once you seen the benefits.
76
- 1. You can do hot reloading of your assets. Thus, you do not have to refresh your web page to see asset change, including changing styles.
77
- 1. You can run your client code on a mocked out express server for super fast prototyping. In other words, your client application can somewhat more easily be move to a different application server.
@@ -1,25 +0,0 @@
1
- # Not currently using ruby-lint
2
- ---
3
- presenter: syntastic
4
-
5
- # Be sure to edit this per your project!
6
- directories:
7
- - app
8
- - lib
9
- - spec
10
-
11
- ignore_paths:
12
- - client
13
- - node_modules
14
- - coverage
15
- - examples
16
-
17
- analysis_classes:
18
- # - argument_amount
19
- - pedantics
20
- - shadowing_variables
21
- # Too many false positives for these
22
- # - undefined_methods
23
- # - undefined_variables
24
- # - unused_variables
25
- - useless_equality_checks