react_on_rails 13.4.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -2
- data/Gemfile.development_dependencies +10 -8
- data/README.md +2 -2
- data/lib/generators/react_on_rails/base_generator.rb +10 -2
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/shakapacker.yml +1 -1
- data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +2 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/system/hello_world_spec.rb +1 -1
- data/lib/react_on_rails/configuration.rb +39 -25
- data/lib/react_on_rails/git_utils.rb +3 -3
- data/lib/react_on_rails/helper.rb +2 -2
- data/lib/react_on_rails/json_output.rb +0 -17
- data/lib/react_on_rails/locales/base.rb +4 -4
- data/lib/react_on_rails/locales/to_js.rb +1 -1
- data/lib/react_on_rails/packs_generator.rb +2 -4
- data/lib/react_on_rails/react_component/render_options.rb +1 -1
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +9 -9
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +3 -3
- data/lib/react_on_rails/test_helper.rb +2 -2
- data/lib/react_on_rails/utils.rb +2 -8
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +2 -2
- data/lib/react_on_rails/webpacker_utils.rb +6 -0
- data/lib/tasks/assets.rake +1 -1
- data/react_on_rails.gemspec +4 -4
- metadata +4 -132
- data/.bookignore +0 -15
- data/.circleci/config.yml +0 -338
- data/.coveralls.yml +0 -1
- data/.dockerignore +0 -2
- data/.eslintignore +0 -17
- data/.eslintrc +0 -53
- data/.github/FUNDING.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -19
- data/.github/workflows/lint-js-and-ruby.yml +0 -54
- data/.github/workflows/main.yml +0 -183
- data/.github/workflows/package-js-tests.yml +0 -35
- data/.github/workflows/rspec-package-specs.yml +0 -46
- data/.gitignore +0 -33
- data/.npmignore +0 -22
- data/.prettierignore +0 -14
- data/.prettierrc +0 -20
- data/.rspec +0 -2
- data/.rubocop.yml +0 -134
- data/.scss-lint.yml +0 -205
- data/.travis.yml +0 -61
- data/book.json +0 -18
- data/docs/additional-details/generator-details.md +0 -56
- data/docs/additional-details/manual-installation-overview.md +0 -30
- data/docs/additional-details/migrating-from-react-rails.md +0 -17
- data/docs/additional-details/recommended-project-structure.md +0 -69
- data/docs/additional-details/tips-for-usage-with-sp6.md +0 -15
- data/docs/additional-details/updating-dependencies.md +0 -31
- data/docs/additional-details/upgrade-webpacker-v3-to-v4.md +0 -10
- data/docs/api/javascript-api.md +0 -99
- data/docs/api/redux-store-api.md +0 -102
- data/docs/api/view-helpers-api.md +0 -133
- data/docs/contributor-info/errors-with-hooks.md +0 -45
- data/docs/contributor-info/generator-testing.md +0 -11
- data/docs/contributor-info/linters.md +0 -68
- data/docs/contributor-info/pull-requests.md +0 -42
- data/docs/contributor-info/releasing.md +0 -76
- data/docs/deployment/elastic-beanstalk.md +0 -63
- data/docs/deployment/heroku-deployment.md +0 -39
- data/docs/getting-started.md +0 -196
- data/docs/guides/client-vs-server-rendering.md +0 -27
- data/docs/guides/configuration.md +0 -289
- data/docs/guides/deployment.md +0 -5
- data/docs/guides/file-system-based-automated-bundle-generation.md +0 -197
- data/docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md +0 -104
- data/docs/guides/how-react-on-rails-works.md +0 -44
- data/docs/guides/how-to-conditionally-server-render-based-on-device-type.md +0 -40
- data/docs/guides/how-to-use-different-files-for-client-and-server-rendering.md +0 -98
- data/docs/guides/i18n.md +0 -87
- data/docs/guides/installation-into-an-existing-rails-app.md +0 -66
- data/docs/guides/minitest-configuration.md +0 -31
- data/docs/guides/rails-webpacker-react-integration-options.md +0 -213
- data/docs/guides/react-on-rails-overview.md +0 -29
- data/docs/guides/react-server-rendering.md +0 -32
- data/docs/guides/render-functions-and-railscontext.md +0 -205
- data/docs/guides/rspec-configuration.md +0 -73
- data/docs/guides/tutorial.md +0 -371
- data/docs/guides/upgrading-react-on-rails.md +0 -304
- data/docs/guides/webpack-configuration.md +0 -42
- data/docs/home.md +0 -23
- data/docs/javascript/angular-js-integration-migration.md +0 -28
- data/docs/javascript/asset-pipeline.md +0 -12
- data/docs/javascript/capistrano-deployment.md +0 -18
- data/docs/javascript/code-splitting.md +0 -165
- data/docs/javascript/converting-from-custom-webpack-config-to-rails-webpacker-config.md +0 -10
- data/docs/javascript/credits.md +0 -10
- data/docs/javascript/foreman-issues.md +0 -15
- data/docs/javascript/images.md +0 -57
- data/docs/javascript/node-dependencies-and-npm.md +0 -19
- data/docs/javascript/react-and-redux.md +0 -36
- data/docs/javascript/react-helmet.md +0 -100
- data/docs/javascript/react-router.md +0 -90
- data/docs/javascript/server-rendering-tips.md +0 -55
- data/docs/javascript/troubleshooting-when-using-shakapacker.md +0 -77
- data/docs/javascript/troubleshooting-when-using-webpacker.md +0 -90
- data/docs/javascript/webpack-v1-notes.md +0 -23
- data/docs/javascript/webpack.md +0 -22
- data/docs/misc/articles.md +0 -20
- data/docs/misc/code_of_conduct.md +0 -13
- data/docs/misc/doctrine.md +0 -77
- data/docs/misc/style.md +0 -33
- data/docs/misc/tips.md +0 -10
- data/docs/outdated/deferred-rendering.md +0 -39
- data/docs/outdated/rails-assets-relative-paths.md +0 -195
- data/docs/outdated/rails-assets.md +0 -77
- data/docs/outdated/rails3.md +0 -9
- data/docs/rails/convert-rails-5-api-only-app.md +0 -19
- data/docs/rails/rails-engine-integration.md +0 -32
- data/docs/rails/rails_view_rendering_from_inline_javascript.md +0 -36
- data/docs/rails/turbolinks.md +0 -124
- data/docs/react-on-rails-pro/react-on-rails-pro.md +0 -43
- data/docs/testimonials/hvmn.md +0 -25
- data/docs/testimonials/resortpass.md +0 -13
- data/docs/testimonials/testimonials.md +0 -28
- data/jest.config.js +0 -4
- data/package-scripts.yml +0 -49
- data/package.json +0 -96
- data/rakelib/docker.rake +0 -26
- data/rakelib/dummy_apps.rake +0 -30
- data/rakelib/example_type.rb +0 -96
- data/rakelib/examples.rake +0 -64
- data/rakelib/examples_config.yml +0 -14
- data/rakelib/lint.rake +0 -30
- data/rakelib/node_package.rake +0 -15
- data/rakelib/release.rake +0 -92
- data/rakelib/run_rspec.rake +0 -103
- data/rakelib/task_helpers.rb +0 -62
- data/script/bootstrap +0 -33
- data/script/release +0 -3
- data/script/setup +0 -23
- data/script/test +0 -38
- data/webpackConfigLoader.js +0 -71
- data/yarn.lock +0 -7010
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 37cf3a6fba0b83dec923947d8cc8f883f3f4f8ff06c51760347bbe41a79ee35a
|
|
4
|
+
data.tar.gz: 522f25ca29ebd985f975d9f8dd7ab8947ef4ccacc7591f28db176b0c2964f444
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 873fc4c65b407b3982ef2761d0e5e346ef8eb04dc9468b074db188f641537634578b057b59a3b4b12135a988bd725207ded6a20e9b4a97ca42f39c31ea934928
|
|
7
|
+
data.tar.gz: 6f46192a308e4d636bbe954e3c34bc256aab07c9b42bf177c9254fde495e37726a46b285df1124ef2ebc859b2311cf77afca8bb16158f39a5eb9fec013d714b2
|
data/CHANGELOG.md
CHANGED
|
@@ -15,7 +15,27 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
|
|
|
15
15
|
### [Unreleased]
|
|
16
16
|
Changes since the last non-beta release.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
### [14.0.0] - 2024-04-03
|
|
19
|
+
_Major bump because dropping support for Ruby 2.7 and deprecated `webpackConfigLoader.js`._
|
|
20
|
+
|
|
21
|
+
#### Removed
|
|
22
|
+
- Dropped Ruby 2.7 support [PR 1595](https://github.com/shakacode/react_on_rails/pull/1595) by [ahangarha](https://github.com/ahangarha).
|
|
23
|
+
- Removed deprecated `webpackConfigLoader.js` [PR 1600](https://github.com/shakacode/react_on_rails/pull/1600) by [ahangarha](https://github.com/ahangarha).
|
|
24
|
+
|
|
25
|
+
#### Fixed
|
|
26
|
+
- Trimmed the Gem to remove package.json which could cause superflous security warnings. [PR 1605](https://github.com/shakacode/react_on_rails/pull/1605) by [justin808](https://github.com/justin808).
|
|
27
|
+
- Prevent displaying the deprecation message for using `webpacker_precompile?` method and `webpacker:clean` rake task when using Shakapacker v7+ [PR 1592](https://github.com/shakacode/react_on_rails/pull/1592) by [ahangarha](https://github.com/ahangarha).
|
|
28
|
+
|
|
29
|
+
### [13.4.1]
|
|
30
|
+
#### Fixed
|
|
31
|
+
- Fixed Typescript types for ServerRenderResult, ReactComponent, RenderFunction, and RailsContext interfaces. [PR 1582](https://github.com/shakacode/react_on_rails/pull/1582) & [PR 1585](https://github.com/shakacode/react_on_rails/pull/1585) by [kotarella1110](https://github.com/kotarella1110)
|
|
32
|
+
|
|
33
|
+
- Removed a workaround in `JsonOutput#escape` for an no-longer supported Rails version. Additionally, removed `Utils.rails_version_less_than_4_1_1`
|
|
34
|
+
which was only used in the workaround. [PR 1580](https://github.com/shakacode/react_on_rails/pull/1580) by [wwahammy](https://github.com/wwahammy)
|
|
35
|
+
|
|
36
|
+
#### Added
|
|
37
|
+
- Exposed TypeScript all types [PR 1586](https://github.com/shakacode/react_on_rails/pull/1586) by [kotarella1110](https://github.com/kotarella1110)
|
|
38
|
+
|
|
19
39
|
### [13.4.0] - 2023-07-30
|
|
20
40
|
#### Fixed
|
|
21
41
|
- Fixed Pack Generation logic during `assets:precompile` if `auto_load_bundle` is `false` & `components_subdirectory` is not set. [PR 1567](https://github.com/shakacode/react_on_rails/pull/1545) by [blackjack26](https://github.com/blackjack26) & [judahmeek](https://github.com/judahmeek).
|
|
@@ -1104,7 +1124,9 @@ Best done with Object destructing:
|
|
|
1104
1124
|
##### Fixed
|
|
1105
1125
|
- Fix several generator-related issues.
|
|
1106
1126
|
|
|
1107
|
-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/
|
|
1127
|
+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.0...master
|
|
1128
|
+
[14.0.0]: https://github.com/shakacode/react_on_rails/compare/13.4.1...14.0.0
|
|
1129
|
+
[13.4.1]: https://github.com/shakacode/react_on_rails/compare/13.4.0...13.4.1
|
|
1108
1130
|
[13.4.0]: https://github.com/shakacode/react_on_rails/compare/13.3.5...13.4.0
|
|
1109
1131
|
[13.3.5]: https://github.com/shakacode/react_on_rails/compare/13.3.4...13.3.5
|
|
1110
1132
|
[13.3.4]: https://github.com/shakacode/react_on_rails/compare/13.3.3...13.3.4
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
gem "shakapacker", "7.
|
|
3
|
+
gem "shakapacker", "7.2.1"
|
|
4
4
|
gem "bootsnap", require: false
|
|
5
|
-
gem "rails", "~> 7.
|
|
5
|
+
gem "rails", "~> 7.1"
|
|
6
|
+
|
|
6
7
|
gem "sqlite3"
|
|
7
8
|
gem "sass-rails", "~> 6.0"
|
|
8
9
|
gem "uglifier"
|
|
9
10
|
gem "jquery-rails"
|
|
10
|
-
gem "puma", "~>
|
|
11
|
-
gem "bundler", "2.
|
|
11
|
+
gem "puma", "~> 6.0"
|
|
12
|
+
gem "bundler", "2.5.3"
|
|
12
13
|
|
|
13
14
|
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
|
14
15
|
gem "turbolinks" if ENV["DISABLE_TURBOLINKS"].nil? || ENV["DISABLE_TURBOLINKS"].strip.empty?
|
|
@@ -29,9 +30,9 @@ group :development, :test do
|
|
|
29
30
|
gem "pry-doc"
|
|
30
31
|
gem "pry-rails"
|
|
31
32
|
gem "pry-rescue"
|
|
32
|
-
gem "rubocop", "1.
|
|
33
|
-
gem "rubocop-performance", require: false
|
|
34
|
-
gem "rubocop-rspec", require: false
|
|
33
|
+
gem "rubocop", "~>1.59", require: false
|
|
34
|
+
gem "rubocop-performance", "~>1.20.0", require: false
|
|
35
|
+
gem "rubocop-rspec", "~>2.26", require: false
|
|
35
36
|
gem "scss_lint", require: false
|
|
36
37
|
gem "spring", "~> 4.0"
|
|
37
38
|
end
|
|
@@ -46,5 +47,6 @@ group :test do
|
|
|
46
47
|
gem "rspec_junit_formatter"
|
|
47
48
|
gem "rspec-rails"
|
|
48
49
|
gem "rspec-retry"
|
|
49
|
-
gem "selenium-webdriver"
|
|
50
|
+
gem "selenium-webdriver", "4.9.0"
|
|
51
|
+
gem "webdrivers", "5.3.0"
|
|
50
52
|
end
|
data/README.md
CHANGED
|
@@ -63,7 +63,7 @@ See [Rails/Webpacker React Integration Options](https://www.shakacode.com/react-
|
|
|
63
63
|
|
|
64
64
|
## Online demo
|
|
65
65
|
* See the [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial) for an example of a live implementation and code.
|
|
66
|
-
* A deployed version of the project `spec/dummy
|
|
66
|
+
* A deployed version of the project `spec/dummy`, which demonstrates several uses of `react_on_rails`, will soon be available on [Control Plane through this link](https://ror-spec-dummy.reactrails.com/)
|
|
67
67
|
|
|
68
68
|
## ShakaCode Forum Premium Content
|
|
69
69
|
_Requires creating a free account._
|
|
@@ -73,7 +73,7 @@ _Requires creating a free account._
|
|
|
73
73
|
|
|
74
74
|
## Prerequisites
|
|
75
75
|
|
|
76
|
-
Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >=
|
|
76
|
+
Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >= 3.0.0
|
|
77
77
|
|
|
78
78
|
# Support
|
|
79
79
|
|
|
@@ -77,7 +77,7 @@ module ReactOnRails
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def add_yarn_dependencies
|
|
80
|
-
major_minor_patch_only = /\A\d+\.\d+\.\d+\z
|
|
80
|
+
major_minor_patch_only = /\A\d+\.\d+\.\d+\z/
|
|
81
81
|
if ReactOnRails::VERSION.match?(major_minor_patch_only)
|
|
82
82
|
run "yarn add react-on-rails@#{ReactOnRails::VERSION} --exact"
|
|
83
83
|
else
|
|
@@ -91,7 +91,15 @@ module ReactOnRails
|
|
|
91
91
|
babel-plugin-macros"
|
|
92
92
|
|
|
93
93
|
puts "Adding CSS handlers"
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
# css_minimizer_webpack_plugin version 6 only supports Nodejs v18+
|
|
96
|
+
# When we bump our minimum Nodejs version to 18, we can remove this logic
|
|
97
|
+
# and install css_minimizer_webpack_plugin directly.
|
|
98
|
+
node_major_version = `node -v`.match(/^v(\d{,2})\./)[1]&.to_i
|
|
99
|
+
css_minimizer_webpack_plugin_version = node_major_version >= 18 ? "" : "@<6.0.0"
|
|
100
|
+
css_minimizer_webpack_plugin = "css-minimizer-webpack-plugin#{css_minimizer_webpack_plugin_version}"
|
|
101
|
+
|
|
102
|
+
run "yarn add css-loader '#{css_minimizer_webpack_plugin}' mini-css-extract-plugin style-loader"
|
|
95
103
|
|
|
96
104
|
puts "Adding dev dependencies"
|
|
97
105
|
run "yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh"
|
|
@@ -39,7 +39,7 @@ module ReactOnRails
|
|
|
39
39
|
|
|
40
40
|
hello_world_index = File.join(destination_root, "app", "views", "hello_world", "index.html.erb")
|
|
41
41
|
hello_world_contents = File.read(hello_world_index)
|
|
42
|
-
new_hello_world_contents = hello_world_contents.gsub(
|
|
42
|
+
new_hello_world_contents = hello_world_contents.gsub("prerender: false",
|
|
43
43
|
"prerender: true")
|
|
44
44
|
|
|
45
45
|
File.open(hello_world_index, "w+") { |f| f.puts new_hello_world_contents }
|
|
@@ -17,7 +17,7 @@ default: &default
|
|
|
17
17
|
|
|
18
18
|
development:
|
|
19
19
|
<<: *default
|
|
20
|
-
# This is false since we're running `bin/shakapacker -w` in Procfile.dev-
|
|
20
|
+
# This is false since we're running `bin/shakapacker -w` in Procfile.dev-static
|
|
21
21
|
compile: false
|
|
22
22
|
|
|
23
23
|
# Reference: https://webpack.js.org/configuration/dev-server/
|
|
@@ -40,7 +40,7 @@ end
|
|
|
40
40
|
# ActiveRecord::Migration.maintain_test_schema!
|
|
41
41
|
|
|
42
42
|
RSpec.configure do |config|
|
|
43
|
-
config.before(:each, type: :system
|
|
43
|
+
config.before(:each, :js, type: :system) do
|
|
44
44
|
driven_by :selenium_chrome
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -49,7 +49,7 @@ RSpec.configure do |config|
|
|
|
49
49
|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
|
50
50
|
|
|
51
51
|
# Remove this line if you"re not using ActiveRecord or ActiveRecord fixtures
|
|
52
|
-
config.fixture_path = "#{
|
|
52
|
+
config.fixture_path = "#{Rails.root}/spec/fixtures"
|
|
53
53
|
|
|
54
54
|
# If you"re not using ActiveRecord, or you"d prefer not to run each of your
|
|
55
55
|
# examples within a transaction, remove the following line or assign false
|
|
@@ -137,35 +137,23 @@ module ReactOnRails
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def adjust_precompile_task
|
|
140
|
-
skip_react_on_rails_precompile = %w[no false n f].include?(ENV
|
|
140
|
+
skip_react_on_rails_precompile = %w[no false n f].include?(ENV.fetch("REACT_ON_RAILS_PRECOMPILE", nil))
|
|
141
141
|
|
|
142
142
|
return if skip_react_on_rails_precompile || build_production_command.blank?
|
|
143
143
|
|
|
144
|
-
if
|
|
145
|
-
msg = <<~MSG
|
|
146
|
-
|
|
147
|
-
React on Rails and Shakapacker error in configuration!
|
|
148
|
-
In order to use config/react_on_rails.rb config.build_production_command,
|
|
149
|
-
you must edit config/webpacker.yml to include this value in the default configuration:
|
|
150
|
-
'webpacker_precompile: false'
|
|
151
|
-
|
|
152
|
-
Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
|
|
153
|
-
default bin/webpacker script will be used for assets:precompile.
|
|
154
|
-
|
|
155
|
-
MSG
|
|
156
|
-
raise ReactOnRails::Error, msg
|
|
157
|
-
end
|
|
144
|
+
raise(ReactOnRails::Error, compile_command_conflict_message) if shakapacker_precompile?
|
|
158
145
|
|
|
159
146
|
precompile_tasks = lambda {
|
|
160
147
|
Rake::Task["react_on_rails:generate_packs"].invoke
|
|
161
148
|
Rake::Task["react_on_rails:assets:webpack"].invoke
|
|
162
|
-
puts "Invoking task webpacker:clean from React on Rails"
|
|
163
149
|
|
|
164
150
|
# VERSIONS is per the shakacode/shakapacker clean method definition.
|
|
165
151
|
# We set it very big so that it is not used, and then clean just
|
|
166
152
|
# removes files older than 1 hour.
|
|
167
153
|
versions = 100_000
|
|
168
|
-
|
|
154
|
+
|
|
155
|
+
puts "Invoking task #{shakapacker_clean_task} from React on Rails"
|
|
156
|
+
Rake::Task[shakapacker_clean_task].invoke(versions)
|
|
169
157
|
}
|
|
170
158
|
|
|
171
159
|
if Rake::Task.task_defined?("assets:precompile")
|
|
@@ -187,7 +175,7 @@ module ReactOnRails
|
|
|
187
175
|
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
|
188
176
|
|
|
189
177
|
if File.expand_path(generated_assets_dir) == webpacker_public_output_path.to_s
|
|
190
|
-
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` "\
|
|
178
|
+
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
|
|
191
179
|
"with Webpacker. Remove this line from your configuration file.")
|
|
192
180
|
else
|
|
193
181
|
msg = <<~MSG
|
|
@@ -225,20 +213,20 @@ module ReactOnRails
|
|
|
225
213
|
|
|
226
214
|
if ReactOnRails::WebpackerUtils.using_webpacker?
|
|
227
215
|
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
|
228
|
-
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the "\
|
|
229
|
-
"generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined
|
|
230
|
-
"public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
|
|
216
|
+
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the " \
|
|
217
|
+
"generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined " \
|
|
218
|
+
"by public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
|
|
231
219
|
return
|
|
232
220
|
end
|
|
233
221
|
|
|
234
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
|
|
222
|
+
Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than " \
|
|
235
223
|
"generated_assets_dirs"
|
|
236
224
|
if generated_assets_dir.blank?
|
|
237
225
|
self.generated_assets_dir = generated_assets_dirs
|
|
238
226
|
else
|
|
239
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
|
|
240
|
-
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker"\
|
|
241
|
-
"
|
|
227
|
+
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \
|
|
228
|
+
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker " \
|
|
229
|
+
"and define neither if using Webpacker"
|
|
242
230
|
end
|
|
243
231
|
end
|
|
244
232
|
|
|
@@ -266,6 +254,32 @@ module ReactOnRails
|
|
|
266
254
|
|
|
267
255
|
raise ReactOnRails::Error, msg
|
|
268
256
|
end
|
|
257
|
+
|
|
258
|
+
def shakapacker_precompile?
|
|
259
|
+
return Webpacker.config.webpacker_precompile? if ReactOnRails::WebpackerUtils.using_shakapacker_6?
|
|
260
|
+
|
|
261
|
+
Webpacker.config.shakapacker_precompile?
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def shakapacker_clean_task
|
|
265
|
+
ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker:clean" : "shakapacker:clean"
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def compile_command_conflict_message
|
|
269
|
+
packer = ReactOnRails::WebpackerUtils.using_shakapacker_6? ? "webpacker" : "shakapacker"
|
|
270
|
+
|
|
271
|
+
<<~MSG
|
|
272
|
+
|
|
273
|
+
React on Rails and Shakapacker error in configuration!
|
|
274
|
+
In order to use config/react_on_rails.rb config.build_production_command,
|
|
275
|
+
you must edit config/#{packer}.yml to include this value in the default configuration:
|
|
276
|
+
'#{packer}_precompile: false'
|
|
277
|
+
|
|
278
|
+
Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
|
|
279
|
+
default bin/#{packer} script will be used for assets:precompile.
|
|
280
|
+
|
|
281
|
+
MSG
|
|
282
|
+
end
|
|
269
283
|
end
|
|
270
284
|
end
|
|
271
285
|
# rubocop:enable Metrics/ClassLength
|
|
@@ -4,13 +4,13 @@ require "English"
|
|
|
4
4
|
|
|
5
5
|
module ReactOnRails
|
|
6
6
|
module GitUtils
|
|
7
|
-
def self.uncommitted_changes?(message_handler)
|
|
7
|
+
def self.uncommitted_changes?(message_handler, git_installed = true)
|
|
8
8
|
return false if ENV["COVERAGE"] == "true"
|
|
9
9
|
|
|
10
10
|
status = `git status --porcelain`
|
|
11
|
-
return false if
|
|
11
|
+
return false if git_installed && status&.empty?
|
|
12
12
|
|
|
13
|
-
error = if
|
|
13
|
+
error = if git_installed
|
|
14
14
|
"You have uncommitted code. Please commit or stash your changes before continuing"
|
|
15
15
|
else
|
|
16
16
|
"You do not have Git installed. Please install Git, and commit your changes before continuing"
|
|
@@ -155,7 +155,7 @@ module ReactOnRails
|
|
|
155
155
|
if defer
|
|
156
156
|
@registered_stores_defer_render ||= []
|
|
157
157
|
@registered_stores_defer_render << redux_store_data
|
|
158
|
-
"YOU SHOULD NOT SEE THIS ON YOUR VIEW -- Uses as a code block, like <% redux_store %> "\
|
|
158
|
+
"YOU SHOULD NOT SEE THIS ON YOUR VIEW -- Uses as a code block, like <% redux_store %> " \
|
|
159
159
|
"and not <%= redux store %>"
|
|
160
160
|
else
|
|
161
161
|
@registered_stores ||= []
|
|
@@ -245,7 +245,7 @@ module ReactOnRails
|
|
|
245
245
|
return "{}" if hash_or_string.nil?
|
|
246
246
|
|
|
247
247
|
unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
|
|
248
|
-
raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument "\
|
|
248
|
+
raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument " \
|
|
249
249
|
"(#{hash_or_string.class} given)."
|
|
250
250
|
end
|
|
251
251
|
|
|
@@ -4,25 +4,8 @@ require "active_support/core_ext/string/output_safety"
|
|
|
4
4
|
|
|
5
5
|
module ReactOnRails
|
|
6
6
|
class JsonOutput
|
|
7
|
-
ESCAPE_REPLACEMENT = {
|
|
8
|
-
"&" => '\u0026',
|
|
9
|
-
">" => '\u003e',
|
|
10
|
-
"<" => '\u003c',
|
|
11
|
-
"\u2028" => '\u2028',
|
|
12
|
-
"\u2029" => '\u2029'
|
|
13
|
-
}.freeze
|
|
14
|
-
ESCAPE_REGEXP = /[\u2028\u2029&><]/u.freeze
|
|
15
|
-
|
|
16
7
|
def self.escape(json)
|
|
17
|
-
return escape_without_erb_util(json) if Utils.rails_version_less_than_4_1_1
|
|
18
|
-
|
|
19
8
|
ERB::Util.json_escape(json)
|
|
20
9
|
end
|
|
21
|
-
|
|
22
|
-
def self.escape_without_erb_util(json)
|
|
23
|
-
# https://github.com/rails/rails/blob/60257141462137331387d0e34931555cf0720886/activesupport/lib/active_support/core_ext/string/output_safety.rb#L113
|
|
24
|
-
|
|
25
|
-
json.to_s.gsub(ESCAPE_REGEXP, ESCAPE_REPLACEMENT)
|
|
26
|
-
end
|
|
27
10
|
end
|
|
28
11
|
end
|
|
@@ -100,14 +100,14 @@ module ReactOnRails
|
|
|
100
100
|
|
|
101
101
|
def convert
|
|
102
102
|
file_names.each do |name|
|
|
103
|
-
template = send("template_#{name}")
|
|
103
|
+
template = send(:"template_#{name}")
|
|
104
104
|
path = file(name)
|
|
105
105
|
generate_file(template, path)
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def generate_file(template, path)
|
|
110
|
-
result = ERB.new(template).result
|
|
110
|
+
result = ERB.new(template).result
|
|
111
111
|
File.write(path, result)
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -138,7 +138,7 @@ module ReactOnRails
|
|
|
138
138
|
def flatten(translations)
|
|
139
139
|
translations.each_with_object({}) do |(k, v), h|
|
|
140
140
|
if v.is_a? Hash
|
|
141
|
-
flatten(v).map { |hk, hv| h["#{k}.#{hk}"
|
|
141
|
+
flatten(v).map { |hk, hv| h[:"#{k}.#{hk}"] = hv }
|
|
142
142
|
elsif v.is_a?(String)
|
|
143
143
|
h[k] = v.gsub("%{", "{")
|
|
144
144
|
elsif !v.is_a?(Array)
|
|
@@ -157,7 +157,7 @@ module ReactOnRails
|
|
|
157
157
|
<<-JS.strip_heredoc
|
|
158
158
|
import { defineMessages } from 'react-intl';
|
|
159
159
|
|
|
160
|
-
const defaultLocale =
|
|
160
|
+
const defaultLocale = '#{default_locale}';
|
|
161
161
|
|
|
162
162
|
const defaultMessages = defineMessages(#{@defaults});
|
|
163
163
|
|
|
@@ -5,7 +5,7 @@ require "fileutils"
|
|
|
5
5
|
module ReactOnRails
|
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
|
7
7
|
class PacksGenerator
|
|
8
|
-
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)
|
|
8
|
+
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/
|
|
9
9
|
MINIMUM_SHAKAPACKER_VERSION = [6, 5, 1].freeze
|
|
10
10
|
|
|
11
11
|
def self.instance
|
|
@@ -155,9 +155,7 @@ module ReactOnRails
|
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
def common_component_to_path
|
|
158
|
-
common_components_paths = Dir.glob("#{components_search_path}/*").
|
|
159
|
-
CONTAINS_CLIENT_OR_SERVER_REGEX.match?(f)
|
|
160
|
-
end
|
|
158
|
+
common_components_paths = Dir.glob("#{components_search_path}/*").grep_v(CONTAINS_CLIENT_OR_SERVER_REGEX)
|
|
161
159
|
component_name_to_path(common_components_paths)
|
|
162
160
|
end
|
|
163
161
|
|
|
@@ -35,7 +35,7 @@ module ReactOnRails
|
|
|
35
35
|
props.clone)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
raise ReactOnRails::Error, "ReactOnRails: your rendering_props_extension module is missing the "\
|
|
38
|
+
raise ReactOnRails::Error, "ReactOnRails: your rendering_props_extension module is missing the " \
|
|
39
39
|
"required adjust_props_for_client_side_hydration method & can not be used"
|
|
40
40
|
end
|
|
41
41
|
props
|
|
@@ -7,7 +7,6 @@ module ReactOnRails
|
|
|
7
7
|
module ServerRenderingPool
|
|
8
8
|
# rubocop:disable Metrics/ClassLength
|
|
9
9
|
class RubyEmbeddedJavaScript
|
|
10
|
-
# rubocop:enable Metrics/ClassLength
|
|
11
10
|
class << self
|
|
12
11
|
def reset_pool
|
|
13
12
|
options = {
|
|
@@ -125,8 +124,8 @@ module ReactOnRails
|
|
|
125
124
|
File.read(server_js_file)
|
|
126
125
|
end
|
|
127
126
|
rescue StandardError => e
|
|
128
|
-
msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be "\
|
|
129
|
-
"read. You may set the server_bundle_js_file in your configuration to be \"\" to "\
|
|
127
|
+
msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be " \
|
|
128
|
+
"read. You may set the server_bundle_js_file in your configuration to be \"\" to " \
|
|
130
129
|
"avoid this warning.\nError is: #{e}"
|
|
131
130
|
raise ReactOnRails::Error, msg
|
|
132
131
|
end
|
|
@@ -145,15 +144,15 @@ module ReactOnRails
|
|
|
145
144
|
begin
|
|
146
145
|
if ReactOnRails.configuration.trace
|
|
147
146
|
Rails.logger.info do
|
|
148
|
-
"[react_on_rails] Created JavaScript context with file "\
|
|
147
|
+
"[react_on_rails] Created JavaScript context with file " \
|
|
149
148
|
"#{ReactOnRails::Utils.server_bundle_js_file_path}"
|
|
150
149
|
end
|
|
151
150
|
end
|
|
152
151
|
ExecJS.compile(base_js_code)
|
|
153
152
|
rescue StandardError => e
|
|
154
|
-
msg = "ERROR when compiling base_js_code! "\
|
|
155
|
-
"See file #{file_name} to "\
|
|
156
|
-
"correlate line numbers of error. Error is\n\n#{e.message}"\
|
|
153
|
+
msg = "ERROR when compiling base_js_code! " \
|
|
154
|
+
"See file #{file_name} to " \
|
|
155
|
+
"correlate line numbers of error. Error is\n\n#{e.message}" \
|
|
157
156
|
"\n\n#{e.backtrace.join("\n")}"
|
|
158
157
|
Rails.logger.error(msg)
|
|
159
158
|
trace_js_code_used("Error when compiling JavaScript code for the context.", base_js_code,
|
|
@@ -192,8 +191,8 @@ module ReactOnRails
|
|
|
192
191
|
|
|
193
192
|
def undefined_for_exec_js_logging(function_name)
|
|
194
193
|
if ReactOnRails.configuration.trace
|
|
195
|
-
"console.error('[React on Rails Rendering] #{function_name} is not defined for server rendering.');\n"\
|
|
196
|
-
"
|
|
194
|
+
"console.error('[React on Rails Rendering] #{function_name} is not defined for server rendering.');\n " \
|
|
195
|
+
"console.error(getStackTrace().join('\\n'));"
|
|
197
196
|
else
|
|
198
197
|
""
|
|
199
198
|
end
|
|
@@ -235,6 +234,7 @@ module ReactOnRails
|
|
|
235
234
|
raise ReactOnRails::Error, msg
|
|
236
235
|
end
|
|
237
236
|
end
|
|
237
|
+
# rubocop:enable Metrics/ClassLength
|
|
238
238
|
end
|
|
239
239
|
end
|
|
240
240
|
end
|
|
@@ -62,10 +62,10 @@ module ReactOnRails
|
|
|
62
62
|
else
|
|
63
63
|
file_list = make_file_list(make_globs(generated_assets_full_path)).to_ary
|
|
64
64
|
puts "V" * 80
|
|
65
|
-
puts "Please define config.webpack_generated_files (array) so the test helper knows "\
|
|
66
|
-
"which files are required. If you are using webpacker, you typically need to only "\
|
|
65
|
+
puts "Please define config.webpack_generated_files (array) so the test helper knows " \
|
|
66
|
+
"which files are required. If you are using webpacker, you typically need to only " \
|
|
67
67
|
"include 'manifest.json'."
|
|
68
|
-
puts "Detected the possible following files to check for webpack compilation in "\
|
|
68
|
+
puts "Detected the possible following files to check for webpack compilation in " \
|
|
69
69
|
"#{generated_assets_full_path}"
|
|
70
70
|
puts file_list.join("\n")
|
|
71
71
|
puts "^" * 80
|
|
@@ -80,8 +80,8 @@ module ReactOnRails
|
|
|
80
80
|
|
|
81
81
|
unless @printed_once
|
|
82
82
|
puts
|
|
83
|
-
puts "====> React On Rails: Checking files in "\
|
|
84
|
-
"#{webpack_assets_status_checker.generated_assets_full_path} for "\
|
|
83
|
+
puts "====> React On Rails: Checking files in " \
|
|
84
|
+
"#{webpack_assets_status_checker.generated_assets_full_path} for " \
|
|
85
85
|
"outdated/missing bundles based on source_path #{source_path}"
|
|
86
86
|
puts
|
|
87
87
|
@printed_once = true
|
data/lib/react_on_rails/utils.rb
CHANGED
|
@@ -118,12 +118,6 @@ module ReactOnRails
|
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
# rubocop:disable Naming/VariableNumber
|
|
122
|
-
def self.rails_version_less_than_4_1_1
|
|
123
|
-
rails_version_less_than("4.1.1")
|
|
124
|
-
end
|
|
125
|
-
# rubocop:enable Naming/VariableNumber
|
|
126
|
-
|
|
127
121
|
module Required
|
|
128
122
|
def required(arg_name)
|
|
129
123
|
raise ReactOnRails::Error, "#{arg_name} is required"
|
|
@@ -195,13 +189,13 @@ module ReactOnRails
|
|
|
195
189
|
to_remove = str.length - max_length
|
|
196
190
|
lstrip = (to_remove / 2.0).ceil
|
|
197
191
|
rstrip = to_remove - lstrip
|
|
198
|
-
str[0..(midpoint - lstrip - 1)] + TRUNCATION_FILLER + str[(midpoint + rstrip)
|
|
192
|
+
str[0..(midpoint - lstrip - 1)] + TRUNCATION_FILLER + str[(midpoint + rstrip)..]
|
|
199
193
|
end
|
|
200
194
|
|
|
201
195
|
def self.find_most_recent_mtime(files)
|
|
202
196
|
files.reduce(1.year.ago) do |newest_time, file|
|
|
203
197
|
mt = File.mtime(file)
|
|
204
|
-
mt
|
|
198
|
+
[mt, newest_time].max
|
|
205
199
|
end
|
|
206
200
|
end
|
|
207
201
|
|
|
@@ -6,7 +6,7 @@ module ReactOnRails
|
|
|
6
6
|
class VersionChecker
|
|
7
7
|
attr_reader :node_package_version
|
|
8
8
|
|
|
9
|
-
MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)
|
|
9
|
+
MAJOR_MINOR_PATCH_VERSION_REGEX = /(\d+)\.(\d+)\.(\d+)/
|
|
10
10
|
|
|
11
11
|
def self.build
|
|
12
12
|
new(NodePackageVersion.build)
|
|
@@ -52,7 +52,7 @@ module ReactOnRails
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def raise_node_semver_version_warning
|
|
55
|
-
msg = "**ERROR** ReactOnRails: Your node package version for react-on-rails contains a "\
|
|
55
|
+
msg = "**ERROR** ReactOnRails: Your node package version for react-on-rails contains a " \
|
|
56
56
|
"^ or ~\n#{common_error_msg}"
|
|
57
57
|
raise ReactOnRails::Error, msg
|
|
58
58
|
end
|
|
@@ -141,5 +141,11 @@ module ReactOnRails
|
|
|
141
141
|
def self.semver_to_string(ary)
|
|
142
142
|
"#{ary[0]}.#{ary[1]}.#{ary[2]}"
|
|
143
143
|
end
|
|
144
|
+
|
|
145
|
+
def self.using_shakapacker_6?
|
|
146
|
+
shakapacker_major_version = shakapacker_version_as_array[0]
|
|
147
|
+
|
|
148
|
+
shakapacker_major_version == 6
|
|
149
|
+
end
|
|
144
150
|
end
|
|
145
151
|
end
|
data/lib/tasks/assets.rake
CHANGED
|
@@ -18,7 +18,7 @@ namespace :react_on_rails do
|
|
|
18
18
|
elsif build_production_command.methods.include?(:call)
|
|
19
19
|
build_production_command.call
|
|
20
20
|
else
|
|
21
|
-
msg = "ReactonRails.configuration.build_production_command is improperly configured. "\
|
|
21
|
+
msg = "ReactonRails.configuration.build_production_command is improperly configured. " \
|
|
22
22
|
"Value = #{build_production_command} with class #{build_production_command.class}"
|
|
23
23
|
puts Rainbow(msg).red
|
|
24
24
|
exit!(1)
|
data/react_on_rails.gemspec
CHANGED
|
@@ -16,14 +16,15 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.homepage = "https://github.com/shakacode/react_on_rails"
|
|
17
17
|
s.license = "MIT"
|
|
18
18
|
|
|
19
|
-
s.files
|
|
20
|
-
f.match(%r{^(test|spec|features|gen-examples|tmp|node_modules|node_package|coverage)/})
|
|
19
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
20
|
+
f.match(%r{^(docs|test|spec|features|gen-examples|tmp|node_modules|node_package|coverage|rakelib|script)/}) ||
|
|
21
|
+
f.match(%r{^(jest\.config\.js|book\.json|package\.json|package-scripts\.yml|yarn\.lock|\..*)})
|
|
21
22
|
end
|
|
22
23
|
s.bindir = "exe"
|
|
23
24
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
25
|
s.require_paths = ["lib"]
|
|
25
26
|
|
|
26
|
-
s.required_ruby_version = ">=
|
|
27
|
+
s.required_ruby_version = ">= 3.0.0"
|
|
27
28
|
|
|
28
29
|
s.add_dependency "addressable"
|
|
29
30
|
s.add_dependency "connection_pool"
|
|
@@ -31,7 +32,6 @@ Gem::Specification.new do |s|
|
|
|
31
32
|
s.add_dependency "rails", ">= 5.2"
|
|
32
33
|
s.add_dependency "rainbow", "~> 3.0"
|
|
33
34
|
|
|
34
|
-
s.add_development_dependency "bundler", "~> 2"
|
|
35
35
|
s.add_development_dependency "gem-release"
|
|
36
36
|
s.post_install_message = '
|
|
37
37
|
--------------------------------------------------------------------------------
|