react_on_rails 12.5.0 → 13.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -1
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.github/workflows/main.yml +3 -3
  6. data/.gitignore +0 -3
  7. data/.prettierignore +2 -0
  8. data/CHANGELOG.md +22 -3
  9. data/Gemfile.development_dependencies +6 -6
  10. data/README.md +10 -15
  11. data/docs/deployment/heroku-deployment.md +1 -1
  12. data/docs/guides/configuration.md +23 -8
  13. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +4 -4
  14. data/docs/guides/how-react-on-rails-works.md +1 -1
  15. data/docs/guides/rspec-configuration.md +1 -1
  16. data/docs/guides/tutorial.md +15 -19
  17. data/docs/guides/upgrading-react-on-rails.md +15 -0
  18. data/docs/guides/webpack-configuration.md +1 -1
  19. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +2 -2
  20. data/lib/generators/react_on_rails/base_generator.rb +9 -8
  21. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +2 -2
  22. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-static +2 -2
  23. data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +25 -8
  24. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +2 -2
  25. data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +1 -1
  26. data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +1 -1
  27. data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +1 -1
  28. data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpack.config.js.tt +15 -0
  29. data/lib/generators/react_on_rails/templates/base/base/config/webpacker.yml +2 -2
  30. data/lib/react_on_rails/configuration.rb +40 -41
  31. data/lib/react_on_rails/helper.rb +3 -3
  32. data/lib/react_on_rails/locales/base.rb +1 -3
  33. data/lib/react_on_rails/react_component/render_options.rb +14 -0
  34. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +8 -6
  35. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
  36. data/lib/react_on_rails/test_helper.rb +2 -2
  37. data/lib/react_on_rails/version.rb +1 -1
  38. data/lib/react_on_rails/webpacker_utils.rb +2 -7
  39. data/lib/tasks/assets.rake +1 -42
  40. data/lib/tasks/locale.rake +1 -2
  41. data/package.json +1 -1
  42. data/rakelib/example_type.rb +5 -2
  43. data/rakelib/examples.rake +3 -10
  44. data/rakelib/release.rake +6 -0
  45. data/rakelib/task_helpers.rb +0 -7
  46. data/react_on_rails.gemspec +1 -2
  47. data/yarn.lock +117 -71
  48. metadata +10 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28e3d2a5f4910c2d0e1aec7d57f2b3d5073cc3317d65dc92d209608d6b305dcd
4
- data.tar.gz: f3280cfe4e5e57aeb60da72928a45ff01df41890ee7ab8a018cb6b4fefef61c8
3
+ metadata.gz: cdfa729f75cfd337b3436fe6e310d7e6a7789455fcba1baa729a2288d98c646f
4
+ data.tar.gz: 54495ad6beed806991e973866a4ccd62fd7b41d3141cbaec2e71a07e13999563
5
5
  SHA512:
6
- metadata.gz: 9ee357656b8bf3fd8367d6036269f8d844c2e6dc72a6133698930dcfae138bfc7312d44d383dcd8d8db20d67da2b110e177374d18322738619ff4de7d43080e4
7
- data.tar.gz: 6a291c92e4d2c86d9b1b6c3bac60a2a4980c7b0c876227d53ad741c802f23a1a63c2bcb451b19a89f0c7e8eb583617d42cafc0810d5f3289866e23def0f8fb8c
6
+ metadata.gz: d0610cfa82d1d1b60f09f1586fb966dcfa12daf8549762f09e74a1fc00df6e0c8374138950e5195db0bed8501f7d8f3a1f62d90a9a779e6b652a0ada08d19d4e
7
+ data.tar.gz: 9e87301d7790829e6fe2391a68cf8de6e5724777e11b955b112783c7cfec13820d5a0c28691c5f2851ec49c92ab20e886b8c2a7b4c3fe2cfcec727d662cc4490
data/.circleci/config.yml CHANGED
@@ -55,7 +55,7 @@ aliases:
55
55
  command: |
56
56
  gem install bundler
57
57
  echo "Bundler version: "; bundle --version
58
- cd spec/dummy && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
58
+ cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
59
59
 
60
60
  # Install ruby gems unless existing set of gems is satisfying bundler.
61
61
  - &install-package-ruby-gems
@@ -63,6 +63,7 @@ aliases:
63
63
  command: |
64
64
  gem install bundler
65
65
  echo "Bundler version: "; bundle --version
66
+ bundle lock --add-platform 'x86_64-linux'
66
67
  bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
67
68
 
68
69
  # Restore node_modules dir from cache using yarn.lock checksum as a key.
@@ -316,6 +317,7 @@ workflows:
316
317
  - build-dummy-app-webpack-test-bundles:
317
318
  requires:
318
319
  - install-dummy-app-node-packages
320
+ - install-dummy-app-ruby-gems
319
321
  - package-js-tests:
320
322
  requires:
321
323
  - install-package-node-packages
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ A bug is a crash or incorrect behavior. If you have a debugging or troubleshooting question, please open [a discussion](https://github.com/shakacode/react_on_rails/discussions).
11
+
12
+ ## Environment
13
+
14
+ 1. Ruby version:
15
+ 2. Rails version:
16
+ 3. Webpacker version:
17
+ 4. React on Rails version:
18
+
19
+ ## Expected behavior
20
+
21
+ ## Actual behavior
22
+
23
+ ## Small, reproducible repo
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -55,7 +55,7 @@ jobs:
55
55
  path: spec/dummy/vendor/bundle
56
56
  key: v4-dummy-app-gem-cache-${{ hashFiles('spec/dummy/Gemfile.lock') }}
57
57
  - name: Install Ruby Gems for dummy app
58
- run: cd spec/dummy && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
58
+ run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
59
59
  - name: Build test bundles for dummy app
60
60
  run: cd spec/dummy && yarn run build:test
61
61
  - id: get-sha
@@ -131,9 +131,9 @@ jobs:
131
131
  - name: yalc add react-on-rails
132
132
  run: cd spec/dummy && yalc add react-on-rails
133
133
  - name: Install Ruby Gems for package
134
- run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
134
+ run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
135
135
  - name: Install Ruby Gems for dummy app
136
- run: cd spec/dummy && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
136
+ run: cd spec/dummy && bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
137
137
  - name: Ensure minimum required Chrome version
138
138
  run: |
139
139
  echo -e "Already installed $(google-chrome --version)\n"
data/.gitignore CHANGED
@@ -11,9 +11,6 @@
11
11
  /vendor/
12
12
 
13
13
  /spec/examples.txt
14
- /spec/dummy/client/node_modules
15
- /spec/dummy/public/webpack/
16
- /spec/dummy/coverage/
17
14
  /spec/react_on_rails/dummy-for-generators/
18
15
 
19
16
  # RVM
data/.prettierignore CHANGED
@@ -8,3 +8,5 @@ gen-examples/examples/*
8
8
  node_package/lib/*
9
9
  spec/react_on_rails/dummy-for-generators/app/javascript/bundles/HelloWorld/*
10
10
  bundle/
11
+ spec/dummy/lib/bs/**
12
+ *.bs.js
data/CHANGELOG.md CHANGED
@@ -17,10 +17,25 @@ Changes since last non-beta release.
17
17
 
18
18
  *Please add entries here for your pull requests that are not yet released.*
19
19
 
20
+ ### [12.6.0] - 2022-01-22
21
+
22
+ ### Added
23
+ - A `rendering_props_extension` configuration which takes a module with an `adjust_props_for_client_side_hydration` method, which is used to process props differently for server/client if `prerender` is set to `true`. [PR 1413](https://github.com/shakacode/react_on_rails/pull/1413) by [gscarv13](https://github.com/gscarv13) & [judahmeek](https://github.com/judahmeek).
24
+
25
+ ### [12.5.2] - 2021-12-29
26
+ ### Fixed
27
+ - Usage of config.build_production_command for custom command for production builds fixed. [PR 1415](https://github.com/shakacode/react_on_rails/pull/1415) by [judahmeek](https://github.com/judahmeek).
28
+
29
+ ### [12.5.1] - 2021-12-27
30
+
31
+ ### Fixed
32
+ - A fatal server rendering error if running an ReactOnRails >=12.4.0 with ReactOnRails Pro <2.4.0. [PR 1412](https://github.com/shakacode/react_on_rails/pull/1412) by [judahmeek](https://github.com/judahmeek).
33
+
20
34
  ### [12.5.0] - 2021-12-26
21
35
 
22
36
  #### Added
23
- - Added webpack configuration files as part of the generator and updated webpacker to version 6 [PR 1404](https://github.com/shakacode/react_on_rails/pull/1404) by [gscarv13](https://github.com/gscarv13).
37
+ - Support for React 18, including the changed SSR API. [PR 1409](https://github.com/shakacode/react_on_rails/pull/1409) by [kylemellander](https://github.com/kylemellander).
38
+ - Added webpack configuration files as part of the generator and updated webpacker to version 6. [PR 1404](https://github.com/shakacode/react_on_rails/pull/1404) by [gscarv13](https://github.com/gscarv13).
24
39
  - Supports Rails 7.
25
40
 
26
41
  #### Changed
@@ -92,7 +107,7 @@ invoked to return the React component. In that case, you won't need to pass any
92
107
  [PR 1268](https://github.com/shakacode/react_on_rails/pull/1268) by [justin808](https://github.com/justin808)
93
108
 
94
109
  See [docs/guides/upgrading-react-on-rails](https://www.shakacode.com/react-on-rails/docs/guides/upgrading-react-on-rails#upgrading-to-v12)
95
- for details.
110
+ for details.
96
111
 
97
112
  #### Other Updates
98
113
  * `react_on_rails` fully supports `rails/webpacker`. The example test app in `spec/dummy` was recently converted over to use rails/webpacker v4+. It's a good example of how to leverage rails/webpacker's webpack configuration for server-side rendering.
@@ -984,7 +999,11 @@ Best done with Object destructing:
984
999
  ##### Fixed
985
1000
  - Fix several generator related issues.
986
1001
 
987
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.4.0...master
1002
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/12.6.0...master
1003
+ [12.6.0]: https://github.com/shakacode/react_on_rails/compare/12.5.2...12.6.0
1004
+ [12.5.2]: https://github.com/shakacode/react_on_rails/compare/12.5.1...12.5.2
1005
+ [12.5.1]: https://github.com/shakacode/react_on_rails/compare/12.5.0...12.5.1
1006
+ [12.5.0]: https://github.com/shakacode/react_on_rails/compare/12.4.0...12.5.0
988
1007
  [12.4.0]: https://github.com/shakacode/react_on_rails/compare/12.3.0...12.4.0
989
1008
  [12.3.0]: https://github.com/shakacode/react_on_rails/compare/12.2.0...12.3.0
990
1009
  [12.2.0]: https://github.com/shakacode/react_on_rails/compare/12.1.0...12.2.0
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "webpacker", "6.0.0.rc.6"
3
+ gem "shakapacker", ">= 6.1.1"
4
4
  gem "bootsnap", require: false
5
- gem "rails"
5
+ gem "rails", "~> 7.0"
6
6
  gem "sqlite3"
7
- gem "sass-rails"
7
+ gem "sass-rails", "~> 6.0"
8
8
  gem "uglifier"
9
9
  gem "jquery-rails"
10
10
  gem "puma"
@@ -17,11 +17,11 @@ gem "jbuilder"
17
17
  # bundle exec rake doc:rails generates the API under doc/api.
18
18
  gem "sdoc", group: :doc
19
19
 
20
- gem "sprockets"
20
+ gem "sprockets", "~> 4.0"
21
21
 
22
22
  gem "amazing_print"
23
23
 
24
- gem "mini_racer"
24
+ gem "mini_racer", ">= 0.6.2"
25
25
 
26
26
  group :development, :test do
27
27
  gem "listen"
@@ -34,7 +34,7 @@ group :development, :test do
34
34
  gem "rubocop-performance", require: false
35
35
  gem "rubocop-rspec", require: false
36
36
  gem "scss_lint", require: false
37
- gem "spring"
37
+ gem "spring", "~> 4.0"
38
38
  end
39
39
 
40
40
  group :test do
data/README.md CHANGED
@@ -12,14 +12,12 @@
12
12
  [![License](https://img.shields.io/badge/license-mit-green.svg)](LICENSE.md) [![Build Status](https://travis-ci.org/shakacode/react_on_rails.svg?branch=master)](https://travis-ci.org/shakacode/react_on_rails) [![Gem Version](https://badge.fury.io/rb/react_on_rails.svg)](https://badge.fury.io/rb/react_on_rails) [![npm version](https://badge.fury.io/js/react-on-rails.svg)](https://badge.fury.io/js/react-on-rails) [![Code Climate](https://codeclimate.com/github/shakacode/react_on_rails/badges/gpa.svg)](https://codeclimate.com/github/shakacode/react_on_rails) [![Coverage Status](https://coveralls.io/repos/shakacode/react_on_rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/shakacode/react_on_rails?branch=master) [![](https://ruby-gem-downloads-badge.herokuapp.com/react_on_rails?type=total)](https://rubygems.org/gems/react_on_rails)
13
13
 
14
14
  # News
15
+ * ShakaCode now maintains the official successor to `rails/webpacker`, [`shakapacker`](https://github.com/shakacode/shakapacker).
15
16
  * Project is updated to support Rails 7!
16
- * **React and Webpack with Ruby on Rails**: The current version of https://github.com/rails/webpacker will soon ship. While it won't be the default for Rails 7, it is not "deprecated." The core webpack configuration has become slimmer, allowing easier extension. If you want to get started today, use the master branch of [shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh) with `gem "webpacker", "6.0.0.rc.6"` Any updates to get to v6 from this point forward should be simple.
17
-
18
- If you have time, please comment on Justin's final proposals for Webpacker v6: [webpacker/pulls/justin808](https://github.com/rails/webpacker/pulls/justin808).
19
17
 
20
18
  -----
21
19
 
22
- *These are the docs for React on Rails 12. To see the version 11 docs, [click here](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
20
+ *These are the docs for React on Rails 13. To see the older docs: [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0) and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
23
21
 
24
22
  #### About
25
23
  React on Rails integrates Rails with (server rendering of) Facebook's [React](https://github.com/facebook/react) front-end framework.
@@ -29,13 +27,13 @@ This project is maintained by the software consulting firm [ShakaCode](https://w
29
27
  Are you interested in optimizing your webpack setup for React on Rails including code
30
28
  splitting with [react-router](https://github.com/ReactTraining/react-router#readme) and
31
29
  [loadable-components](https://loadable-components.com/) with server-side rendering for SEO and hot-reloading for developers?
32
- We did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/). Check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/).
30
+ We did this for Popmenu, [lowering Heroku costs 20-25% while getting a 73% decrease in average response times](https://www.shakacode.com/recent-work/popmenu/). Several years later, Popmenu is serving millions of SSR requests per day React on Rails.
33
31
 
34
- For more information, feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com), maintainer of React on Rails.
32
+ Check out [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/). For more information, feel free to contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com), maintainer of React on Rails.
35
33
 
36
34
  # Documentation
37
35
 
38
- See the documentation at [shakacode.com/react-on-rails/docs](https://www.shakacode.com/react-on-rails/docs/).
36
+ See the documentation at **[shakacode.com/react-on-rails/docs](https://www.shakacode.com/react-on-rails/docs/)**.
39
37
 
40
38
  ## Project Objective
41
39
 
@@ -55,11 +53,9 @@ Given that `rails/webpacker` gem already provides basic React integration, why w
55
53
 
56
54
  See [Rails/Webpacker React Integration Options](https://www.shakacode.com/react-on-rails/docs/guides/rails-webpacker-react-integration-options) for comparisons to other gems.
57
55
 
58
- See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
59
-
60
56
  ## Online demo
61
-
62
- A deployed version of the project `spec/dummy` which demonstrates several uses of `react_on_rails` is available on heroku [through this link](https://ror-spec-dummy.herokuapp.com/)
57
+ * See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
58
+ * A deployed version of the project `spec/dummy` which demonstrates several uses of `react_on_rails` is available on heroku [through this link](https://ror-spec-dummy.herokuapp.com/)
63
59
 
64
60
  ## ShakaCode Forum Premium Content
65
61
  _Requires creating a free account._
@@ -67,20 +63,19 @@ _Requires creating a free account._
67
63
  * [How to use different versions of a file for client and server rendering](https://forum.shakacode.com/t/how-to-use-different-versions-of-a-file-for-client-and-server-rendering/1352)
68
64
  * [How to conditionally render server side based on the device type](https://forum.shakacode.com/t/how-to-conditionally-render-server-side-based-on-the-device-type/1473)
69
65
 
70
-
71
66
  ## Prerequisites
72
67
 
73
- Ruby on Rails >=5 and rails/webpacker 4.2+.
68
+ Ruby on Rails >=5, rails/webpacker >= 4.2, Ruby >= 2.7
74
69
 
75
70
  # Support
76
71
 
77
72
  * [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
78
73
  - [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
79
- - **[forum.shakacode.com](https://forum.shakacode.com)**: Post your questions
74
+ - [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
75
+ - **[forum.shakacode.com](https://forum.shakacode.com)**: Other discussions
80
76
  - **[@railsonmaui on Twitter](https://twitter.com/railsonmaui)**
81
77
  - *See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time.*
82
78
  - See [Projects](https://github.com/shakacode/react_on_rails/tree/master/PROJECTS.md) using and [KUDOS](https://github.com/shakacode/react_on_rails/tree/master/KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
83
- - *See [NEWS.md](https://github.com/shakacode/react_on_rails/tree/master/NEWS.md) for more notes over time.*
84
79
 
85
80
  ## Contributing
86
81
 
@@ -22,7 +22,7 @@ Alternatively, you can specify `config.build_production_command` to have
22
22
  react_on_rails invoke a command for you during assets:precompile.
23
23
 
24
24
  ```
25
- config.build_production_command = "RAILS_ENV=production bin/webpack"
25
+ config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/webpacker"
26
26
  ```
27
27
 
28
28
  ### Consider Removing Webpacker's clean task
@@ -68,11 +68,11 @@ ReactOnRails.configure do |config|
68
68
 
69
69
  # If you're using the standard rails/webpacker configuration of webpack, then rails/webpacker
70
70
  # will automatically modify or create an assets:precompile task to build your assets. If so,
71
- # set this value to nil. Alternatively, you can specify `config.build_production_command`
71
+ # set this value to nil. Alternatively, you can specify `config.build_production_command`
72
72
  # to have react_on_rails invoke a command for you during assets:precompile.
73
73
  # The command is either a script or a module containing a class method `call`
74
74
  # In this example, the module BuildProductionCommand would have a class method `call`.
75
- config.build_production_command = "RAILS_ENV=production bin/webpack"
75
+ config.build_production_command = "RAILS_ENV=production bin/webpacker"
76
76
 
77
77
  # See bottom for an example of the BuildProductionCommand module.
78
78
  # config.build_production_command = BuildProductionCommand
@@ -129,6 +129,11 @@ ReactOnRails.configure do |config|
129
129
  # any server rendering issues immediately during development.
130
130
  config.raise_on_prerender_error = Rails.env.development?
131
131
 
132
+ # This configuration allows logic to be applied to client rendered props, such as stripping props that are only used during server rendering.
133
+ # Add a module with an adjust_props_for_client_side_hydration method that expects the component's name & props hash
134
+ # See below for an example definition of RenderingPropsExtension
135
+ config.rendering_props_extension = RenderingPropsExtension
136
+
132
137
  ################################################################################
133
138
  # Server Renderer Configuration for ExecJS
134
139
  ################################################################################
@@ -176,9 +181,8 @@ ReactOnRails.configure do |config|
176
181
 
177
182
  # You can optionally add values to your rails_context. This object is passed
178
183
  # every time a component renders.
179
- # See example below for an example definition of RenderingExtension
180
- #
181
- # config.rendering_extension = RenderingExtension
184
+ # See below for an example definition of RenderingExtension
185
+ config.rendering_extension = RenderingExtension
182
186
 
183
187
  ################################################################################
184
188
  ################################################################################
@@ -199,7 +203,7 @@ ReactOnRails.configure do |config|
199
203
  # with rspec then this controls what yarn command is run
200
204
  # to automatically refresh your webpack assets on every test run.
201
205
  #
202
- config.build_test_command = "RAILS_ENV=test bin/webpack"
206
+ config.build_test_command = "RAILS_ENV=test bin/webpacker"
203
207
 
204
208
  # CONFIGURE YOUR SOURCE FILES
205
209
  # The test helper needs to know where your JavaScript files exist. The value is configured
@@ -216,14 +220,25 @@ ReactOnRails.configure do |config|
216
220
  end
217
221
  ```
218
222
 
223
+ Example of a ReactOnRailsConfig module for `client_props_extension`:
224
+
225
+ ```ruby
226
+ module RenderingPropsExtension
227
+ # The modify_props method will be called by ReactOnRails::ReactComponent::RenderOptions if config.client_props_extension is defined
228
+ def self.adjust_props_for_client_side_hydration(component_name, props)
229
+ component_name == 'HelloWorld' ? props.except(:server_side_only) : props
230
+ end
231
+ end
232
+ ```
233
+
219
234
  Example of a ReactOnRailsConfig module for `production_build_command`:
220
235
 
221
236
  ```ruby
222
237
  module BuildProductionCommand
223
238
  include FileUtils
224
- # Method with the name of call will be called during assets:precompile
239
+ # The call method will be called during assets:precompile
225
240
  def self.call
226
- sh "bin/webpack"
241
+ sh "bin/webpacker"
227
242
  end
228
243
  end
229
244
  ```
@@ -11,10 +11,10 @@ The webpack-dev-server provides:
11
11
  For use with webpack, see **Client Side rendering and HMR using react-refresh-webpack-plugin** section bellow or visit [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) for additional details.
12
12
 
13
13
  If you are ***not*** using server-side rendering (***not*** using `prerender: true`),
14
- then you can follow all the regular docs for using the `bin/webpack-dev-server`
14
+ then you can follow all the regular docs for using the `bin/webpacker-dev-server`
15
15
  during development.
16
16
 
17
- # Server Side Rendering with the Default rails/webpacker bin/webpack-dev-server
17
+ # Server Side Rendering with the Default rails/webpacker bin/webpacker-dev-server
18
18
 
19
19
  If you are using server-side rendering, then you have a couple options. The
20
20
  recommended technique is to have a different webpack configuration for server
@@ -41,7 +41,7 @@ If you don't configure these two to false, you'll see errors like:
41
41
 
42
42
  # Client Side rendering with HMR using react-refresh-webpack-plugin
43
43
  ## Basic installation
44
- To enable HMR functionality you have to use `./bin/webpack-dev-server`
44
+ To enable HMR functionality you have to use `./bin/webpacker-dev-server`
45
45
  1. In `config/webpacker.yml` set **hmr** and **inline** `dev_server` properties to true.
46
46
  ```
47
47
  dev_server:
@@ -59,7 +59,7 @@ To enable HMR functionality you have to use `./bin/webpack-dev-server`
59
59
 
60
60
  3. HMR is for use with the webpack-dev-server, so we only add this for the webpack-dev-server.
61
61
  ```
62
- const { devServer } = require('@rails/webpacker')
62
+ const { devServer } = require('shakapacker')
63
63
 
64
64
  const isWebpackDevServer = process.env.WEBPACK_DEV_SERVER
65
65
 
@@ -32,7 +32,7 @@ Each time you change your client code, you will need to re-generate the bundles
32
32
 
33
33
  For example, you might create a [Procfile.dev](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/Procfile.dev).
34
34
 
35
- On production deployments that use asset precompilation, such as Heroku deployments, `rails/webpacker`, by default, will automatically run webpack to build your JavaScript bundles, running the command `bin/webpack` in your app.
35
+ On production deployments that use asset precompilation, such as Heroku deployments, `rails/webpacker`, by default, will automatically run webpack to build your JavaScript bundles, running the command `bin/webpacker` in your app.
36
36
 
37
37
  However, if you want to run a custom command to run webpack to build your bundles, then you will:
38
38
  1. Define `config.build_production_command` in your [config/initializers/react_on_rails.rb](https://www.shakacode.com/react-on-rails/docs/guides/configuration/)
@@ -12,7 +12,7 @@ compiled by webpack before running tests and during production deployment:
12
12
  2. **Use the react_on_rails settings and helpers**. Use the settings in `config/initializers/react_on_rails.rb`. Refer to [docs/configuration](https://www.shakacode.com/react-on-rails/docs/guides/configuration/).
13
13
 
14
14
  ```yml
15
- config.build_test_command = "NODE_ENV=test RAILS_ENV=test bin/webpack"
15
+ config.build_test_command = "NODE_ENV=test RAILS_ENV=test bin/webpacker"
16
16
  ```
17
17
 
18
18
  Which should you use? If you're already using the `rails/webpacker` way to configure webpack, then
@@ -4,7 +4,7 @@
4
4
 
5
5
  -----
6
6
 
7
- *Updated for Ruby 2.7.1, Rails 6.0.3.1, React on Rails v12.5.0, and Webpacker v6*
7
+ *Updated for Ruby 2.7.1, Rails 6.0.3.1, React on Rails v12.5.0, and Shakapacker v6*
8
8
 
9
9
  This tutorial guides you through setting up a new or existing Rails app with **React on Rails**, demonstrating Rails + React + Redux + Server Rendering.
10
10
 
@@ -21,18 +21,16 @@ By the time you read this, the latest may have changed. Be sure to check the ver
21
21
  * https://rubygems.org/gems/react_on_rails
22
22
  * https://www.npmjs.com/package/react-on-rails
23
23
 
24
- _Note: some of the screen images below show the "npm" command. react_on_rails 6.6.0 and greater uses `yarn`._
25
-
26
24
  ## Setting up your environment
27
25
 
28
- Trying out **React on Rails** is super easy, so long as you have the basic prerequisites. This includes the basics for Rails 6.x and node version 13+. I recommend `rvm` and `nvm` to install Ruby and Node, and [brew](https://brew.sh/) to install [yarn](https://yarnpkg.com/en/docs/install#mac-tab). Rails can be installed as an ordinary gem.
26
+ Trying out **React on Rails** is super easy, so long as you have the basic prerequisites. This includes the basics for Rails 6.x and node version 14+. I recommend `rvm` or `rbevn` and `nvm` to install Ruby and Node. Rails can be installed as an ordinary gem.
29
27
 
30
28
  ```
31
29
  nvm install node # download and install latest stable Node
32
30
  nvm alias default node # make it default version
33
31
  nvm list # check
34
32
 
35
- brew install yarn # you can use other installer if desired
33
+ brew install yarn # you can use other installer if desired, such as yvm
36
34
  rvm install 2.7 # download and install latest stable Ruby (update to exact version)
37
35
  rvm use 2.7 --default # use it and make it default
38
36
  rvm list # check
@@ -46,40 +44,37 @@ Then we need to create a fresh Rails application as following.
46
44
 
47
45
  First be sure to run `rails -v` and check you are using Rails 5.1.3 or above. If you are using an older version of Rails, you'll need to install webpacker with react per the instructions [here](https://github.com/rails/webpacker).
48
46
 
49
- ```
47
+ ```bash
50
48
  cd <directory where you want to create your new Rails app>
51
49
 
52
50
  # Any name you like for the rails app
53
51
  # Skip javascript so will add that next and get the current version
54
- rails new --skip-sprockets --skip-turbolinks --javascript=webpack test-react-on-rails
52
+ rails new --skip-turbolinks --skip-javascript test-react-on-rails
55
53
 
56
54
  cd test-react-on-rails
57
55
  ```
58
56
 
59
- ## Add the webpacker and react_on_rails gems
57
+ ## Add the shakapacker and react_on_rails gems
60
58
  To avoid issues regarding inconsistent gem and npm versions, you should specify the exact versions
61
59
  of both the gem and npm package. In other words, don't use the `^` or `~` in the version specifications.
62
- _Use the latest version for react_on_rails._
60
+ _Use the latest version for `react_on_rails` and `shakapacker`._
63
61
 
64
62
  ```
65
- gem 'react_on_rails', '12.5.0' # prefer exact gem version to match npm version
63
+ gem 'react_on_rails', '13.0.0' # prefer exact gem version to match npm version
64
+ gem 'shakapacker', '6.1.1' # prefer exact gem version to match npm version
65
+
66
66
  ```
67
67
 
68
68
  Note: The latest released React On Rails version is considered stable. Please use the latest
69
69
  version to ensure you get all the security patches and the best support.
70
70
 
71
- ```bash
72
- bundle add webpacker --git=https://github.com/rails/webpacker.git
73
- bundle add react_on_rails --version=12.5.0 --strict
74
- ```
75
-
76
- ## Run the webpacker generator
71
+ ## Run the webpacker (shakapacker) generator
77
72
 
78
73
  ```terminal
79
74
  bundle exec rails webpacker:install
80
75
  ```
81
76
 
82
- Let's commit everything before installing React on Rails.
77
+ **Let's commit everything before installing React on Rails.**
83
78
 
84
79
  ```
85
80
  # Here are git commands to make a new git repo and commit everything.
@@ -98,10 +93,11 @@ If you want the redux install: `rails generate react_on_rails:install --redux`
98
93
  The generator will add `mini_racer`'s latest version. If you're using linux & encounter issues installing `libv8`, here's [a common solution](https://github.com/rubyjs/mini_racer/issues/218).
99
94
 
100
95
  ```
101
- rails generate react_on_rails:install
96
+ bundle exec rails generate react_on_rails:install
102
97
  ```
103
98
 
104
- Enter `a` to replace all configuration files required by the project.
99
+ Enter `a` to replace all configuration files required by the project. You can check the diffs
100
+ before you commit to see what changed.
105
101
 
106
102
  Then run the server with one of the following options:
107
103
 
@@ -5,6 +5,21 @@ If you would like help in migrating between React on Rails versions or help with
5
5
 
6
6
  We specialize in helping companies to quickly and efficiently upgrade. The older versions use the Rails asset pipeline to package client assets. The current and recommended way is to use Webpack 4+ for asset preparation. You may also need help migrating from the `rails/webpacker`'s Webpack configuration to a better setup ready for Server Side Rendering.
7
7
 
8
+ ## Upgrading to v13
9
+
10
+ ### Breaking Change
11
+ Previously, the gem `webpacker` was a Gem dependency.
12
+
13
+ v13 has changed slightly to switch to `shakapacker`.
14
+
15
+ For details, see see the [Shakapacker guide to upgrading](https://github.com/shakacode/shakapacker/blob/master/docs/v6_upgrade.md)
16
+
17
+ In summary:
18
+
19
+ 1. Change the gem reference from 'webpacker' to 'shakapacker'
20
+ 2. Change the npm reference from '@rails/webpacker' to 'shakapacker'
21
+ 3. Other updates, depending on what version of rails/webpacker that you had.
22
+
8
23
  ## Upgrading to v12
9
24
  ### Recent versions
10
25
  Make sure that you are on a relatively more recent version of rails and webpacker. Yes, the [rails/webpacker](https://github.com/rails/webpacker) gem is required!
@@ -33,7 +33,7 @@ Until version 9, all React on Rails apps used the `/client` directory for config
33
33
  You can access values in the `config/webpacker.yml`
34
34
 
35
35
  ```js
36
- const { config, devServer } = require('@rails/webpacker');
36
+ const { config, devServer } = require('shakapacker');
37
37
  ```
38
38
 
39
39
  You will want consider using some of the same values set in these files:
@@ -4,7 +4,7 @@
4
4
  and avoid any duplicates. We don't want different versions of the same packages.
5
5
  We want the versions from rails/webpacker unless we specifically want to override them.
6
6
  2. Search the rails/webpacker repo for anything you're not sure about in terms of package names.
7
- 3. run `bin/webpack` and make sure there are zero errors
7
+ 3. run `bin/webpacker` and make sure there are zero errors
8
8
  4. update webpack plugins and loaders to current or close to current
9
- 5. Make sure that your bin/webpack and bin/webpacker match the latest on
9
+ 5. Make sure that your bin/webpacker and bin/webpacker match the latest on
10
10
  https://github.com/rails/webpacker/tree/master/lib/install/bin
@@ -54,6 +54,7 @@ module ReactOnRails
54
54
  config/webpack/development.js
55
55
  config/webpack/production.js
56
56
  config/webpack/serverWebpackConfig.js
57
+ config/webpack/webpack.config.js
57
58
  config/webpack/webpackConfig.js]
58
59
  config = {
59
60
  message: "// The source code including full typescript support is available at:"
@@ -136,28 +137,28 @@ module ReactOnRails
136
137
 
137
138
  What to do next:
138
139
 
139
- - See the documentation on https://github.com/rails/webpacker/blob/master/docs/webpack.md
140
+ - See the documentation on https://github.com/shakacode/shakapacker#webpack-configuration
140
141
  for how to customize the default webpack configuration.
141
142
 
142
143
  - Include your webpack assets to your application layout.
143
144
 
144
145
  <%= javascript_pack_tag 'hello-world-bundle' %>
145
146
 
146
- - Run `rails s` to start the Rails server and use Webpacker's default lazy compilation.
147
+ - Run `rails s` to start the Rails server.
147
148
 
148
- - Visit http://localhost:3000/hello_world and see your React On Rails app running!
149
-
150
- - Run bin/webpack-dev-server to start the Webpack dev server for compilation of Webpack
149
+ - Run bin/webpacker-dev-server to start the Webpack dev server for compilation of Webpack
151
150
  assets as soon as you save. This default setup with the dev server does not work
152
151
  for server rendering
153
152
 
154
- - Alternately, you may turn off compile in config/webpacker.yml and run the foreman
155
- command to start the rails server and run webpack in watch mode.
153
+ - Visit http://localhost:3000/hello_world and see your React On Rails app running!
154
+
155
+ - Alternately, run the foreman command to start the rails server and run webpack#{' '}
156
+ in watch mode.
156
157
 
157
158
  foreman start -f Procfile.dev-static
158
159
 
159
160
  - To turn on HMR, edit config/webpacker.yml and set HMR to true. Restart the rails server
160
- and bin/webpack-dev-server. Or use Procfile.dev.
161
+ and bin/webpacker-dev-server. Or use Procfile.dev.
161
162
 
162
163
  - To server render, change this line app/views/hello_world/index.html.erb to
163
164
  `prerender: true` to see server rendering (right click on page and select "view source").
@@ -1,5 +1,5 @@
1
1
  # Procfile for development using HMR
2
2
  # You can run these commands in separate shells
3
3
  rails: bundle exec rails s -p 3000
4
- wp-client: HMR=true bin/webpack-dev-server
5
- wp-server: HMR=true SERVER_BUNDLE_ONLY=yes bin/webpack --watch
4
+ wp-client: HMR=true bin/webpacker-dev-server
5
+ wp-server: HMR=true SERVER_BUNDLE_ONLY=yes bin/webpacker --watch
@@ -5,5 +5,5 @@ web: rails s -p 3000
5
5
  # When making frequent changes to client side assets, you will prefer building webpack assets
6
6
  # upon saving rather than when you refresh your browser page.
7
7
  # Note, if using React on Rails localization you will need to run
8
- # `bundle exec rake react_on_rails:locale` before you run bin/webpack
9
- webpack: sh -c 'rm -rf public/packs/* || true && bin/webpack -w'
8
+ # `bundle exec rake react_on_rails:locale` before you run bin/webpacker
9
+ webpack: sh -c 'rm -rf public/packs/* || true && bin/webpacker -w'