react_on_rails 10.0.0 → 11.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/.eslintrc +4 -0
- data/.rubocop.yml +2 -2
- data/.travis.yml +3 -0
- data/CHANGELOG.md +81 -88
- data/CONTRIBUTING.md +0 -7
- data/Dockerfile_tests +12 -0
- data/Gemfile +8 -13
- data/NEWS.md +2 -0
- data/PROJECTS.md +10 -2
- data/README.md +137 -121
- data/app/helpers/react_on_rails_helper.rb +1 -533
- data/docker-compose.yml +11 -0
- data/docs/additional-reading/caching-and-performance.md +4 -0
- data/docs/additional-reading/capistrano-deployment.md +18 -0
- data/docs/additional-reading/elastic-beanstalk.md +53 -33
- data/docs/additional-reading/server-rendering-tips.md +4 -4
- data/docs/additional-reading/troubleshooting-when-using-webpacker.md +90 -0
- data/docs/api/ruby-api.md +7 -2
- data/docs/basics/configuration.md +23 -9
- data/docs/basics/i18n.md +4 -0
- data/docs/basics/upgrading-react-on-rails.md +181 -0
- data/docs/tutorial.md +7 -11
- data/lib/generators/react_on_rails/base_generator.rb +6 -3
- data/lib/generators/react_on_rails/dev_tests_generator.rb +1 -1
- data/lib/generators/react_on_rails/install_generator.rb +1 -1
- data/lib/generators/react_on_rails/react_no_redux_generator.rb +1 -1
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +2 -2
- data/lib/generators/react_on_rails/templates/base/base/app/javascript/bundles/HelloWorld/components/HelloWorld.jsx +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +3 -2
- data/lib/generators/react_on_rails/templates/dev_tests/spec/simplecov_helper.rb +2 -2
- data/lib/react_on_rails/assets_precompile.rb +8 -4
- data/lib/react_on_rails/configuration.rb +34 -20
- data/lib/react_on_rails/error.rb +4 -0
- data/lib/react_on_rails/locales_to_js.rb +2 -2
- data/lib/react_on_rails/prerender_error.rb +2 -2
- data/lib/react_on_rails/react_on_rails_helper.rb +547 -0
- data/lib/react_on_rails/server_rendering_pool/{exec.rb → ruby_embedded_java_script.rb} +37 -40
- data/lib/react_on_rails/server_rendering_pool.rb +21 -10
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +2 -2
- data/lib/react_on_rails/test_helper.rb +1 -1
- data/lib/react_on_rails/utils.rb +14 -52
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +33 -12
- data/lib/react_on_rails/webpacker_utils.rb +42 -0
- data/lib/react_on_rails.rb +3 -2
- data/package.json +2 -5
- data/rakelib/dummy_apps.rake +2 -1
- data/rakelib/example_type.rb +1 -1
- data/rakelib/examples.rake +3 -2
- data/rakelib/lint.rake +3 -2
- data/rakelib/node_package.rake +2 -1
- data/rakelib/release.rake +4 -5
- data/rakelib/run_rspec.rake +3 -4
- data/rakelib/task_helpers.rb +1 -1
- data/react_on_rails.gemspec +23 -13
- data/yarn.lock +3 -39
- metadata +75 -49
- data/lib/react_on_rails/server_rendering_pool/node.rb +0 -83
- data/lib/react_on_rails/test_helper/node_process_launcher.rb +0 -14
|
@@ -18,24 +18,43 @@ module ReactOnRails
|
|
|
18
18
|
ensure_server_bundle_js_file_has_no_path
|
|
19
19
|
check_i18n_directory_exists
|
|
20
20
|
check_i18n_yml_directory_exists
|
|
21
|
+
check_server_render_method_is_only_execjs
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.check_server_render_method_is_only_execjs
|
|
25
|
+
return if @configuration.server_render_method.blank? ||
|
|
26
|
+
@configuration.server_render_method == "ExecJS"
|
|
27
|
+
|
|
28
|
+
msg = <<-MSG.strip_heredoc
|
|
29
|
+
Error configuring /config/react_on_rails.rb: invalid value for `config.server_render_method`.
|
|
30
|
+
If you wish to use a server render method other than ExecJS, contact justin@shakacode.com
|
|
31
|
+
for details.
|
|
32
|
+
MSG
|
|
33
|
+
raise ReactOnRails::Error, msg
|
|
21
34
|
end
|
|
22
35
|
|
|
23
36
|
def self.check_i18n_directory_exists
|
|
24
|
-
return if @configuration.i18n_dir.
|
|
37
|
+
return if @configuration.i18n_dir.nil?
|
|
25
38
|
return if Dir.exist?(@configuration.i18n_dir)
|
|
26
39
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
msg = <<-MSG.strip_heredoc
|
|
41
|
+
Error configuring /config/react_on_rails.rb: invalid value for `config.i18n_dir`.
|
|
42
|
+
Directory does not exist: #{@configuration.i18n_dir}. Set to value to nil or comment it
|
|
43
|
+
out if not using the React on Rails i18n feature.
|
|
44
|
+
MSG
|
|
45
|
+
raise ReactOnRails::Error, msg
|
|
30
46
|
end
|
|
31
47
|
|
|
32
48
|
def self.check_i18n_yml_directory_exists
|
|
33
|
-
return if @configuration.i18n_yml_dir.
|
|
49
|
+
return if @configuration.i18n_yml_dir.nil?
|
|
34
50
|
return if Dir.exist?(@configuration.i18n_yml_dir)
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
msg = <<-MSG.strip_heredoc
|
|
53
|
+
Error configuring /config/react_on_rails.rb: invalid value for `config.i18n_yml_dir`.
|
|
54
|
+
Directory does not exist: #{@configuration.i18n_yml_dir}. Set to value to nil or comment it
|
|
55
|
+
out if not using this i18n with React on Rails, or if you want to use all translation files.
|
|
56
|
+
MSG
|
|
57
|
+
raise ReactOnRails::Error, msg
|
|
39
58
|
end
|
|
40
59
|
|
|
41
60
|
def self.ensure_generated_assets_dir_present
|
|
@@ -62,9 +81,8 @@ module ReactOnRails
|
|
|
62
81
|
return unless @configuration.webpack_generated_files.empty?
|
|
63
82
|
|
|
64
83
|
files = ["hello-world-bundle.js"]
|
|
65
|
-
if @configuration.server_bundle_js_file.present?
|
|
66
|
-
|
|
67
|
-
end
|
|
84
|
+
files << @configuration.server_bundle_js_file if @configuration.server_bundle_js_file.present?
|
|
85
|
+
|
|
68
86
|
@configuration.webpack_generated_files = files
|
|
69
87
|
end
|
|
70
88
|
|
|
@@ -83,9 +101,8 @@ module ReactOnRails
|
|
|
83
101
|
|
|
84
102
|
def self.configuration
|
|
85
103
|
@configuration ||= Configuration.new(
|
|
86
|
-
node_modules_location:
|
|
104
|
+
node_modules_location: nil,
|
|
87
105
|
generated_assets_dirs: nil,
|
|
88
|
-
|
|
89
106
|
# generated_assets_dirs is deprecated
|
|
90
107
|
generated_assets_dir: "",
|
|
91
108
|
server_bundle_js_file: "",
|
|
@@ -98,15 +115,12 @@ module ReactOnRails
|
|
|
98
115
|
server_renderer_pool_size: 1,
|
|
99
116
|
server_renderer_timeout: 20,
|
|
100
117
|
skip_display_none: nil,
|
|
101
|
-
|
|
102
118
|
# skip_display_none is deprecated
|
|
103
119
|
webpack_generated_files: %w[manifest.json],
|
|
104
120
|
rendering_extension: nil,
|
|
105
|
-
server_render_method:
|
|
121
|
+
server_render_method: nil,
|
|
106
122
|
symlink_non_digested_assets_regex: nil,
|
|
107
123
|
build_test_command: "",
|
|
108
|
-
i18n_dir: "",
|
|
109
|
-
i18n_yml_dir: "",
|
|
110
124
|
build_production_command: ""
|
|
111
125
|
)
|
|
112
126
|
end
|
|
@@ -122,7 +136,7 @@ module ReactOnRails
|
|
|
122
136
|
:i18n_dir, :i18n_yml_dir,
|
|
123
137
|
:server_render_method, :symlink_non_digested_assets_regex
|
|
124
138
|
|
|
125
|
-
def initialize(node_modules_location:
|
|
139
|
+
def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
|
|
126
140
|
replay_console: nil,
|
|
127
141
|
trace: nil, development_mode: nil,
|
|
128
142
|
logging_on_server: nil, server_renderer_pool_size: nil,
|
|
@@ -132,8 +146,8 @@ module ReactOnRails
|
|
|
132
146
|
rendering_extension: nil, build_test_command: nil,
|
|
133
147
|
build_production_command: nil,
|
|
134
148
|
i18n_dir: nil, i18n_yml_dir: nil,
|
|
135
|
-
server_render_method:
|
|
136
|
-
self.node_modules_location = node_modules_location
|
|
149
|
+
server_render_method: nil, symlink_non_digested_assets_regex: nil)
|
|
150
|
+
self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
|
|
137
151
|
self.server_bundle_js_file = server_bundle_js_file
|
|
138
152
|
self.generated_assets_dirs = generated_assets_dirs
|
|
139
153
|
self.generated_assets_dir = generated_assets_dir
|
|
@@ -5,7 +5,7 @@ require "erb"
|
|
|
5
5
|
module ReactOnRails
|
|
6
6
|
class LocalesToJs
|
|
7
7
|
def initialize
|
|
8
|
-
return if i18n_dir.
|
|
8
|
+
return if i18n_dir.nil?
|
|
9
9
|
return unless obsolete?
|
|
10
10
|
@translations, @defaults = generate_translations
|
|
11
11
|
convert
|
|
@@ -108,7 +108,7 @@ module ReactOnRails
|
|
|
108
108
|
if v.is_a? Hash
|
|
109
109
|
flatten(v).map { |hk, hv| h["#{k}.#{hk}".to_sym] = hv }
|
|
110
110
|
else
|
|
111
|
-
h[k] = v
|
|
111
|
+
h[k] = v.gsub("%{", "{")
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
end
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
# rubocop:disable: Layout/IndentHeredoc
|
|
4
4
|
module ReactOnRails
|
|
5
|
-
class PrerenderError <
|
|
5
|
+
class PrerenderError < StandardError
|
|
6
6
|
# err might be nil if JS caught the error
|
|
7
7
|
def initialize(component_name: nil, err: nil, props: nil,
|
|
8
8
|
js_code: nil, console_messages: nil)
|
|
9
|
-
message = "ERROR in SERVER PRERENDERING\n".dup
|
|
9
|
+
message = "ERROR in SERVER PRERENDERING\n".dup
|
|
10
10
|
if err
|
|
11
11
|
# rubocop:disable Layout/IndentHeredoc
|
|
12
12
|
message << <<-MSG
|