react_on_rails 13.0.0.beta.0 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/generators/react_on_rails/base_generator.rb +1 -0
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +0 -2
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +0 -2
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +6 -0
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpack.config.js.tt +2 -2
- data/lib/react_on_rails/helper.rb +15 -14
- data/lib/react_on_rails/json_parse_error.rb +1 -1
- data/lib/react_on_rails/prerender_error.rb +5 -2
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +19 -4
- data/lib/react_on_rails/version.rb +1 -1
- data/package.json +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0c8e1ea64a37bf952902b50d8336916e2d579f8a2e4f04e2467bd750d8418d7
|
4
|
+
data.tar.gz: 388204125e919bb352bb14df64ab67549459c2f63c416e6dc98de39daccf2395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b59cea6f171d0734b118238b2b7cc1b6cf7573ea47e77716f4175d9fc69dc896d175cc331c064f6dad563cbe5a8474e81ae55568b455e152f7674b15e1670961
|
7
|
+
data.tar.gz: 1f7a8895a3f90eff53089451c79a27bc920ac4488bb9475bdd46373b467e10ca6d8ebe445e715cdb86e50590b27da9a9ca99aa455c724be3cd85a83f8065701d
|
data/CHANGELOG.md
CHANGED
@@ -16,6 +16,13 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
|
|
16
16
|
Changes since last non-beta release.
|
17
17
|
|
18
18
|
*Please add entries here for your pull requests that are not yet released.*
|
19
|
+
### [13.0.0] - 2022-02-08
|
20
|
+
#### Breaking
|
21
|
+
- Removed webpacker as a dependency. Add gem Shakapacker to your project.
|
22
|
+
|
23
|
+
#### Fixed
|
24
|
+
- Propper throwing of exceptions.
|
25
|
+
- Default configuration better handles test env.
|
19
26
|
|
20
27
|
### [12.6.0] - 2022-01-22
|
21
28
|
|
@@ -51,6 +51,7 @@ module ReactOnRails
|
|
51
51
|
base_files = %w[babel.config.js
|
52
52
|
config/webpack/clientWebpackConfig.js
|
53
53
|
config/webpack/commonWebpackConfig.js
|
54
|
+
config/webpack/test.js
|
54
55
|
config/webpack/development.js
|
55
56
|
config/webpack/production.js
|
56
57
|
config/webpack/serverWebpackConfig.js
|
@@ -1,7 +1,5 @@
|
|
1
1
|
<%= add_documentation_reference(config[:message], "// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/development.js") %>
|
2
2
|
|
3
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
4
|
-
|
5
3
|
const { devServer, inliningCss } = require('shakapacker');
|
6
4
|
|
7
5
|
const webpackConfig = require('./webpackConfig');
|
@@ -1,7 +1,5 @@
|
|
1
1
|
<%= add_documentation_reference(config[:message], "// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/production.js") %>
|
2
2
|
|
3
|
-
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
|
4
|
-
|
5
3
|
const webpackConfig = require('./webpackConfig');
|
6
4
|
|
7
5
|
const productionEnvOnly = (_clientWebpackConfig, _serverWebpackConfig) => {
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<%= add_documentation_reference(config[:message], "// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/development.js") %>
|
2
|
+
|
3
|
+
// Use dev
|
4
|
+
const config = require('./development');
|
5
|
+
|
6
|
+
module.exports = config;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const { env
|
1
|
+
const { env } = require('shakapacker')
|
2
2
|
const { existsSync } = require('fs')
|
3
3
|
const { resolve } = require('path')
|
4
4
|
|
@@ -8,7 +8,7 @@ const envSpecificConfig = () => {
|
|
8
8
|
console.log(`Loading ENV specific webpack configuration file ${path}`)
|
9
9
|
return require(path)
|
10
10
|
} else {
|
11
|
-
|
11
|
+
throw new Error(`Could not find file to load ${path}, based on NODE_ENV`)
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
@@ -234,9 +234,9 @@ module ReactOnRails
|
|
234
234
|
console_log_script = result["consoleLogScript"]
|
235
235
|
raw("#{html}#{render_options.replay_console ? console_log_script : ''}")
|
236
236
|
rescue ExecJS::ProgramError => err
|
237
|
-
raise ReactOnRails::PrerenderError
|
238
|
-
|
239
|
-
|
237
|
+
raise ReactOnRails::PrerenderError.new(component_name: "N/A (server_render_js called)",
|
238
|
+
err: err,
|
239
|
+
js_code: js_code)
|
240
240
|
end
|
241
241
|
|
242
242
|
def json_safe_and_pretty(hash_or_string)
|
@@ -309,6 +309,7 @@ module ReactOnRails
|
|
309
309
|
|
310
310
|
@rails_context.merge(serverSide: server_side)
|
311
311
|
end
|
312
|
+
|
312
313
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
313
314
|
|
314
315
|
private
|
@@ -483,21 +484,21 @@ module ReactOnRails
|
|
483
484
|
result = ReactOnRails::ServerRenderingPool.server_render_js_with_console_logging(js_code, render_options)
|
484
485
|
rescue StandardError => err
|
485
486
|
# This error came from the renderer
|
486
|
-
raise ReactOnRails::PrerenderError
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
487
|
+
raise ReactOnRails::PrerenderError.new(component_name: react_component_name,
|
488
|
+
# Sanitize as this might be browser logged
|
489
|
+
props: sanitized_props_string(props),
|
490
|
+
err: err,
|
491
|
+
js_code: js_code)
|
491
492
|
end
|
492
493
|
|
493
494
|
if result["hasErrors"] && render_options.raise_on_prerender_error
|
494
495
|
# We caught this exception on our backtrace handler
|
495
|
-
raise ReactOnRails::PrerenderError
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
496
|
+
raise ReactOnRails::PrerenderError.new(component_name: react_component_name,
|
497
|
+
# Sanitize as this might be browser logged
|
498
|
+
props: sanitized_props_string(props),
|
499
|
+
err: nil,
|
500
|
+
js_code: js_code,
|
501
|
+
console_messages: result["consoleReplayScript"])
|
501
502
|
|
502
503
|
end
|
503
504
|
result
|
@@ -49,10 +49,13 @@ module ReactOnRails
|
|
49
49
|
message = +"ERROR in SERVER PRERENDERING\n"
|
50
50
|
if err
|
51
51
|
message << <<~MSG
|
52
|
-
Encountered error:
|
52
|
+
Encountered error:
|
53
|
+
|
54
|
+
#{err}
|
55
|
+
|
53
56
|
MSG
|
54
57
|
|
55
|
-
backtrace = err.backtrace.join("\n")
|
58
|
+
backtrace = err.backtrace.first(15).join("\n")
|
56
59
|
else
|
57
60
|
backtrace = nil
|
58
61
|
end
|
@@ -47,7 +47,7 @@ module ReactOnRails
|
|
47
47
|
# Note, js_code does not have to be based on React.
|
48
48
|
# js_code MUST RETURN json stringify Object
|
49
49
|
# Calling code will probably call 'html_safe' on return value before rendering to the view.
|
50
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
50
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
51
51
|
def exec_server_render_js(js_code, render_options, js_evaluator = nil)
|
52
52
|
js_evaluator ||= self
|
53
53
|
if render_options.trace
|
@@ -56,12 +56,27 @@ module ReactOnRails
|
|
56
56
|
"tmp/server-generated-#{@file_index % 10}.js")
|
57
57
|
@file_index += 1
|
58
58
|
end
|
59
|
-
|
59
|
+
begin
|
60
|
+
json_string = js_evaluator.eval_js(js_code, render_options)
|
61
|
+
rescue StandardError => err
|
62
|
+
msg = <<~MSG
|
63
|
+
Error evaluating server bundle. Check your webpack configuration.
|
64
|
+
===============================================================
|
65
|
+
Caught error:
|
66
|
+
#{err.message}
|
67
|
+
===============================================================
|
68
|
+
MSG
|
69
|
+
|
70
|
+
if err.message.include?("ReferenceError: self is not defined")
|
71
|
+
msg << "\nError indicates that you may have code-splitting incorrectly enabled.\n"
|
72
|
+
end
|
73
|
+
raise ReactOnRails::Error, msg, err.backtrace
|
74
|
+
end
|
60
75
|
result = nil
|
61
76
|
begin
|
62
77
|
result = JSON.parse(json_string)
|
63
78
|
rescue JSON::ParserError => e
|
64
|
-
raise ReactOnRails::JsonParseError.new(e, json_string)
|
79
|
+
raise ReactOnRails::JsonParseError.new(parse_error: e, json: json_string)
|
65
80
|
end
|
66
81
|
|
67
82
|
if render_options.logging_on_server
|
@@ -76,7 +91,7 @@ module ReactOnRails
|
|
76
91
|
end
|
77
92
|
result
|
78
93
|
end
|
79
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
94
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity
|
80
95
|
|
81
96
|
def trace_js_code_used(msg, js_code, file_name = "tmp/server-generated.js", force: false)
|
82
97
|
return unless ReactOnRails.configuration.trace || force
|
data/package.json
CHANGED
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: 13.0.0
|
4
|
+
version: 13.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Gordon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -248,6 +248,7 @@ files:
|
|
248
248
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt
|
249
249
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt
|
250
250
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt
|
251
|
+
- lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt
|
251
252
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/webpack.config.js.tt
|
252
253
|
- lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt
|
253
254
|
- lib/generators/react_on_rails/templates/base/base/config/webpacker.yml
|
@@ -333,9 +334,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
333
334
|
version: 2.7.0
|
334
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
335
336
|
requirements:
|
336
|
-
- - "
|
337
|
+
- - ">="
|
337
338
|
- !ruby/object:Gem::Version
|
338
|
-
version:
|
339
|
+
version: '0'
|
339
340
|
requirements: []
|
340
341
|
rubygems_version: 3.2.32
|
341
342
|
signing_key:
|