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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cdfa729f75cfd337b3436fe6e310d7e6a7789455fcba1baa729a2288d98c646f
4
- data.tar.gz: 54495ad6beed806991e973866a4ccd62fd7b41d3141cbaec2e71a07e13999563
3
+ metadata.gz: d0c8e1ea64a37bf952902b50d8336916e2d579f8a2e4f04e2467bd750d8418d7
4
+ data.tar.gz: 388204125e919bb352bb14df64ab67549459c2f63c416e6dc98de39daccf2395
5
5
  SHA512:
6
- metadata.gz: d0610cfa82d1d1b60f09f1586fb966dcfa12daf8549762f09e74a1fc00df6e0c8374138950e5195db0bed8501f7d8f3a1f62d90a9a779e6b652a0ada08d19d4e
7
- data.tar.gz: 9e87301d7790829e6fe2391a68cf8de6e5724777e11b955b112783c7cfec13820d5a0c28691c5f2851ec49c92ab20e886b8c2a7b4c3fe2cfcec727d662cc4490
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, webpackConfig } = require('shakapacker')
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
- return webpackConfig
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, component_name: "N/A (server_render_js called)",
238
- err: err,
239
- js_code: js_code
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, component_name: react_component_name,
487
- # Sanitize as this might be browser logged
488
- props: sanitized_props_string(props),
489
- err: err,
490
- js_code: js_code
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, component_name: react_component_name,
496
- # Sanitize as this might be browser logged
497
- props: sanitized_props_string(props),
498
- err: nil,
499
- js_code: js_code,
500
- console_messages: result["consoleReplayScript"]
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
@@ -4,7 +4,7 @@ module ReactOnRails
4
4
  class JsonParseError < ::ReactOnRails::Error
5
5
  attr_reader :json
6
6
 
7
- def initialize(parse_error, json)
7
+ def initialize(parse_error:, json:)
8
8
  @json = json
9
9
  @original_error = parse_error
10
10
  super(parse_error.message)
@@ -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: \"#{err}\"
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
- json_string = js_evaluator.eval_js(js_code, render_options)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "13.0.0.beta.0"
4
+ VERSION = "13.0.0"
5
5
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-on-rails",
3
- "version": "13.0.0-beta.0",
3
+ "version": "13.0.0",
4
4
  "description": "react-on-rails JavaScript for react_on_rails Ruby gem",
5
5
  "main": "node_package/lib/ReactOnRails.js",
6
6
  "directories": {
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.beta.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-07 00:00:00.000000000 Z
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: 1.3.1
339
+ version: '0'
339
340
  requirements: []
340
341
  rubygems_version: 3.2.32
341
342
  signing_key: