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
data/.scss-lint.yml DELETED
@@ -1,205 +0,0 @@
1
- # See http://sass-guidelin.es/#zeros
2
-
3
- scss_files:
4
- - 'spec/dummy/app/assets/stylesheets/**/*.scss'
5
- exclude:
6
- - 'spec/dummy/app/assets/stylesheets/application.css'
7
- linters:
8
- # BangFormat:
9
- # enabled: true
10
- # space_before_bang: true
11
- # space_after_bang: false
12
- #
13
- # BorderZero:
14
- # enabled: true
15
- # convention: zero # or `none`
16
- #
17
- ColorKeyword:
18
- enabled: false
19
- ColorVariable:
20
- enabled: false
21
- #
22
- # Comment:
23
- # enabled: true
24
- #
25
- # DebugStatement:
26
- # enabled: true
27
- #
28
- # DeclarationOrder:
29
- # enabled: true
30
- #
31
- # DuplicateProperty:
32
- # enabled: true
33
- #
34
- # ElsePlacement:
35
- # enabled: true
36
- # style: same_line # or 'new_line'
37
- #
38
- # EmptyLineBetweenBlocks:
39
- # enabled: true
40
- # ignore_single_line_blocks: true
41
- #
42
- # EmptyRule:
43
- # enabled: true
44
- #
45
- # FinalNewline:
46
- # enabled: true
47
- # present: true
48
- #
49
- HexLength:
50
- enabled: true
51
- style: long
52
-
53
- HexNotation:
54
- enabled: true
55
- style: uppercase
56
- #
57
- # HexValidation:
58
- # enabled: true
59
- #
60
- IdSelector:
61
- enabled: true
62
- #
63
- # ImportantRule:
64
- # enabled: true
65
- #
66
- # ImportPath:
67
- # enabled: true
68
- # leading_underscore: false
69
- # filename_extension: false
70
- #
71
- # Indentation:
72
- # enabled: true
73
- # allow_non_nested_indentation: false
74
- # character: space # or 'tab'
75
- # width: 2
76
- #
77
- LeadingZero:
78
- enabled: true
79
- style: include_zero
80
- #
81
- # MergeableSelector:
82
- # enabled: true
83
- # force_nesting: true
84
- #
85
- # NameFormat:
86
- # enabled: true
87
- # allow_leading_underscore: true
88
- # convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern
89
- #
90
- # NestingDepth:
91
- # enabled: true
92
- # max_depth: 3
93
- #
94
- # PlaceholderInExtend:
95
- # enabled: true
96
- #
97
- # PropertyCount:
98
- # enabled: false
99
- # include_nested: false
100
- # max_properties: 10
101
- #
102
- # PropertyUnits:
103
- # enabled: true
104
- # global: [
105
- # 'ch', 'em', 'ex', 'rem', # Font-relative lengths
106
- # 'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths
107
- # 'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths
108
- # 'deg', 'grad', 'rad', 'turn', # Angle
109
- # 'ms', 's', # Duration
110
- # 'Hz', 'kHz', # Frequency
111
- # 'dpi', 'dpcm', 'dppx', # Resolution
112
- # '%', # Other
113
- # ]
114
- # properties: {}
115
- #
116
- # PropertySortOrder:
117
- # enabled: true
118
- # ignore_unspecified: false
119
- # separate_groups: false
120
- #
121
- # PropertySpelling:
122
- # enabled: true
123
- # extra_properties: []
124
- #
125
- # QualifyingElement:
126
- # enabled: true
127
- # allow_element_with_attribute: false
128
- # allow_element_with_class: false
129
- # allow_element_with_id: false
130
- #
131
- # SelectorDepth:
132
- # enabled: true
133
- # max_depth: 3
134
- #
135
- # SelectorFormat:
136
- # enabled: true
137
- # convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
138
- #
139
- # Shorthand:
140
- # enabled: true
141
- # allowed_shorthands: [1, 2, 3]
142
- #
143
- # SingleLinePerProperty:
144
- # enabled: true
145
- # allow_single_line_rule_sets: true
146
- #
147
- # SingleLinePerSelector:
148
- # enabled: true
149
- #
150
- # SpaceAfterComma:
151
- # enabled: true
152
- #
153
- # SpaceAfterPropertyColon:
154
- # enabled: true
155
- # style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
156
- #
157
- # SpaceAfterPropertyName:
158
- # enabled: true
159
- #
160
- # SpaceBeforeBrace:
161
- # enabled: true
162
- # style: space # or 'new_line'
163
- # allow_single_line_padding: false
164
- #
165
- # SpaceBetweenParens:
166
- # enabled: true
167
- # spaces: 0
168
- #
169
- # StringQuotes:
170
- # enabled: true
171
- # style: single_quotes # or double_quotes
172
- #
173
- # TrailingSemicolon:
174
- # enabled: true
175
- #
176
- # TrailingZero:
177
- # enabled: false
178
- #
179
- # UnnecessaryMantissa:
180
- # enabled: true
181
- #
182
- # UnnecessaryParentReference:
183
- # enabled: true
184
- #
185
- # UrlFormat:
186
- # enabled: true
187
- #
188
- # UrlQuotes:
189
- # enabled: true
190
- #
191
- # VariableForProperty:
192
- # enabled: false
193
- # properties: []
194
- #
195
- # VendorPrefix:
196
- # enabled: true
197
- # identifier_list: base
198
- # additional_identifiers: []
199
- # excluded_identifiers: []
200
- #
201
- # ZeroUnit:
202
- # enabled: true
203
- #
204
- # Compass::*:
205
- # enabled: false
data/.travis.yml DELETED
@@ -1,61 +0,0 @@
1
- sudo: required
2
-
3
- language: ruby
4
-
5
- rvm:
6
- - 2.5.3
7
- - 2.6.5
8
- - 2.7.0
9
-
10
- services:
11
- - docker
12
-
13
- cache:
14
- bundler: true
15
- directories:
16
- - node_modules # NPM packages
17
- yarn: true
18
-
19
- gemfile:
20
- - spec/dummy/Gemfile
21
-
22
- env:
23
- global:
24
- - RAILS_ENV=test
25
- - DRIVER=selenium_chrome
26
- - CHROME_BIN=/usr/bin/google-chrome
27
- - USE_COVERALLS=TRUE
28
-
29
- before_install:
30
- - sudo apt-get update
31
- - sudo apt-get install -y xvfb libappindicator1 fonts-liberation
32
- - wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
33
- - sudo dpkg -i google-chrome*.deb
34
- - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen scn 1600x1200x16"
35
-
36
- install:
37
- - travis_retry gem install bundler -v '>2'
38
- - travis_retry nvm install 14
39
- - node -v
40
- - travis_retry npm i -g yarn
41
- - travis_retry yarn global add yalc
42
- - travis_retry yalc add react-on-rails
43
- - travis_retry yarn
44
- - travis_retry bundle install
45
- - travis_retry yarn run build
46
- - travis_retry yalc publish
47
- - cd spec/dummy
48
- - travis_retry yalc add react-on-rails
49
- - travis_retry yarn
50
- - cd ../..
51
- - bundle exec rake prepare_for_ci
52
-
53
- before_script:
54
- - "export DISPLAY=:99"
55
-
56
- script:
57
- - bundle exec rake
58
-
59
- notifications:
60
- slack:
61
- secure: LfcUk4AJ4vAxWwRIyw4tFh8QNbYefMwfG/oLfsN3CdRMWMOtCOHR1GGsRhAOlfVVJ/FvHqVqWj5gK7z7CaO5Uvl7rD3/zJ8QzExKx/iH9yWj55iIPuKLzwFNnBwRpFW/cqyU2lFPPRxGD50BUn3c+qybkuSqtKZ6qtTowwqlxLa5iyM3N95aZp7MEIKCP7cPcnHfLbJyP8wBpotp/rtw62eXM2HIRJJwgjcp+n+My7VFR9DnBXNFf6R91aZHM4U4cHHDbu15HFtH8honVrzK1JQdyqMNHga+j04dFuaS7z9Q369/hsELMOBp/227+Pz7ZRfWZFK4UASguOvyeX7RmGTRpTuWLm1XJeUzfsPZVROecaSVQBve+U7F12yKqilt97QlvRXn2EGyBILqvxtFNNR4S9kgAf72/6EFgiM1TKq7i9zy6lVOnagU2+7amq7UeopX1uoFsUfNKMR7YbgV1WjF0IK95UP0b0/7ZOJlPYgi5zzkQi129qAFWSMmxGk+ZpsttHh/tjJtvAh0A3mHq/zb5w4ub/MbSyZqeDUNgGj72QArOWUFSAStQT1ybsVLeDoKPgOvVq7OV1D64rpcHjBXcqOCit8tDZ+TqkFhcYJo2cITSaqE4zJXn+4F5s7So5O8CyfKYQq+kFJCooYGmfgTUckJpGl7eIvKmL4TN9Q=
data/book.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "gitbook": "3.1.1",
3
- "title": "React on Rails Documentation",
4
- "plugins": ["prism", "-highlight", "github"],
5
- "pluginsConfig": {
6
- "github": {
7
- "url": "https://github.com/shakacode/react_on_rails/"
8
- },
9
- "sharing": {
10
- "facebook": true,
11
- "twitter": true,
12
- "google": true,
13
- "weibo": true,
14
- "instapaper": true,
15
- "vk": true
16
- }
17
- }
18
- }
@@ -1,56 +0,0 @@
1
- # Generator Details
2
-
3
- The `react_on_rails:install` generator combined with the example pull requests of generator runs will get you up and running efficiently. There's a fair bit of setup with integrating Webpack with Rails. Defaults for options are such that the default is for the flag to be off. For example, the default for `-R` is that `redux` is off, and the default of `-b` is that `skip-bootstrap` is off.
4
-
5
- Run `rails generate react_on_rails:install --help` for descriptions of all available options:
6
-
7
- ```
8
- Usage:
9
- rails generate react_on_rails:install [options]
10
-
11
- Options:
12
- -R, [--redux], [--no-redux] # Install Redux gems and Redux version of Hello World Example. Default: false
13
- [--ignore-warnings], [--no-ignore-warnings] # Skip warnings. Default: false
14
-
15
- Runtime options:
16
- -f, [--force] # Overwrite files that already exist
17
- -p, [--pretend], [--no-pretend] # Run but do not make any changes
18
- -q, [--quiet], [--no-quiet] # Suppress status output
19
- -s, [--skip], [--no-skip] # Skip files that already exist
20
-
21
- Description:
22
-
23
- The react_on_rails:install generator integrates webpack with rails with ease. You
24
- can pass the redux option if you'd like to have redux setup for you automatically.
25
-
26
- * Redux
27
-
28
- Passing the --redux generator option causes the generated Hello World example
29
- to integrate the Redux state container framework. The necessary node modules
30
- will be automatically included for you.
31
-
32
- *******************************************************************************
33
-
34
-
35
- Then you may run
36
-
37
- `rails s`
38
- ```
39
-
40
- Another good option is to create a simple test app per the [Tutorial](https://www.shakacode.com/react-on-rails/docs/guides/tutorial/).
41
-
42
- # Understanding the Organization of the Generated Client Code
43
- The generated client code follows our organization scheme. Each unique set of functionality, is given its own folder inside of `app/javascript/app/bundles`. Note, the recommended for bigger projects is `client/app/bundles`. This encourages for modularity of *domains*.
44
-
45
- Inside of the generated "HelloWorld" domain you will find the following folders:
46
-
47
- + `startup`: This contains the entry point files for webpack. It defaults to a single file that is used for server and client compilation, but if these need to be different, then you can create two webpack configurations with separate endpoints.
48
- + `containers`: "smart components" (components that have functionality and logic that is passed to child "dumb components").
49
- + `components`: includes "dumb components", or components that simply render their properties and call functions given to them as properties by a parent component. Ultimately, at least one of these dumb components will have a parent container component.
50
-
51
- You may also notice the `app/lib` folder. This is for any code that is common between bundles and therefore needs to be shared (for example, middleware).
52
-
53
- ## Redux
54
- If you have used the `--redux` generator option, you will notice the familiar additional redux folders in addition to the aforementioned folders. The Hello World example has also been modified to use Redux.
55
-
56
- Note the organizational paradigm of "bundles". These are like application domains and are used for grouping your code into webpack bundles, in case you decide to create different bundles for deployment. This is also useful for separating out logical parts of your application. The concept is that each bundle will have it's own Redux store. If you have code that you want to reuse across bundles, including components and reducers, place them under `/client/app/lib`.
@@ -1,30 +0,0 @@
1
- # Manual Installation Overview
2
-
3
- TODO: Review this file
4
-
5
-
6
- This file summarizes what the React on Rails generator does.
7
-
8
- ## Configure the `/client` Directory
9
-
10
- This directory has no references to Rails outside of the destination directory for the files created by the various Webpack config files.
11
-
12
- The only requirements within this directory for basic React on Rails integration are:
13
-
14
- 1. Your webpack configuration files:
15
- 1. Create outputs in a directory like `/public/webpack`, which is customizable in your `config/initializers/react_on_rails.rb`.
16
- 1. Provide server rendering if you wish to use that feature.
17
- 1. Your JavaScript code "registers" any components and stores per the ReactOnRails APIs of ReactOnRails.register(components) and ReactOnRails.registerStore(stores). See [our javascript API docs](https://www.shakacode.com/react-on-rails/docs/api/javascript-api/) and the [ReactOnRails.js source](https://github.com/shakacode/react_on_rails/tree/master/node_package/src/ReactOnRails.js).
18
- 1. Set your registration file as an "entry" point in your Webpack configs.
19
- 1. Add the [Manifest plugin](https://github.com/danethurber/webpack-manifest-plugin) to your config.
20
- The default path: `public/webpack` can be loaded with webpackConfigLoader as shown in the dummy example.
21
- 1. You create scripts in `client/package.json` per the example apps. These are used for building your Webpack assets. Also do this for your top level `package.json`.
22
-
23
- ## Rails Steps (outside of /client)
24
- 1. Add `gem "webpacker"` to the Gemfile, run bundle. The gem provides the `stylesheet_pack_tag` and `javascript_pack_tag` helpers which is used to load the bundled assets to your layouts.[Dummy Example](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/views/layouts/application.html.erb)
25
- 1. Configure the `config/initializers/react_on_rails.rb`. You can adjust some necessary settings and defaults. See file [https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/config/initializers/react_on_rails.rb) for a detailed example of configuration, including comments on the different values to configure.
26
- 1. Configure your Procfiles per the example apps. These are at the root of your Rails installation.
27
- 1. Configure your top level JavaScript files for inclusion in your layout. You'll want a version that you use for static assets, and you want a file for any files in your setup that are not part of your webpack build. The reason for this is for use with hot-reloading. If you are not using hot reloading, then you only need to configure your `application.js` file to include your Webpack generated files.
28
- 1. If you are deploying to Heroku, see [our heroku deployment documentation](https://www.shakacode.com/react-on-rails/docs/deployment/heroku-deployment/)
29
-
30
- If I missed anything, please submit a PR or file an issue.
@@ -1,17 +0,0 @@
1
- ## Migrate From react-rails
2
- If you are using [react-rails](https://github.com/reactjs/react-rails) in your project, it is pretty simple to migrate to [react_on_rails](https://github.com/shakacode/react_on_rails).
3
-
4
- - Remove the 'react-rails' gem from your Gemfile.
5
-
6
- - Remove the generated lines for react-rails in your application.js file.
7
-
8
- ```
9
- //= require react
10
- //= require react_ujs
11
- //= require components
12
- ```
13
-
14
- - Follow our [getting started guide](https://www.shakacode.com/react-on-rails/docs/getting-started/).
15
-
16
- Note: If you have components from react-rails you want to use, then you will need to port them into react_on_rails which uses webpack instead of the asset pipeline.
17
-
@@ -1,69 +0,0 @@
1
- # Recommended Project structure
2
-
3
- The React on Rails generator uses the standard Shakapacker 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
- Per the example repo [shakacode/react_on_rails_demo_ssr_hmr](https://github.com/shakacode/react_on_rails_demo_ssr_hmr),
16
- you should consider keeping your codebase mostly consistent with the defaults for [Shakapacker](https://github.com/shakacode/shakapacker).
17
-
18
- ## Steps to convert from the generator defaults to use a `/client` directory for source code
19
-
20
- 1. Move the directory:
21
-
22
- ```
23
- mv app/javascript client
24
- ```
25
-
26
- 2. Edit your `/config/shakapacker.yml` file. Change the `default/source_path`:
27
-
28
- ```yml
29
- source_path: client
30
- ```
31
-
32
- ## Moving node_modules from `/` to `/client` with a custom webpack setup.
33
-
34
- Shakapacker 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.
35
-
36
- 1. Move the `/package.json` to `/client/package.json`
37
- 2. Create a `/package.json` that delegates to `/client/package.json`.
38
- ```
39
- "scripts": {
40
- "heroku-postbuild": "cd ./client && yarn"
41
- },
42
- ```
43
- 3. If your `node_modules` directory is not at the top level of the Rails project, then you will need to set the
44
- ENV value of `SHAKAPACKER_CONFIG` to the location of the `config/shakapacker.yml` file per [rails/webpacker PR 2561](https://github.com/rails/webpacker/pull/2561). (Notice the change of spelling from Webpacker to Shakapacker)
45
-
46
- ## CSS, Sass, Fonts, and Images
47
- Should you move your styling assets to Webpack? Or stick with the plain Rails asset pipeline. It depends!
48
-
49
- Here's a good discussion of this option: [Why does Rails 6 include both Webpacker and Sprockets?](https://rossta.net/blog/why-does-rails-install-both-webpacker-and-sprockets.html).
50
-
51
- You have 2 basic choices:
52
-
53
- ### Simple Rails Way
54
- 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.
55
-
56
- #### Advantages to the Simple Rails Way
57
- 1. Much simpler! There's no changes really from your current processes.
58
-
59
- ### Using Webpack to Manage Styling Assets
60
- This technique involves customization of the webpack config files to generate CSS, image, and font assets.
61
-
62
- #### Directory structure
63
- 1. `/client/app/assets`: Assets for CSS for client app.
64
- 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.
65
-
66
- #### Advantages to having Webpack Manage Styles
67
- 1. You can use [CSS modules](https://github.com/css-modules/css-modules), which is super compelling once you seen the benefits.
68
- 1. You can use CSS in JS.
69
- 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.
@@ -1,15 +0,0 @@
1
- # Tips for usage with Shakapacker 6
2
-
3
- As mentioned earlier in the documentation, we assume you install ReactOnRails in a project with Shakapacker 7+ installed and configured. If you still use Shakapacker 6, we encourage you to check the upgrade to the version 7 guide. Otherwise, you need to consider the following:
4
-
5
- 1. The install generator tries to take the necessary steps to adapt the installed files to match the file structure and configurations for Shakapacker 6. So you don't need to be worried about the ReactOnRails installation process.
6
-
7
- 2. Check the following table to map the references in the documentation to the relevant ones in Shakapacker 6:
8
-
9
- |Usage in Shakapacker 7 |Equivalant in Shakapacker 6|
10
- |----------------------------|---------------------------|
11
- |`config/shakapacker.yml` |`config/webpacker.yml` |
12
- |`bin/shakapacker` |`bin/webpacker` |
13
- |`bin/shakapacker-dev-server`|`bin/webpacker-dev-server` |
14
-
15
- 3. Any environment variables starting with `SHAKAPACKER_*` should be changed to `WEBPACKER_*`.
@@ -1,31 +0,0 @@
1
- # Updating Dependencies
2
-
3
- If you frequently update you dependencies in small batches, you will avoid large and painful updates later. Then again, if you don't have good tests coverage, it's hazardous to update dependencies at any time.
4
-
5
- ## Ruby
6
-
7
- Delete any unwanted version constraints from your Gemfile and run:
8
-
9
- ```bash
10
- bundle update
11
- ```
12
-
13
- ## NPM
14
-
15
- 1. Install [npm-check-updates](https://www.npmjs.com/package/npm-check-updates)
16
- 1. Run `yarn outdated` and read CHANGELOGs of major updated packages before you update. You might not be ready for some updates.
17
- 1. Run these commands. You may or may not need to `rm -rf` your `node_modules` directory.
18
-
19
- ```
20
- cd client
21
- ncu -u -a
22
- yarn
23
- ```
24
-
25
- Some combinations that I often run:
26
-
27
- ### remove old installed `node_modules` so you only get what corresponds to package.json
28
- ```
29
- ncu -u -a && rm -rf node_modules && yarn
30
- ```
31
-
@@ -1,10 +0,0 @@
1
- # Upgrading rails/webpacker v3.5 to v4
2
-
3
- The following steps can be followed to update a Webpacker v3.5 app to v4.
4
-
5
- 1. Update the gem `webpacker` and the package `@rails/webpacker`
6
- 1. Merge changes from the new default [.babelrc](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/.babelrc) to your `/.babelrc`. If you are using React, you need to add `"@babel/preset-react"`, to the list of `presets`.
7
- 1. Copy the file [.browserslistrc](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/.browserslistrc) to `/`.
8
- 1. Merge any differences between [config/webpacker.yml](https://github.com/shakacode/react_on_rails/tree/master/lib/install/config/webpacker.yml) and your `/config/webpacker.yml`.
9
-
10
- Here is an [example commit of these changes](https://github.com/shakacode/react_on_rails-tutorial-v11/pull/1/files).
@@ -1,99 +0,0 @@
1
- # ReactOnRails JavaScript API
2
- ## CSRF protection
3
-
4
- Rails has built-in protection for Cross-Site Request Forgery (CSRF), see [Rails Documentation](http://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf). To nicely utilize this feature in JavaScript requests, React on Rails provides two helpers that can be used as following for POST, PUT or DELETE requests:
5
-
6
- ```js
7
- import ReactOnRails from 'react-on-rails';
8
-
9
- // reads from DOM csrf token generated by Rails in <%= csrf_meta_tags %>
10
- csrfToken = ReactOnRails.authenticityToken();
11
-
12
- // compose Rails specific request header as following { X-CSRF-Token: csrfToken, X-Requested-With: XMLHttpRequest }
13
- header = ReactOnRails.authenticityHeaders(otherHeader);
14
- ```
15
-
16
- If you are using [jquery-ujs](https://github.com/rails/jquery-ujs) for AJAX calls, then these helpers are not needed because the [jquery-ujs](https://github.com/rails/jquery-ujs) library updates header automatically, see [jquery-ujs documentation](https://robots.thoughtbot.com/a-tour-of-rails-jquery-ujs#cross-site-request-forgery-protection).
17
-
18
-
19
-
20
- ## API
21
-
22
- The best source of docs is the main [ReactOnRails.js](https://github.com/shakacode/react_on_rails/node_package/src/ReactOnRails.js) file. Here's a quick summary. No guarantees that this won't be outdated!
23
-
24
- ```js
25
- /**
26
- * Main entry point to using the react-on-rails npm package. This is how Rails will be able to
27
- * find you components for rendering. Components get called with props, or you may use a
28
- * "Render-Function" to return a React component or an object with the following shape:
29
- * { renderedHtml, redirectLocation, error }.
30
- * For server rendering, if you wish to return multiple HTML strings from a Render-Function,
31
- * you may return an Object from your Render-Function with a single top level property of
32
- * renderedHtml. Inside this Object, place a key called componentHtml, along with any other
33
- * needed keys. This is useful when you using side effects libraries like react helmet.
34
- * Your Ruby code with get this Object as a Hash containing keys componentHtml and any other
35
- * custom keys that you added:
36
- * { renderedHtml: { componentHtml, customKey1, customKey2 } }
37
- * See the example in https://www.shakacode.com/react-on-rails/docs/javascript/react-helmet
38
- * @param components (key is component name, value is component)
39
- */
40
- register(components)
41
-
42
- /**
43
- * Allows registration of store generators to be used by multiple react components on one Rails
44
- * view. store generators are functions that take one arg, props, and return a store. Note that
45
- * the setStore API is different in tha it's the actual store hydrated with props.
46
- * @param stores (key is store name, value is the store generator)
47
- */
48
- registerStore(stores)
49
-
50
- /**
51
- * Allows retrieval of the store by name. This store will be hydrated by any Rails form props.
52
- * Pass optional param throwIfMissing = false if you want to use this call to get back null if the
53
- * store with name is not registered.
54
- * @param name
55
- * @param throwIfMissing Defaults to true. Set to false to have this call return undefined if
56
- * there is no store with the given name.
57
- * @returns Redux Store, possibly hydrated
58
- */
59
- getStore(name, throwIfMissing = true )
60
-
61
- /**
62
- * Renders or hydrates the react element passed. In case react version is >=18 will use the new api.
63
- * @param domNode
64
- * @param reactElement
65
- * @param hydrate if true will perform hydration, if false will render
66
- * @returns {Root|ReactComponent|ReactElement|null}
67
- */
68
- reactHydrateOrRender(domNode, reactElement, hydrate)
69
-
70
- /**
71
- * Set options for ReactOnRails, typically before you call ReactOnRails.register
72
- * Available Options:
73
- * `traceTurbolinks: true|false Gives you debugging messages on Turbolinks events
74
- */
75
- setOptions(options)
76
-
77
- /**
78
- * Allow directly calling the page loaded script in case the default events that trigger react
79
- * rendering are not sufficient, such as when loading JavaScript asynchronously with TurboLinks:
80
- * More details can be found here:
81
- * https://www.shakacode.com/react-on-rails/docs/rails/turbolinks
82
- */
83
- reactOnRailsPageLoaded()
84
-
85
- /**
86
- * Returns CSRF authenticity token inserted by Rails csrf_meta_tags
87
- * @returns String or null
88
- */
89
-
90
- authenticityToken()
91
-
92
- /**
93
- * Returns header with csrf authenticity token and XMLHttpRequest
94
- * @param {*} other headers
95
- * @returns {*} header
96
- */
97
-
98
- authenticityHeaders(otherHeaders = {})
99
- ```