react_on_rails 13.4.0 → 14.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -2
  3. data/Gemfile.development_dependencies +10 -8
  4. data/README.md +2 -2
  5. data/lib/generators/react_on_rails/base_generator.rb +10 -2
  6. data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
  7. data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
  8. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
  9. data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
  10. data/lib/react_on_rails/configuration.rb +39 -25
  11. data/lib/react_on_rails/git_utils.rb +3 -3
  12. data/lib/react_on_rails/helper.rb +2 -2
  13. data/lib/react_on_rails/json_output.rb +0 -17
  14. data/lib/react_on_rails/locales/base.rb +4 -4
  15. data/lib/react_on_rails/locales/to_js.rb +1 -1
  16. data/lib/react_on_rails/packs_generator.rb +2 -4
  17. data/lib/react_on_rails/react_component/render_options.rb +1 -1
  18. data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +9 -9
  19. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
  20. data/lib/react_on_rails/test_helper.rb +2 -2
  21. data/lib/react_on_rails/utils.rb +2 -8
  22. data/lib/react_on_rails/version.rb +1 -1
  23. data/lib/react_on_rails/version_checker.rb +2 -2
  24. data/lib/react_on_rails/webpacker_utils.rb +6 -0
  25. data/lib/tasks/assets.rake +1 -1
  26. data/react_on_rails.gemspec +4 -4
  27. metadata +4 -132
  28. data/.bookignore +0 -15
  29. data/.circleci/config.yml +0 -338
  30. data/.coveralls.yml +0 -1
  31. data/.dockerignore +0 -2
  32. data/.eslintignore +0 -17
  33. data/.eslintrc +0 -53
  34. data/.github/FUNDING.yml +0 -1
  35. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
  36. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  37. data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
  38. data/.github/workflows/lint-js-and-ruby.yml +0 -54
  39. data/.github/workflows/main.yml +0 -183
  40. data/.github/workflows/package-js-tests.yml +0 -35
  41. data/.github/workflows/rspec-package-specs.yml +0 -46
  42. data/.gitignore +0 -33
  43. data/.npmignore +0 -22
  44. data/.prettierignore +0 -14
  45. data/.prettierrc +0 -20
  46. data/.rspec +0 -2
  47. data/.rubocop.yml +0 -134
  48. data/.scss-lint.yml +0 -205
  49. data/.travis.yml +0 -61
  50. data/book.json +0 -18
  51. data/docs/additional-details/generator-details.md +0 -56
  52. data/docs/additional-details/manual-installation-overview.md +0 -30
  53. data/docs/additional-details/migrating-from-react-rails.md +0 -17
  54. data/docs/additional-details/recommended-project-structure.md +0 -69
  55. data/docs/additional-details/tips-for-usage-with-sp6.md +0 -15
  56. data/docs/additional-details/updating-dependencies.md +0 -31
  57. data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
  58. data/docs/api/javascript-api.md +0 -99
  59. data/docs/api/redux-store-api.md +0 -102
  60. data/docs/api/view-helpers-api.md +0 -133
  61. data/docs/contributor-info/errors-with-hooks.md +0 -45
  62. data/docs/contributor-info/generator-testing.md +0 -11
  63. data/docs/contributor-info/linters.md +0 -68
  64. data/docs/contributor-info/pull-requests.md +0 -42
  65. data/docs/contributor-info/releasing.md +0 -76
  66. data/docs/deployment/elastic-beanstalk.md +0 -63
  67. data/docs/deployment/heroku-deployment.md +0 -39
  68. data/docs/getting-started.md +0 -196
  69. data/docs/guides/client-vs-server-rendering.md +0 -27
  70. data/docs/guides/configuration.md +0 -289
  71. data/docs/guides/deployment.md +0 -5
  72. data/docs/guides/file-system-based-automated-bundle-generation.md +0 -197
  73. data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
  74. data/docs/guides/how-react-on-rails-works.md +0 -44
  75. data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
  76. data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
  77. data/docs/guides/i18n.md +0 -87
  78. data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
  79. data/docs/guides/minitest-configuration.md +0 -31
  80. data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
  81. data/docs/guides/react-on-rails-overview.md +0 -29
  82. data/docs/guides/react-server-rendering.md +0 -32
  83. data/docs/guides/render-functions-and-railscontext.md +0 -205
  84. data/docs/guides/rspec-configuration.md +0 -73
  85. data/docs/guides/tutorial.md +0 -371
  86. data/docs/guides/upgrading-react-on-rails.md +0 -304
  87. data/docs/guides/webpack-configuration.md +0 -42
  88. data/docs/home.md +0 -23
  89. data/docs/javascript/angular-js-integration-migration.md +0 -28
  90. data/docs/javascript/asset-pipeline.md +0 -12
  91. data/docs/javascript/capistrano-deployment.md +0 -18
  92. data/docs/javascript/code-splitting.md +0 -165
  93. data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
  94. data/docs/javascript/credits.md +0 -10
  95. data/docs/javascript/foreman-issues.md +0 -15
  96. data/docs/javascript/images.md +0 -57
  97. data/docs/javascript/node-dependencies-and-npm.md +0 -19
  98. data/docs/javascript/react-and-redux.md +0 -36
  99. data/docs/javascript/react-helmet.md +0 -100
  100. data/docs/javascript/react-router.md +0 -90
  101. data/docs/javascript/server-rendering-tips.md +0 -55
  102. data/docs/javascript/troubleshooting-when-using-shakapacker.md +0 -77
  103. data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
  104. data/docs/javascript/webpack-v1-notes.md +0 -23
  105. data/docs/javascript/webpack.md +0 -22
  106. data/docs/misc/articles.md +0 -20
  107. data/docs/misc/code_of_conduct.md +0 -13
  108. data/docs/misc/doctrine.md +0 -77
  109. data/docs/misc/style.md +0 -33
  110. data/docs/misc/tips.md +0 -10
  111. data/docs/outdated/deferred-rendering.md +0 -39
  112. data/docs/outdated/rails-assets-relative-paths.md +0 -195
  113. data/docs/outdated/rails-assets.md +0 -77
  114. data/docs/outdated/rails3.md +0 -9
  115. data/docs/rails/convert-rails-5-api-only-app.md +0 -19
  116. data/docs/rails/rails-engine-integration.md +0 -32
  117. data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
  118. data/docs/rails/turbolinks.md +0 -124
  119. data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
  120. data/docs/testimonials/hvmn.md +0 -25
  121. data/docs/testimonials/resortpass.md +0 -13
  122. data/docs/testimonials/testimonials.md +0 -28
  123. data/jest.config.js +0 -4
  124. data/package-scripts.yml +0 -49
  125. data/package.json +0 -96
  126. data/rakelib/docker.rake +0 -26
  127. data/rakelib/dummy_apps.rake +0 -30
  128. data/rakelib/example_type.rb +0 -96
  129. data/rakelib/examples.rake +0 -64
  130. data/rakelib/examples_config.yml +0 -14
  131. data/rakelib/lint.rake +0 -30
  132. data/rakelib/node_package.rake +0 -15
  133. data/rakelib/release.rake +0 -92
  134. data/rakelib/run_rspec.rake +0 -103
  135. data/rakelib/task_helpers.rb +0 -62
  136. data/script/bootstrap +0 -33
  137. data/script/release +0 -3
  138. data/script/setup +0 -23
  139. data/script/test +0 -38
  140. data/webpackConfigLoader.js +0 -71
  141. data/yarn.lock +0 -7010
@@ -1,55 +0,0 @@
1
- # Server Rendering Tips
2
-
3
- For the best performance with Server Rendering, consider using [React on Rails Pro]
4
-
5
-
6
- ## General Tips
7
- - Your code can't reference `document`. Server side JS execution does not have access to `document`,
8
- so jQuery and some other libs won't work in this environment. You can debug this by putting in
9
- `console.log` statements in your code.
10
- - You can conditionally avoid running code that references document by either checking if `window`
11
- is defined or using the "railsContext"
12
- your top level react component. Since the passed in props Hash from the view helper applies to
13
- client and server side code, the best way to do this is to use a Render-Function.
14
- - If you're serious about server rendering, it's worth the effort to have different entry points for client and server rendering. It's worth the extra complexity. The point is that you have separate files for top level client or server side, and you pass some extra option indicating that rendering is happening server side.
15
- - You can enable Node.js server rendering via [React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki).
16
-
17
- ## Troubleshooting Server Rendering
18
-
19
- 1. First be sure your code works with server rendering disabled (`prerender: false`)
20
- 2. Be sure that `config.trace` is true. You will get the server invocation code that renders your component. If you're not using Shakapacker, you will also get the whole file used to setup the JavaScript context.
21
-
22
- ## CSS
23
- Server bundles must always have CSS Extracted
24
-
25
- ## setTimeout, setInterval, and clearTimeout
26
-
27
- These methods are polyfilled for server rendering to be no-ops. We log calls to these when in `trace` mode. In the past, some libraries, namely babel-polyfill, did call setTimout.
28
-
29
- Here's an example of this which shows the line numbers that end up calling setTimeout:
30
- ```
31
- ➜ ~/shakacode/react_on_rails/gen-examples/examples/basic-server-rendering (add-rails-helper-to-generator u=) ✗ export SERVER_TRACE_REACT_ON_RAILS=TRUE
32
- ➜ ~/shakacode/react_on_rails/gen-examples/examples/basic-server-rendering (add-rails-helper-to-generator u=) ✗ rspec
33
- Hello World
34
- Building Webpack client-rendering assets...
35
- Completed building Webpack client-rendering assets.
36
- ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
37
- react_renderer.rb: 92
38
- wrote file tmp/server-generated.js
39
- ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
40
- ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
41
- react_renderer.rb: 92
42
- wrote file tmp/base_js_code.js
43
- ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
44
- [SERVER] setTimeout is not defined for execJS. See https://github.com/sstephenson/execjs#faq. Note babel-polyfill will call this.
45
- [SERVER] at setTimeout (<eval>:31:17)
46
- at defer (<eval>:4422:8)
47
- at setImmediate (<eval>:4387:6)
48
- at notify (<eval>:4481:16)
49
- at module.exports (<eval>:4490:6)
50
- at notify (<eval>:4081:4)
51
- at Promise.$resolve (<eval>:4189:8)
52
- at <eval>:793:18
53
- at Function.resolve (<eval>:4265:6)
54
- the hello world example works
55
- ```
@@ -1,77 +0,0 @@
1
- # Client rendering crashes when configuring `optimization.runtimeChunk` to `multiple`
2
-
3
- ## Context
4
-
5
- 1. Ruby version: 3.1
6
- 2. Rails version: 7.0.6
7
- 3. Shakapacker version: 6.6.0
8
- 4. React on Rails version: 13.3.5
9
-
10
- ## The failure
11
-
12
- Configuring Webpack to embed the runtime in each chunk and calling `react_component` twice in a rails view/partial causes the client render to crash with the following error:
13
-
14
- ```
15
- Could not find component registered with name XXX. Registered component names include [ YYY ]. Maybe you forgot to register the component?
16
- ```
17
-
18
- ```
19
- VM4859 clientStartup.js:132 Uncaught Error: ReactOnRails encountered an error while rendering component: XXX. See above error message.
20
- at Object.get (ComponentRegistry.js:40:15)
21
- at Object.getComponent (ReactOnRails.js:211:44)
22
- at render (VM4859 clientStartup.js:103:53)
23
- at forEachReactOnRailsComponentRender (VM4859 clientStartup.js:138:9)
24
- at reactOnRailsPageLoaded (VM4859 clientStartup.js:164:5)
25
- at renderInit (VM4859 clientStartup.js:205:9)
26
- at onPageReady (VM4859 clientStartup.js:234:9)
27
- at HTMLDocument.onReadyStateChange (VM4859 clientStartup.js:238:13)
28
- ```
29
-
30
- ## Configs
31
-
32
- ### Webpack configuration
33
-
34
- ```js
35
- optimization: {
36
- runtimeChunk: 'multiple'
37
- },
38
- ```
39
-
40
- ### Rails view
41
-
42
- ```haml
43
- = react_component("XXX", props: @props)
44
- = yield
45
- = react_component("YYY", props: @props)
46
- ```
47
-
48
- ## The problem
49
-
50
- Configuring Webpack to embed the runtime in each chunk and calling `react_component` twice in a rails view/partial causes the client render to crash.
51
-
52
- Read more at https://github.com/shakacode/react_on_rails/issues/1558.
53
-
54
- ## Solution
55
-
56
- To overcome this issue, we could use [shakapacker](https://github.com/shakacode/shakapacker)'s default optimization configuration (pseudo-code):
57
-
58
- ```js
59
- const { webpackConfig: baseClientWebpackConfig } = require('shakapacker');
60
-
61
- // ...
62
-
63
- config.optimization = baseClientWebpackConfig.optimization;
64
- ```
65
- As it set the `optimization.runtimeChunk` to `single`. See its source:
66
-
67
- `package/environments/base.js:115`
68
- ```js
69
- optimization: {
70
- splitChunks: { chunks: 'all' },
71
-
72
- runtimeChunk: 'single'
73
- },
74
- ```
75
- https://github.com/shakacode/shakapacker/blob/cdf32835d3e0949952b8b4b53063807f714f9b24/package/environments/base.js#L115-L119
76
-
77
- Or set `optimization.runtimeChunk` to `single` directly.
@@ -1,90 +0,0 @@
1
- ## Context
2
-
3
- Rails: 5.0.2
4
- react_on_rails: upgraded from 6.6.0 to 9.0.3
5
-
6
- ## The failure
7
-
8
- Rspec failing with
9
- ```
10
- Failure/Error: raise Webpacker::Manifest::MissingEntryError, missing_file_from_manifest_error(name)
11
-
12
- Webpacker::Manifest::MissingEntryError:
13
- Webpacker can't find webpack-bundle.js in /home/user/ws/pp/code/pp-core-checkout_spa_update_npm/public/webpack-test/manifest.json. Possible causes:
14
- 1. You want to set webpacker.yml value of compile to true for your environment
15
- unless you are using the `webpack -w` or the webpack-dev-server.
16
- 2. Webpack has not yet re-run to reflect updates.
17
- 3. You have misconfigured Webpacker's config/webpacker.yml file.
18
- 4. Your Webpack configuration is not creating a manifest.
19
- Your manifest contains:
20
- {
21
- "main.css": "/webpack-test/main-bundle.css",
22
- "main.js": "/webpack-test/main-dde0e05a2817931424c3.js"
23
- }
24
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/webpacker-3.0.1/lib/webpacker/manifest.rb:44:in `handle_missing_entry'
25
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/webpacker-3.0.1/lib/webpacker/manifest.rb:40:in `find'
26
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/webpacker-3.0.1/lib/webpacker/manifest.rb:27:in `lookup'
27
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/utils.rb:145:in `bundle_js_file_path_from_webpacker'
28
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/utils.rb:90:in `bundle_js_file_path'
29
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb:56:in `block in all_compiled_assets'
30
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb:55:in `map'
31
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb:55:in `all_compiled_assets'
32
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb:35:in `stale_generated_webpack_files'
33
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper/ensure_assets_compiled.rb:34:in `call'
34
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper.rb:85:in `ensure_assets_compiled'
35
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/react_on_rails-9.0.3/lib/react_on_rails/test_helper.rb:39:in `block (2 levels) in configure_rspec_to_compile_assets'
36
- # /home/user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:443:in `instance_exec'
37
- ...
38
- ```
39
-
40
- At the same time dev/prod environments works fine (with extra webpack calling step outside rails).
41
-
42
- ## Configs
43
-
44
- ### webpack.config.js
45
-
46
- ```js
47
- ...
48
- const ManifestPlugin = require('webpack-manifest-plugin');
49
- ...
50
- const { output } = webpackConfigLoader(configPath);
51
- ...
52
- output: {
53
- filename: '[name]-[hash].js',
54
-
55
- // Leading and trailing slashes ARE necessary.
56
- publicPath: output.publicPath,
57
- path: output.path,
58
- },
59
- ...
60
- plugins: [
61
- ...
62
- new ManifestPlugin({
63
- publicPath: output.publicPath,
64
- writeToFileEmit: true
65
- }),
66
- ...
67
- ]
68
- ...
69
- ```
70
-
71
- ### config/webpacker.yml
72
-
73
- is default from sample appliction v9.x
74
-
75
- ### config/initializers/react_on_rails.rb
76
-
77
- ```ruby
78
- ...
79
- # Define the files we need to check for webpack compilation when running tests.
80
- config.webpack_generated_files = %w( webpack-bundle.js main-bundle.css )
81
- ...
82
- ```
83
-
84
- ## The problem
85
-
86
- When `ReactOnRails.configuration.webpack_generated_files` is specified, it prevents usage of `manifest.json`
87
-
88
- ## Solution
89
-
90
- Removing of `config.webpack_generated_files` from `config/initializers/react_on_rails.rb` resolving issue.
@@ -1,23 +0,0 @@
1
- # Webpack V1 Tips
2
-
3
- The following only apply to Webpack V1. Take 1 hour and update to v2! It's worth it!
4
-
5
- ## Use the `--bail` Option When Running Webpack for CI or Deployments if using Webpack V1
6
- For your scripts that statically build your Webpack bundles, use the `--bail` option. This will ensure that CI and your product deployment **halt** if Webpack cannot complete! For more details, see the documentation for [Webpack's `--bail` option](https://webpack.js.org/configuration/other-options/#bail). Note, you might not want to use the `--bail` option if you just want to depend on Webpack returning a non-zero error code and you want to see all the errors, rather than only the first error.
7
-
8
-
9
- ## Entry Points
10
- You should ensure you configure the entry points correctly for webpack if you want to break out libraries into a "vendor" bundle where your libraries are packaged separately from your app's code. If you send web clients your vendor bundle separately from your app bundles, then web clients might have the vendor bundle cached while they receive updates for your app.
11
-
12
- You need both include `react-dom` and `react` as values for `entry`, like this:
13
-
14
- ```
15
- entry: {
16
-
17
- // See use of 'vendor' in the CommonsChunkPlugin inclusion below.
18
- vendor: [
19
- 'babel-core/polyfill',
20
- 'react',
21
- 'react-dom',
22
- ],
23
- ```
@@ -1,22 +0,0 @@
1
- # Webpack Tips
2
-
3
- ## Where do I learn about advanced Webpack setups, such as with "CSS Modules", "Code Splitting", etc
4
- You can try out example app, [shakacode/react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial). We're building comprehensive production examples in our new, premium product, [**React on Rails Pro**](https://forum.shakacode.com/t/introducing-react-on-rails-pro-subscriptions/785). If you're interested, please see the details in [this forum post](https://forum.shakacode.com/t/introducing-react-on-rails-pro-subscriptions/785).
5
-
6
- ## Webpack v1 or v2?
7
- We recommend using Webpack version 2.3.1 or greater.
8
-
9
- ## yarn or npm?
10
- Yarn is the current recommendation!
11
-
12
- ## Entry Points
13
-
14
- You should ensure you configure the entry points correctly for webpack if you want to break out libraries into a "vendor" bundle where your libraries are packaged separately from your app's code. If you send web clients your vendor bundle separately from your app bundles, then web clients might have the vendor bundle cached while they receive updates for your app.
15
-
16
- Webpack v2 makes this very convenient! See:
17
-
18
- * [Implicit Common Vendor Chunk](https://webpack.js.org/guides/code-splitting-libraries/#implicit-common-vendor-chunk)
19
- * [Manifest File](https://webpack.js.org/guides/code-splitting-libraries/#manifest-file)
20
-
21
- ## Webpack v4
22
- Webpack v4 is heartily recommended. If you need help with migrating your project to Webpack v4, please contact me, [justin@shakacode.com](mailto:justin@shakacode.com).
@@ -1,20 +0,0 @@
1
- # Articles, Videos, and Podcasts
2
-
3
- ## Articles
4
-
5
- * [Introducing React on Rails v9 with Webpacker Support](https://blog.shakacode.com/introducing-react-on-rails-v9-with-webpacker-support-f2584c6c8fa4) for an overview of the integration of React on Rails with Webpacker.
6
- * [Webpacker Lite: Why Fork Webpacker?](https://blog.shakacode.com/webpacker-lite-why-fork-webpacker-f0a7707fac92)
7
- * [React on Rails, 2000+ 🌟 Stars](https://medium.com/shakacode/react-on-rails-2000-stars-32ff5cfacfbf#.6gmfb2gpy)
8
- * [The React on Rails Doctrine](https://medium.com/@railsonmaui/the-react-on-rails-doctrine-3c59a778c724)
9
- * [Simple Tutorial](https://www.shakacode.com/react-on-rails/docs/guides/tutorial/).
10
-
11
- ## Videos
12
-
13
- * [Video of running the v9 installer with Webpacker v3](https://youtu.be/M0WUM_XPaII). History, motivations, philosophy, and overview.
14
- 1. [GORUCO 2017: Front-End Sadness to Happiness: The React on Rails Story by Justin Gordon](https://www.youtube.com/watch?v=SGkTvKRPYrk)
15
- 2. [egghead.io: Creating a component with React on Rails](https://egghead.io/lessons/react-creating-a-component-with-react-on-rails)
16
- 3. [egghead.io: Creating a redux component with React on Rails](https://egghead.io/lessons/react-add-redux-state-management-to-a-react-on-rails-project)
17
- 4. [React On Rails Tutorial Series](https://www.youtube.com/playlist?list=PL5VAKH-U1M6dj84BApfUtvBjvF-0-JfEU)
18
- 1. [History and Motivation](https://youtu.be/F4oymbUHvoY)
19
- 2. [Basic Tutorial Walkthrough](https://youtu.be/_bjScw60FBk)
20
- 3. [Code Walkthrough](https://youtu.be/McQ9UM-_ocQ)
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
@@ -1,77 +0,0 @@
1
- # The React on Rails Doctrine
2
-
3
- By Justin Gordon, January 26, 2016
4
-
5
- This document is an extension and complement to [The Rails Doctrine](http://rubyonrails.org/doctrine/). If you haven't read that document, I suggest you do so first.
6
-
7
- As stated in the [React on Rails README](https://www.shakacode.com/react-on-rails/docs/), the project objective is to provide an opinionated and optimal framework for integrating **Ruby on Rails** with modern JavaScript tooling and libraries. When considering what goes into **react_on_rails**, we ask ourselves, is the functionality related to the intersection of using Rails and with modern JavaScript? A good example is view helper integration of React components on a Rails view. If the answer is yes, then the functionality belongs right here. In other cases, we're releasing separate npm packages or Ruby gems. For example, we needed an easy way to integrate [Twitter Bootstrap](http://getbootstrap.com/) with Webpack, and we released the [npm bootstrap-loader](https://github.com/shakacode/bootstrap-loader/).
8
-
9
- Besides the project objective, let's stick with the "Rails Doctrine" and keep the following in mind.
10
-
11
- ## Optimize for Programmer Happiness
12
- The React on Rails setup provides several key components related to front-end developer happiness:
13
-
14
- 1. [Hot reloading of both JavaScript and CSS](https://gaearon.github.io/react-hot-loader/), via the [webpack dev server](https://webpack.github.io/docs/webpack-dev-server.html). This works for both using an [express server](http://expressjs.com/) to load stubs for the ajax requests, as well as using a live Rails server. **Oh yes**, your Rails server can do hot reloading!
15
- 2. [CSS modules](https://github.com/css-modules/webpack-demo) which remove the madness of a global namespace for CSS. We organize our CSS (Sass, actually) right next to our JavaScript React component files. This means no more creating long class names to ensure that CSS picks up the right styles.
16
- 3. [ES6 JavaScript](http://es6-features.org/#Constants) is a great language for client side coding, much more so than Ruby due to the asynchronous nature of UI programming.
17
- 4. JavaScript libraries and tooling work better in the native node way, rather than via some aspect of Sprockets and the Rails Asset Pipeline. We find way less frustration this way, especially from being able to get the latest advances with the rest of the JavaScript community. Why complicated beautiful JavaScript tooling Rails asset pipeline complexity?
18
- 5. We want our JavaScript from npm. Getting JavaScript from rubygems.org is comparatively frustrating.
19
- 6. Happiness for us is actively participating in open source, so we want to be where the action is, which is with the npm libraries on github.com.
20
- 7. You can get set up on React on Rails **FAST** using our application generator.
21
- 8. By placing all client-side development inside of the `/client` directory, pure JavaScript developers can productively do development separate from Rails. Instead of Rails APIs, stub APIs on an express server can provide a simple backend, allowing for rapid iteration of UI prototypes.
22
- 9. Just because we're not relying on the Rails asset pipeline for ES6 conversion does not mean that we're deploying Rails apps in any different way. We still use the asset pipeline to include our Webpack compiled JavaScript. This only requires a few small modifications, as explained in [our heroku deployment documentation](https://www.shakacode.com/react-on-rails/docs/deployment/heroku-deployment/).
23
-
24
- ## Convention over Configuration
25
- * React on Rails has taken the hard work out of figuring out the JavaScript tooling that works best with Rails. Not only could you spend lots of time researching different tooling, but then you'd have to figure out how to splice it all together. This is where a lot of "JavaScript fatigue" comes from. The following keep the code clean and consistent:
26
- * [Style Guide](https://www.shakacode.com/react-on-rails/docs/misc/style/)
27
- * [linters](https://www.shakacode.com/react-on-rails/docs/contributor-info/linters/)
28
-
29
- We're big believers in this quote from the Rails Doctrine:
30
-
31
- > The same goes even when you understand how all the pieces go together. When there’s an obvious next step for every change, we can scoot through the many parts of an application that is the same or very similar to all the other applications that went before it. A place for everything and everything in its place. Constraints liberate even the most able minds.
32
-
33
-
34
- ## The Menu Is Omakase
35
- Here's the chef's selection from the React on Rails community:
36
-
37
- ### Libraries
38
- * [Bootstrap](http://getbootstrap.com/), loaded from [bootstrap-loader](https://github.com/shakacode/bootstrap-loader/). Common UI styles.
39
- * [Lodash](https://lodash.com/): Swiss army knife of utilities.
40
- * [React](https://facebook.github.io/react/): UI components.
41
- * [React-Router](https://github.com/reactjs/react-router): Provider of deep links for client-side application.
42
- * [Redux](https://github.com/reactjs/redux): Flux implementation (aka "state container").
43
-
44
- ### JavaScript Tooling
45
- * [Babel](https://babeljs.io/): Transpiler for ES6 into ES5 and much more.
46
- * [EsLint](http://eslint.org/)
47
- * [Webpack](http://webpack.github.io/): Generator of deployment assets and provider of hot module reloading.
48
-
49
- By having a common set of tools, we can discuss what we should or shouldn't be using. Thus, this takes out the "JavaScript Fatigue" from having too many unclear choices in the JavaScript world.
50
-
51
- By the way, we're *not* omakase for standard Rails. That would be CoffeeScript. However, the Rails Doctrine makes it clear that non-standard menu choices are certainly welcome!
52
-
53
- ## No One Paradigm
54
- React on Rails fits into the "No One Paradigm" of the Rails ecosystem from the perspective that it rocks for client side development with Rails, even though it's a totally different language than the server code written in Ruby.
55
-
56
- ## Exalt Beautiful Code
57
- ES5 was ugly. ES6 is beautiful. React is beautiful. Client side code written with React plus Redux, fully linted with the ShakaCode linters, and organized per our recommended project structure is beautiful. Don't take our word for it. Take a look at the component sample code in the [react-webpack-rails-tutorial sample code](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/client/app/bundles/comments).
58
-
59
- ## Value Integrated Systems
60
- Assuming that you're building the type of app that's a good fit for Rails (document/database based with lots of business rules), the tight integration of modern JavaScript with React on top of Ruby on Rails is better than building a pure client side app and separate microservices. Here's why:
61
-
62
- * Via React on Rails, we can seamlessly integrate React UI components with Rails.
63
- * Tight integration allows for trivial set up of server rendering of React on top of Rails, complete with support for fragment caching of the server rendered HTML, and integration with [Turbolinks](https://github.com/turbolinks/turbolinks).
64
- * Tight integration allows mixing and matching Rails pages with React driven pages, even on the same page. Not every part of a UI requires the high fidelity achievable using React. Many existing apps may have hundreds of standards Rails forms. Support for mixing and matching React with Rails forms provides the best of both worlds.
65
-
66
- ## Progress over Stability
67
- React on Rails will maintain an active pace of development, to keep up with:
68
-
69
- * Community suggestions.
70
- * New client side tooling, libraries, and techniques.
71
- * Updates to Rails.
72
-
73
- ## Raise a Big Tent
74
- React on Rails is definitely a part of the big tent of Rails. Plus, React on Rails provides its own big tent. A huge benefit of the React on Rails system is simple integration with Webpack and NPM, allowing integration with almost any library available on [npm](https://www.npmjs.org/)! The integration with Webpack also allows for other Webpack supported build tools.
75
-
76
- ## Thanks!
77
- Thanks for reading and being a part of the React on Rails community. Feedback on this document and *anything* in React on Rails is welcome. Please [open an issue](https://github.com/shakacode/react_on_rails/issues/new) or a pull request. If you'd like to join our private Slack channel, please [email](mailto:contact@shakacode.com) us a request.
data/docs/misc/style.md DELETED
@@ -1,33 +0,0 @@
1
- # Code Style
2
- This document describes the coding style of [ShakaCode](http://www.shakacode.com). Yes, it's opinionated, as all style guidelines should be. We shall put as little as possible into this guide and instead rely on:
3
-
4
- * Use of linters with our standard linter configuration.
5
- * References to existing style guidelines that support the linter configuration.
6
- * Anything additional goes next.
7
-
8
- ## Client Side JavaScript and React
9
- * See the [Shakacode JavaScript Style Guide](https://github.com/shakacode/style-guide-javascript)
10
-
11
- ## Style Guides to Follow
12
- Follow these style guidelines per the linter configuration. Basically, lint your code and if you have questions about the suggested fixes, look here:
13
-
14
- ### Ruby Coding Standards
15
- * [ShakaCode Ruby Coding Standards](https://github.com/shakacode/style-guide-ruby)
16
- * [Ruby Documentation](http://guides.rubyonrails.org/api_documentation_guidelines.html)
17
-
18
- ### JavaScript Coding Standards
19
- * [ShakaCode Javascript](https://github.com/shakacode/style-guide-javascript)
20
- * Use the [eslint-config-shakacode](https://github.com/shakacode/style-guide-javascript/tree/master/packages/eslint-config-shakacode) npm package with eslint.
21
- * [JSDoc](http://usejsdoc.org/)
22
-
23
- ### Git coding Standards
24
- * [Git Coding Standards](http://chlg.co/1GV2m9p)
25
-
26
- ### Sass Coding Standards
27
- * [Sass Guidelines](http://sass-guidelin.es/) by [Hugo Giraudel](http://hugogiraudel.com/)
28
- * [Github Front End Guidelines](http://primercss.io/guidelines/)
29
-
30
- # Git Usage
31
- * Follow a github-flow model where you branch off of master for features.
32
- * Before merging a branch to master, rebase it on top of master, by using command like `git fetch; git checkout my-branch; git rebase -i origin/master`. Clean up your commit message at this point. Be super careful to communicate with anybody else working on this branch and do not do this when others have uncommitted changes. Ideally, your merge of your feature back to master should be one nice commit.
33
- * Run hosted CI and code coverage.
data/docs/misc/tips.md DELETED
@@ -1,10 +0,0 @@
1
- # Tips
2
- + **DO NOT RUN `rails s`** and instead run
3
-
4
- `foreman start -f Procfile.dev`
5
-
6
- to automatically start the webpack file watchers that will regenerate your JavaScript. Note, RSpec does not automatically rebuild the bundle files, so you could get incorrect results from your tests if you change the client code and do not rebuild the bundles. The same problem occurs when pulling down changes from GitHub and running tests without first rebuilding the bundles.
7
- + The default for rendering right now is `prerender: false`. **NOTE:** Server side rendering does not work for some components that use an async setup for server rendering. You can configure the default for prerender in your config.
8
- + You can expose either a React component or a function that returns a React component. If you wish to create a React component via a function, rather than simply props, then you need to set the property "generator" on that helper invocation to true (or change the defaults). When that is done, the function is invoked with a single parameter of "props", and that function should return a React element.
9
- + Be sure you can first render your react component **client only** before you try to debug server rendering!
10
- + Open up the HTML source and take a look at the generated HTML and the JavaScript to see what's going on under the covers. Note that when server rendering is turned on, then you'll see the server rendered react components. When server rendering is turned off, then you'll only see the `div` element where the in-line JavaScript will render the component. You might also notice how the props you pass (a Ruby Hash) becomes in-line JavaScript on the HTML page.
@@ -1,39 +0,0 @@
1
- # Deferred Rendering
2
-
3
- Please see [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/] if you are interested in code splitting using
4
- [loadable-components.com](https://loadable-components.com/docs) with React on Rails.
5
-
6
- -----
7
-
8
- What is code splitting? From the webpack documentation:
9
-
10
- > For big web apps it’s not efficient to put all code into a single file, especially if some blocks of code are only required under some circumstances. Webpack has a feature to split your codebase into “chunks” which are loaded on demand. Some other bundlers call them “layers”, “rollups”, or “fragments”. This feature is called “code splitting”.
11
-
12
- ## Server Rendering and Code Splitting
13
-
14
- Let's say you're requesting a page that needs to fetch a code chunk from the server before it's able to render. If you do all your rendering on the client side, you don't have to do anything special. However, if the page is rendered on the server, you'll find that React will spit out the following error:
15
-
16
- > Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
17
-
18
- > (client) <!-- react-empty: 1 -
19
-
20
- > (server) <div data-reactroot="
21
- <!--This comment is here because the comment beginning on line 13 messes up Sublime's markdown parsing-->
22
-
23
- Different markup is generated on the client than on the server. Why does this happen? When you register a component or Render-Function with `ReactOnRails.register`, React on Rails will by default render the component as soon as the page loads. However, code splitting requires that components render at a later time when the JavaScript chunks have loaded.
24
-
25
- ## Solution
26
-
27
- To prevent this, you have to wait until the code chunk is fetched before doing the initial render on the client side. To accomplish this, react on rails allows you to register a renderer. This works just like registering a Render-Function, except that the function you pass takes three arguments: `renderer(props, railsContext, domNodeId)`, and is responsible for calling `ReactDOM.render` or `ReactDOM.hydrate` to render the component to the DOM. React on rails will automatically detect when a Render-Function takes three arguments, and will **not** call `ReactDOM.render` or `ReactDOM.hydrate`, instead allowing you to control the initial render yourself. Note, you have to be careful to call `ReactDOM.hydrate` rather than `ReactDOM.render` if you are are server rendering.
28
-
29
-
30
- ## Server vs. Client Code Caveats
31
-
32
- If you're going to try to do code splitting with server rendered routes, you'll probably need to use seperate route definitions for client and server to prevent code splitting from happening for the server bundle. The server bundle should be one file containing all the JavaScript code. This will require you to have seperate webpack configurations for client and server.
33
-
34
- Do not attempt to register a renderer function on the server. Instead, register either a Render-Function or a component. If you register a renderer in the server bundle, you'll get an error when react on rails tries to server render the component.
35
-
36
-
37
- ## React on Rails Pro
38
- [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/] includes a complete setup using this technique for code splitting using
39
- [loadable-components.com](https://loadable-components.com/docs) with React on Rails.