react_on_rails 11.0.7 → 11.0.8
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 +5 -5
- data/.travis.yml +2 -2
- data/CHANGELOG.md +19 -1
- data/README.md +18 -14
- data/docs/additional-reading/rails-engine-integration.md +7 -0
- data/docs/additional-reading/rspec-configuration.md +7 -1
- data/docs/basics/configuration.md +7 -3
- data/docs/basics/upgrading-react-on-rails.md +2 -2
- data/lib/react_on_rails/configuration.rb +129 -126
- data/lib/react_on_rails/prerender_error.rb +2 -0
- data/lib/react_on_rails/react_on_rails_helper.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +5 -1
- data/lib/react_on_rails/utils.rb +4 -2
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_syntax_converter.rb +14 -12
- data/lib/react_on_rails/webpacker_utils.rb +2 -2
- data/package.json +1 -1
- data/rakelib/release.rake +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ed7b1fbb2464837b56060e72a7496e347e4da42218d09256e11b2e30c24e43b
|
4
|
+
data.tar.gz: fb7122bd0af170552379b15faeb3bdacd989f8121e7995dd975d9554bd948d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f2cca7b17bf7c7f53d338a51fa01e28bb131712fdba019e058e481993d178995710ef42e3cc063f8617184695abaf1dc444f6161e5ee8a92ed04f4e042a27ed
|
7
|
+
data.tar.gz: ebf4448a0ad4316ecc89d893f6a52eecbd23ec62b55ea7e4a615ff15c7c20fabe1964e84224fda00328348e832555ce1dd78ae3782ffd9ee7d0514fdca9adb17
|
data/.travis.yml
CHANGED
@@ -37,9 +37,9 @@ before_install:
|
|
37
37
|
|
38
38
|
install:
|
39
39
|
- travis_retry gem install bundler
|
40
|
-
- travis_retry nvm install
|
40
|
+
- travis_retry nvm install 8.11.3
|
41
41
|
- node -v
|
42
|
-
- travis_retry npm i -g yarn
|
42
|
+
- travis_retry npm i -g yarn
|
43
43
|
- travis_retry yarn global add babel-cli
|
44
44
|
- travis_retry bundle install
|
45
45
|
- travis_retry yarn
|
data/CHANGELOG.md
CHANGED
@@ -9,13 +9,28 @@ See [Upgrading React on Rails](./docs/basics/upgrading-react-on-rails.md) for mo
|
|
9
9
|
Changes since last non-beta release.
|
10
10
|
|
11
11
|
*Please add entries here for your pull requests that are not yet released.*
|
12
|
+
### [11.0.9] - 2018-05-22
|
13
|
+
#### Fixed
|
14
|
+
- HashWithIndifferent access for props threw if used for props. [PR 1100](https://github.com/shakacode/react_on_rails/pull/1100) by [justin808](https://github.com/justin808).
|
15
|
+
- Test helper for detecting stale bundles did not properly handle the case of a server-bundle.js without a hash.[PR 1102](https://github.com/shakacode/react_on_rails/pull/1102) by [justin808](https://github.com/justin808).
|
16
|
+
|
17
|
+
### [11.0.8] - 2018-05-22
|
18
|
+
#### Fixed
|
19
|
+
- Fix test helper determination of stale assets. [PR 1093](https://github.com/shakacode/react_on_rails/pull/1093) by [justin808](https://github.com/justin808).
|
12
20
|
|
13
21
|
#### Changed
|
22
|
+
- Document how to manually rehydrate XHR-substituted components on client side. [PR 1095](https://github.com/shakacode/react_on_rails/pull/1095) by [hchevalier](https://github.com/hchevalier).
|
23
|
+
|
24
|
+
### [11.0.7] - 2018-05-11
|
25
|
+
#### Fixed
|
26
|
+
- Fix npm publshing. [PR 1090](https://github.com/shakacode/react_on_rails/pull/1090) by [justin808](https://github.com/justin808).
|
14
27
|
|
15
28
|
### [11.0.6] - 2018-05-11
|
29
|
+
#### Changed
|
16
30
|
- Even more detailed errors for Honeybadger and Sentry when there's a JSON parse error on server rendering. [PR 1086](https://github.com/shakacode/react_on_rails/pull/1086) by [justin808](https://github.com/justin808).
|
17
31
|
|
18
32
|
### [11.0.5] - 2018-05-11
|
33
|
+
#### Changed
|
19
34
|
- More detailed errors for Honeybadger and Sentry. [PR 1081](https://github.com/shakacode/react_on_rails/pull/1081) by [justin808](https://github.com/justin808).
|
20
35
|
|
21
36
|
### [11.0.4] - 2018-05-3
|
@@ -761,7 +776,10 @@ Best done with Object destructing:
|
|
761
776
|
##### Fixed
|
762
777
|
- Fix several generator related issues.
|
763
778
|
|
764
|
-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.0.
|
779
|
+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/11.0.9...master
|
780
|
+
[11.0.8]: https://github.com/shakacode/react_on_rails/compare/11.0.8...11.0.9
|
781
|
+
[11.0.8]: https://github.com/shakacode/react_on_rails/compare/11.0.7...11.0.8
|
782
|
+
[11.0.7]: https://github.com/shakacode/react_on_rails/compare/11.0.6...11.0.7
|
765
783
|
[11.0.6]: https://github.com/shakacode/react_on_rails/compare/11.0.5...11.0.6
|
766
784
|
[11.0.5]: https://github.com/shakacode/react_on_rails/compare/11.0.4...11.0.5
|
767
785
|
[11.0.4]: https://github.com/shakacode/react_on_rails/compare/11.0.3...11.0.4
|
data/README.md
CHANGED
@@ -2,19 +2,29 @@
|
|
2
2
|
|
3
3
|
*If this projects helps you, please give us a star!*
|
4
4
|
|
5
|
-
##
|
5
|
+
## React on Rails Pro Released!
|
6
|
+
React on Rails Pro provides Node server rendering and other performance enhancements for React on Rails. It's live at [egghead.io](https://egghead.io). See the [React on Rails Pro Docs](https://github.com/shakacode/react_on_rails/wiki).
|
7
|
+
|
6
8
|
Aloha, I'm Justin Gordon the creator and maintainer of React on Rails. I offer a [React on Rails Pro Support Plan](http://www.shakacode.com/work/shakacode-pro-support.pdf), and I can help you with:
|
7
9
|
* Optimizing your webpack setup to Webpack v4 for React on Rails.
|
8
10
|
* Upgrading from older React on Rails to newer versions (are using using the new Webpacker setup that avoids the asset pipeline?)
|
9
11
|
* Better performance client and server side.
|
10
12
|
* Efficiently migrating from Angular to React.
|
11
13
|
* Best practices based on 4 years of React on Rails experience.
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
|
15
|
+
From Kyle Maune of Cooper Aerial, May 4, 2018
|
16
|
+
|
17
|
+

|
18
|
+
|
19
|
+
From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
|
20
|
+
|
21
|
+

|
15
22
|
|
16
23
|
Please [email me](mailto:justin@shakacode.com) for a free half-hour project consultation, on anything from React on Rails to any aspect of web development.
|
17
24
|
|
25
|
+
For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
|
26
|
+
|
27
|
+
|
18
28
|
----
|
19
29
|
|
20
30
|
## React on Rails is based on Webpacker!
|
@@ -69,15 +79,6 @@ Please [**click to subscribe**](https://app.mailerlite.com/webforms/landing/l1d9
|
|
69
79
|
* See [Projects](PROJECTS.md) using and [KUDOS](./KUDOS.md) for React on Rails. Please submit yours! Please edit either page or [email us](mailto:contact@shakacode.com) and we'll add your info. We also **love stars** as it helps us attract new users and contributors.
|
70
80
|
* *See [NEWS.md](NEWS.md) for more notes over time.*
|
71
81
|
|
72
|
-
------
|
73
|
-
|
74
|
-
# Testimonials
|
75
|
-
From Joel Hooks, Co-Founder, Chief Nerd at [egghead.io](https://egghead.io/), January 30, 2017:
|
76
|
-
|
77
|
-

|
78
|
-
|
79
|
-
For more testimonials, see [Live Projects](PROJECTS.md) and [Kudos](./KUDOS.md).
|
80
|
-
|
81
82
|
-------
|
82
83
|
|
83
84
|
# Articles, Videos, and Podcasts
|
@@ -540,7 +541,10 @@ All options except `props, id, html_options` will inherit from your `react_on_ra
|
|
540
541
|
+ **replay_console:** Default is true. False will disable echoing server-rendering logs to the browser. While this can make troubleshooting server rendering difficult, so long as you have the configuration of `logging_on_server` set to true, you'll still see the errors on the server.
|
541
542
|
+ **logging_on_server:** Default is true. True will log JS console messages and errors to the server.
|
542
543
|
+ **raise_on_prerender_error:** Default is false. True will throw an error on the server side rendering. Your controller will have to handle the error.
|
543
|
-
|
544
|
+
|
545
|
+
Note: client hydration will not trigger for components rendered through XHR. You will have to handle it with javascript.
|
546
|
+
For an example, see [spec/dummy/app/views/pages/xhr_refresh.rb](https://github.com/shakacode/react_on_rails/tree/master/spec/dummy/app/views/pages/xhr_refresh.rb).
|
547
|
+
|
544
548
|
### react_component_hash
|
545
549
|
`react_component_hash` is used to return multiple HTML strings for server rendering, such as for
|
546
550
|
adding meta-tags to a page. It is exactly like react_component except for the following:
|
@@ -32,3 +32,10 @@ This is necessary because React on Rails attaches itself to the rake assets:prec
|
|
32
32
|
Requiring `react_on_rails` and including the helper will get rid of any issues where react on rails or react_component is undefined.
|
33
33
|
|
34
34
|
As far as solving the assets issue, `lib/tasks/assets.rake` in `react_on_rails` would somehow have to know that `react_on_rails` was included in an engine, and decide the path accordingly. This might be impossible, especially in the case of multiple engines using `react_on_rails` in a single application. Another solution would be to detach this rake task from the rails assets:precompile task, and let people use it separately.
|
35
|
+
|
36
|
+
# Github Issues
|
37
|
+
|
38
|
+
* [Integration with an engine #342](https://github.com/shakacode/react_on_rails/issues/342)
|
39
|
+
* [Feature: target destination option for the install generator #459](https://github.com/shakacode/react_on_rails/issues/459)
|
40
|
+
* [Integration with Rails 5 Engines #562](https://github.com/shakacode/react_on_rails/issues/562)
|
41
|
+
* [Run inside a Rails engine? #257](https://github.com/shakacode/react_on_rails/issues/257)
|
@@ -37,7 +37,13 @@ The following `config/react_on_rails.rb` settings **must** match your setup:
|
|
37
37
|
|
38
38
|
# Define the files we need to check for webpack compilation when running tests.
|
39
39
|
# Generally, the manifest.json is good enough for this check if using webpacker
|
40
|
-
config.webpack_generated_files = %w(
|
40
|
+
config.webpack_generated_files = %w( manifest.json )
|
41
|
+
|
42
|
+
# OR if you're not hashing the server-bundle.js, then you should include your server-bundle.js in the list.
|
43
|
+
# config.webpack_generated_files = %w( server-bundle.js manifest.json )
|
44
|
+
|
45
|
+
# OR if you're not using webpacker, your setup might look like.
|
46
|
+
# config.webpack_generated_files = %w( client-bundle.js server-bundle.js )
|
41
47
|
|
42
48
|
# If you are using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
|
43
49
|
# with rspec then this controls what yarn command is run
|
@@ -58,8 +58,10 @@ ReactOnRails.configure do |config|
|
|
58
58
|
|
59
59
|
# Define the files we need to check for webpack compilation when running tests.
|
60
60
|
# The default is `%w( manifest.json )` as will be sufficient for most webpacker builds.
|
61
|
+
# However, if you are generated a server bundle that is NOT hashed (present in manifest.json),
|
62
|
+
# then include the file in this list like this:
|
61
63
|
#
|
62
|
-
config.webpack_generated_files = %w( manifest.json )
|
64
|
+
config.webpack_generated_files = %w( server-bundle.js manifest.json )
|
63
65
|
|
64
66
|
# You can optionally add values to your rails_context. See example below for RenderingExtension
|
65
67
|
# config.rendering_extension = RenderingExtension
|
@@ -75,8 +77,10 @@ ReactOnRails.configure do |config|
|
|
75
77
|
# JavaScript execution instances which should handle any component requested.
|
76
78
|
#
|
77
79
|
# While you may configure this to be the same as your client bundle file, this file is typically
|
78
|
-
# different.
|
79
|
-
#
|
80
|
+
# different. Note, be sure to include the exact file name with the ".js" if you are not hashing this file.
|
81
|
+
# If you are hashing this file (supposing you are using the same file for client rendering), then
|
82
|
+
#
|
83
|
+
# you should include a name that matches your bundle name in your webpack config.
|
80
84
|
config.server_bundle_js_file = "server-bundle.js"
|
81
85
|
|
82
86
|
# If set to true, this forces Rails to reload the server bundle if it is modified
|
@@ -25,10 +25,10 @@ Reason for doing this: This enables your webpack bundles to bypass the Rails ass
|
|
25
25
|
#### From version 7 or lower
|
26
26
|
|
27
27
|
##### ...while keeping your `client` directory
|
28
|
-
Unfortunately, this requires quite a few steps:
|
29
28
|
* `.gitignore`: add `/public/webpack/*`
|
30
29
|
* `Gemfile`: bump `react_on_rails` and add `webpacker`
|
31
|
-
* layout views: anything bundled by webpack will need to be requested by a `javascript_pack_tag` or `stylesheet_pack_tag
|
30
|
+
* layout views: anything bundled by webpack will need to be requested by a `javascript_pack_tag` or `stylesheet_pack_tag`.
|
31
|
+
* Search your codebase for javascript_include_tag. Use the
|
32
32
|
* `config/initializers/assets.rb`: we no longer need to modify `Rails.application.config.assets.paths` or append anything to `Rails.application.config.assets.precompile`.
|
33
33
|
* `config/initializers/react_on_rails.rb`:
|
34
34
|
* Delete `config.generated_assets_dir`. Webpacker's config now supplies this information
|
@@ -3,138 +3,13 @@
|
|
3
3
|
module ReactOnRails
|
4
4
|
def self.configure
|
5
5
|
yield(configuration)
|
6
|
-
setup_config_values
|
6
|
+
configuration.setup_config_values
|
7
7
|
end
|
8
8
|
|
9
9
|
DEFAULT_GENERATED_ASSETS_DIR = File.join(%w[public webpack], Rails.env).freeze
|
10
10
|
DEFAULT_SERVER_RENDER_TIMEOUT = 20
|
11
11
|
DEFAULT_POOL_SIZE = 1
|
12
12
|
|
13
|
-
def self.setup_config_values
|
14
|
-
ensure_webpack_generated_files_exists
|
15
|
-
configure_generated_assets_dirs_deprecation
|
16
|
-
configure_skip_display_none_deprecation
|
17
|
-
ensure_generated_assets_dir_present
|
18
|
-
ensure_server_bundle_js_file_has_no_path
|
19
|
-
check_i18n_directory_exists
|
20
|
-
check_i18n_yml_directory_exists
|
21
|
-
check_server_render_method_is_only_execjs
|
22
|
-
error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path
|
26
|
-
return unless ReactOnRails::WebpackerUtils.using_webpacker?
|
27
|
-
|
28
|
-
return if @configuration.generated_assets_dir.blank?
|
29
|
-
|
30
|
-
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
31
|
-
|
32
|
-
if File.expand_path(@configuration.generated_assets_dir) == webpacker_public_output_path.to_s
|
33
|
-
Rails.logger.warn("You specified /config/initializers/react_on_rails.rb generated_assets_dir "\
|
34
|
-
"with Webpacker. Remove this line from your configuration file.")
|
35
|
-
else
|
36
|
-
msg = <<-MSG.strip_heredoc
|
37
|
-
Error configuring /config/initializers/react_on_rails.rb: You are using webpacker
|
38
|
-
and your specified value for generated_assets_dir = #{@configuration.generated_assets_dir}
|
39
|
-
that does not match the value for public_output_path specified in
|
40
|
-
webpacker.yml = #{webpacker_public_output_path}. You should remove the configuration
|
41
|
-
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
|
42
|
-
MSG
|
43
|
-
raise ReactOnRails::Error, msg
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.check_server_render_method_is_only_execjs
|
48
|
-
return if @configuration.server_render_method.blank? ||
|
49
|
-
@configuration.server_render_method == "ExecJS"
|
50
|
-
|
51
|
-
msg = <<-MSG.strip_heredoc
|
52
|
-
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.server_render_method`.
|
53
|
-
If you wish to use a server render method other than ExecJS, contact justin@shakacode.com
|
54
|
-
for details.
|
55
|
-
MSG
|
56
|
-
raise ReactOnRails::Error, msg
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.check_i18n_directory_exists
|
60
|
-
return if @configuration.i18n_dir.nil?
|
61
|
-
return if Dir.exist?(@configuration.i18n_dir)
|
62
|
-
|
63
|
-
msg = <<-MSG.strip_heredoc
|
64
|
-
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.i18n_dir`.
|
65
|
-
Directory does not exist: #{@configuration.i18n_dir}. Set to value to nil or comment it
|
66
|
-
out if not using the React on Rails i18n feature.
|
67
|
-
MSG
|
68
|
-
raise ReactOnRails::Error, msg
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.check_i18n_yml_directory_exists
|
72
|
-
return if @configuration.i18n_yml_dir.nil?
|
73
|
-
return if Dir.exist?(@configuration.i18n_yml_dir)
|
74
|
-
|
75
|
-
msg = <<-MSG.strip_heredoc
|
76
|
-
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.i18n_yml_dir`.
|
77
|
-
Directory does not exist: #{@configuration.i18n_yml_dir}. Set to value to nil or comment it
|
78
|
-
out if not using this i18n with React on Rails, or if you want to use all translation files.
|
79
|
-
MSG
|
80
|
-
raise ReactOnRails::Error, msg
|
81
|
-
end
|
82
|
-
|
83
|
-
def self.ensure_generated_assets_dir_present
|
84
|
-
return if @configuration.generated_assets_dir.present? || ReactOnRails::WebpackerUtils.using_webpacker?
|
85
|
-
|
86
|
-
@configuration.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
|
87
|
-
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.configure_generated_assets_dirs_deprecation
|
91
|
-
return if @configuration.generated_assets_dirs.blank?
|
92
|
-
|
93
|
-
if ReactOnRails::WebpackerUtils.using_webpacker?
|
94
|
-
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
95
|
-
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the "\
|
96
|
-
"generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined by "\
|
97
|
-
"public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
|
98
|
-
return
|
99
|
-
end
|
100
|
-
|
101
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
|
102
|
-
"generated_assets_dirs"
|
103
|
-
if @configuration.generated_assets_dir.blank?
|
104
|
-
@configuration.generated_assets_dir = @configuration.generated_assets_dirs
|
105
|
-
else
|
106
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
|
107
|
-
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker"\
|
108
|
-
" and define neither if using Webpacker"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def self.ensure_webpack_generated_files_exists
|
113
|
-
return unless @configuration.webpack_generated_files.empty?
|
114
|
-
|
115
|
-
files = ["hello-world-bundle.js"]
|
116
|
-
files << @configuration.server_bundle_js_file if @configuration.server_bundle_js_file.present?
|
117
|
-
|
118
|
-
@configuration.webpack_generated_files = files
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.ensure_server_bundle_js_file_has_no_path
|
122
|
-
return unless @configuration.server_bundle_js_file.include?(File::SEPARATOR)
|
123
|
-
|
124
|
-
assets_dir = ReactOnRails::Utils.generated_assets_full_path
|
125
|
-
@configuration.server_bundle_js_file = File.basename(@configuration.server_bundle_js_file)
|
126
|
-
|
127
|
-
Rails.logger_warn do
|
128
|
-
"[DEPRECATION] ReactOnRails: remove path from server_bundle_js_file in configuration. "\
|
129
|
-
"All generated files must go in #{assets_dir}. Using file basename #{@configuration.server_bundle_js_file}"
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def self.configure_skip_display_none_deprecation
|
134
|
-
return if @configuration.skip_display_none.nil?
|
135
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails: remove skip_display_none from configuration."
|
136
|
-
end
|
137
|
-
|
138
13
|
def self.configuration
|
139
14
|
@configuration ||= Configuration.new(
|
140
15
|
node_modules_location: nil,
|
@@ -214,5 +89,133 @@ module ReactOnRails
|
|
214
89
|
self.server_render_method = server_render_method
|
215
90
|
self.symlink_non_digested_assets_regex = symlink_non_digested_assets_regex
|
216
91
|
end
|
92
|
+
|
93
|
+
# on ReactOnRails
|
94
|
+
def setup_config_values
|
95
|
+
ensure_webpack_generated_files_exists
|
96
|
+
configure_generated_assets_dirs_deprecation
|
97
|
+
configure_skip_display_none_deprecation
|
98
|
+
ensure_generated_assets_dir_present
|
99
|
+
ensure_server_bundle_js_file_has_no_path
|
100
|
+
check_i18n_directory_exists
|
101
|
+
check_i18n_yml_directory_exists
|
102
|
+
check_server_render_method_is_only_execjs
|
103
|
+
error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def error_if_using_webpacker_and_generated_assets_dir_not_match_public_output_path
|
109
|
+
return unless ReactOnRails::WebpackerUtils.using_webpacker?
|
110
|
+
|
111
|
+
return if generated_assets_dir.blank?
|
112
|
+
|
113
|
+
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
114
|
+
|
115
|
+
if File.expand_path(generated_assets_dir) == webpacker_public_output_path.to_s
|
116
|
+
Rails.logger.warn("You specified /config/initializers/react_on_rails.rb generated_assets_dir "\
|
117
|
+
"with Webpacker. Remove this line from your configuration file.")
|
118
|
+
else
|
119
|
+
msg = <<-MSG.strip_heredoc
|
120
|
+
Error configuring /config/initializers/react_on_rails.rb: You are using webpacker
|
121
|
+
and your specified value for generated_assets_dir = #{generated_assets_dir}
|
122
|
+
that does not match the value for public_output_path specified in
|
123
|
+
webpacker.yml = #{webpacker_public_output_path}. You should remove the configuration
|
124
|
+
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
|
125
|
+
MSG
|
126
|
+
raise ReactOnRails::Error, msg
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def check_server_render_method_is_only_execjs
|
131
|
+
return if server_render_method.blank? ||
|
132
|
+
server_render_method == "ExecJS"
|
133
|
+
|
134
|
+
msg = <<-MSG.strip_heredoc
|
135
|
+
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.server_render_method`.
|
136
|
+
If you wish to use a server render method other than ExecJS, contact justin@shakacode.com
|
137
|
+
for details.
|
138
|
+
MSG
|
139
|
+
raise ReactOnRails::Error, msg
|
140
|
+
end
|
141
|
+
|
142
|
+
def check_i18n_directory_exists
|
143
|
+
return if i18n_dir.nil?
|
144
|
+
return if Dir.exist?(i18n_dir)
|
145
|
+
|
146
|
+
msg = <<-MSG.strip_heredoc
|
147
|
+
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.i18n_dir`.
|
148
|
+
Directory does not exist: #{i18n_dir}. Set to value to nil or comment it
|
149
|
+
out if not using the React on Rails i18n feature.
|
150
|
+
MSG
|
151
|
+
raise ReactOnRails::Error, msg
|
152
|
+
end
|
153
|
+
|
154
|
+
def check_i18n_yml_directory_exists
|
155
|
+
return if i18n_yml_dir.nil?
|
156
|
+
return if Dir.exist?(i18n_yml_dir)
|
157
|
+
|
158
|
+
msg = <<-MSG.strip_heredoc
|
159
|
+
Error configuring /config/initializers/react_on_rails.rb: invalid value for `config.i18n_yml_dir`.
|
160
|
+
Directory does not exist: #{i18n_yml_dir}. Set to value to nil or comment it
|
161
|
+
out if not using this i18n with React on Rails, or if you want to use all translation files.
|
162
|
+
MSG
|
163
|
+
raise ReactOnRails::Error, msg
|
164
|
+
end
|
165
|
+
|
166
|
+
def ensure_generated_assets_dir_present
|
167
|
+
return if generated_assets_dir.present? || ReactOnRails::WebpackerUtils.using_webpacker?
|
168
|
+
|
169
|
+
self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
|
170
|
+
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
|
171
|
+
end
|
172
|
+
|
173
|
+
def configure_generated_assets_dirs_deprecation
|
174
|
+
return if generated_assets_dirs.blank?
|
175
|
+
|
176
|
+
if ReactOnRails::WebpackerUtils.using_webpacker?
|
177
|
+
webpacker_public_output_path = ReactOnRails::WebpackerUtils.webpacker_public_output_path
|
178
|
+
Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the "\
|
179
|
+
"generated_assets_dirs no the generated_assets_dir when using Webpacker. This is defined by "\
|
180
|
+
"public_output_path specified in webpacker.yml = #{webpacker_public_output_path}."
|
181
|
+
return
|
182
|
+
end
|
183
|
+
|
184
|
+
Rails.logger.warn "[DEPRECATION] ReactOnRails: Use config.generated_assets_dir rather than "\
|
185
|
+
"generated_assets_dirs"
|
186
|
+
if generated_assets_dir.blank?
|
187
|
+
self.generated_assets_dir = generated_assets_dirs
|
188
|
+
else
|
189
|
+
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and "\
|
190
|
+
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Webpacker"\
|
191
|
+
" and define neither if using Webpacker"
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def ensure_webpack_generated_files_exists
|
196
|
+
return unless webpack_generated_files.empty?
|
197
|
+
|
198
|
+
files = ["hello-world-bundle.js"]
|
199
|
+
files << server_bundle_js_file if server_bundle_js_file.present?
|
200
|
+
|
201
|
+
self.webpack_generated_files = files
|
202
|
+
end
|
203
|
+
|
204
|
+
def ensure_server_bundle_js_file_has_no_path
|
205
|
+
return unless server_bundle_js_file.include?(File::SEPARATOR)
|
206
|
+
|
207
|
+
assets_dir = ReactOnRails::Utils.generated_assets_full_path
|
208
|
+
self.server_bundle_js_file = File.basename(server_bundle_js_file)
|
209
|
+
|
210
|
+
Rails.logger_warn do
|
211
|
+
"[DEPRECATION] ReactOnRails: remove path from server_bundle_js_file in configuration. "\
|
212
|
+
"All generated files must go in #{assets_dir}. Using file basename #{server_bundle_js_file}"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def configure_skip_display_none_deprecation
|
217
|
+
return if skip_display_none.nil?
|
218
|
+
Rails.logger.warn "[DEPRECATION] ReactOnRails: remove skip_display_none from configuration."
|
219
|
+
end
|
217
220
|
end
|
218
221
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# rubocop:disable: Layout/IndentHeredoc
|
4
4
|
module ReactOnRails
|
5
5
|
class PrerenderError < ::ReactOnRails::Error
|
6
|
+
# TODO: Consider remove providing original `err` as already have access to `self.cause`
|
7
|
+
# http://blog.honeybadger.io/nested-errors-in-ruby-with-exception-cause/
|
6
8
|
attr_reader :component_name, :err, :props, :js_code, :console_messages
|
7
9
|
|
8
10
|
# err might be nil if JS caught the error
|
@@ -264,7 +264,7 @@ module ReactOnRails
|
|
264
264
|
|
265
265
|
def json_safe_and_pretty(hash_or_string)
|
266
266
|
return "{}" if hash_or_string.nil?
|
267
|
-
unless hash_or_string.
|
267
|
+
unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
|
268
268
|
raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument "\
|
269
269
|
"(#{hash_or_string.class} given)."
|
270
270
|
end
|
@@ -53,7 +53,11 @@ module ReactOnRails
|
|
53
53
|
def all_compiled_assets
|
54
54
|
@all_compiled_assets ||= begin
|
55
55
|
webpack_generated_files = @webpack_generated_files.map do |bundle_name|
|
56
|
-
ReactOnRails
|
56
|
+
if bundle_name == ReactOnRails.configuration.server_bundle_js_file
|
57
|
+
ReactOnRails::Utils.server_bundle_js_file_path
|
58
|
+
else
|
59
|
+
ReactOnRails::Utils.bundle_js_file_path(bundle_name)
|
60
|
+
end
|
57
61
|
end
|
58
62
|
|
59
63
|
if webpack_generated_files.present?
|
data/lib/react_on_rails/utils.rb
CHANGED
@@ -76,8 +76,10 @@ exitstatus: #{status.exitstatus}#{stdout_msg}#{stderr_msg}
|
|
76
76
|
begin
|
77
77
|
bundle_js_file_path(bundle_name)
|
78
78
|
rescue Webpacker::Manifest::MissingEntryError
|
79
|
-
File.
|
80
|
-
|
79
|
+
File.expand_path(
|
80
|
+
File.join(ReactOnRails::WebpackerUtils.webpacker_public_output_path,
|
81
|
+
bundle_name)
|
82
|
+
)
|
81
83
|
end
|
82
84
|
else
|
83
85
|
bundle_js_file_path(bundle_name)
|
@@ -2,19 +2,21 @@
|
|
2
2
|
|
3
3
|
require_relative "version"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module ReactOnRails
|
6
|
+
class VersionSyntaxConverter
|
7
|
+
def rubygem_to_npm(rubygem_version = ReactOnRails::VERSION)
|
8
|
+
regex_match = rubygem_version.match(/(\d+\.\d+\.\d+)[.\-]?(.+)?/)
|
9
|
+
return "#{regex_match[1]}-#{regex_match[2]}" if regex_match[2]
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
regex_match[1].to_s
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def npm_to_rubygem(npm_version)
|
15
|
+
match = npm_version
|
16
|
+
.tr("-", ".")
|
17
|
+
.strip
|
18
|
+
.match(/(\d.*)/)
|
19
|
+
match.present? ? match[0] : nil
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
@@ -8,12 +8,12 @@ module ReactOnRails
|
|
8
8
|
# Note Webpacker 3.4.3 manifest lookup is inside of the public_output_path
|
9
9
|
# [2] (pry) ReactOnRails::WebpackerUtils: 0> Webpacker.manifest.lookup("app-bundle.js")
|
10
10
|
# "/webpack/development/app-bundle-c1d2b6ab73dffa7d9c0e.js"
|
11
|
+
# Next line will throw if the file or manifest does not exist
|
11
12
|
hashed_bundle_name = Webpacker.manifest.lookup!(bundle_name)
|
12
13
|
|
13
14
|
if Webpacker.dev_server.running?
|
14
15
|
"#{Webpacker.dev_server.protocol}://#{Webpacker.dev_server.host_with_port}#{hashed_bundle_name}"
|
15
16
|
else
|
16
|
-
# Next line will throw if the file or manifest does not exist
|
17
17
|
File.expand_path(File.join("public", hashed_bundle_name)).to_s
|
18
18
|
end
|
19
19
|
end
|
@@ -23,7 +23,7 @@ module ReactOnRails
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.webpacker_public_output_path
|
26
|
-
# Webpacker has the full absolute path of webpacker output files in a
|
26
|
+
# Webpacker has the full absolute path of webpacker output files in a Pathname
|
27
27
|
Webpacker.config.public_output_path.to_s
|
28
28
|
end
|
29
29
|
|
data/package.json
CHANGED
data/rakelib/release.rake
CHANGED
@@ -41,7 +41,7 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
|
|
41
41
|
npm_version = if gem_version.strip.empty?
|
42
42
|
""
|
43
43
|
else
|
44
|
-
VersionSyntaxConverter.new.rubygem_to_npm(gem_version)
|
44
|
+
ReactOnRails::VersionSyntaxConverter.new.rubygem_to_npm(gem_version)
|
45
45
|
end
|
46
46
|
|
47
47
|
# Having the examples prevents publishing
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_on_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 11.0.
|
4
|
+
version: 11.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -498,7 +498,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
498
498
|
version: '0'
|
499
499
|
requirements: []
|
500
500
|
rubyforge_project:
|
501
|
-
rubygems_version: 2.
|
501
|
+
rubygems_version: 2.7.7
|
502
502
|
signing_key:
|
503
503
|
specification_version: 4
|
504
504
|
summary: Rails with react server rendering with webpack.
|