react_on_rails 9.0.0.beta.11 → 9.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +2 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +5 -0
  5. data/.travis.yml +11 -0
  6. data/CHANGELOG.md +24 -9
  7. data/Gemfile +2 -2
  8. data/Gemfile.rails32 +74 -0
  9. data/README.md +17 -12
  10. data/Rakefile +8 -1
  11. data/app/helpers/react_on_rails_helper.rb +1 -1
  12. data/docs/additional-reading/asset-pipeline.md +20 -0
  13. data/docs/additional-reading/hot-reloading-rails-development.md +0 -75
  14. data/docs/additional-reading/rspec-configuration.md +6 -23
  15. data/{lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt → docs/basics/configuration.md} +78 -41
  16. data/docs/basics/generator.md +0 -5
  17. data/docs/basics/installation-overview.md +5 -4
  18. data/docs/tutorial.md +25 -13
  19. data/lib/generators/USAGE +0 -4
  20. data/lib/generators/react_on_rails/base_generator.rb +41 -81
  21. data/lib/generators/react_on_rails/dev_tests_generator.rb +7 -5
  22. data/lib/generators/react_on_rails/install_generator.rb +5 -10
  23. data/lib/generators/react_on_rails/react_no_redux_generator.rb +10 -9
  24. data/lib/generators/react_on_rails/react_with_redux_generator.rb +27 -17
  25. data/lib/generators/react_on_rails/templates/.eslintrc +2 -0
  26. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev +4 -0
  27. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev-server +5 -0
  28. data/lib/generators/react_on_rails/templates/base/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
  29. data/lib/generators/react_on_rails/templates/base/base/{client/app/bundles/HelloWorld/startup/registration.jsx.tt → app/javascript/packs/registration.js.tt} +0 -0
  30. data/lib/generators/react_on_rails/templates/base/base/app/views/hello_world/index.html.erb.tt +0 -1
  31. data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/{hello_world.html.erb.tt → hello_world.html.erb} +3 -3
  32. data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +41 -0
  33. data/lib/generators/react_on_rails/templates/dev_tests/.eslintrc +25 -0
  34. data/lib/generators/react_on_rails/templates/dev_tests/spec/rails_helper.rb +0 -1
  35. data/lib/generators/react_on_rails/templates/dev_tests/spec/spec_helper.rb +2 -0
  36. data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx → app/javascript/bundles/HelloWorld/actions/helloWorldActionCreators.js} +0 -0
  37. data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/components/HelloWorld.jsx +0 -0
  38. data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx → app/javascript/bundles/HelloWorld/constants/helloWorldConstants.js} +0 -0
  39. data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx → app/javascript/bundles/HelloWorld/containers/HelloWorldContainer.js} +0 -0
  40. data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx → app/javascript/bundles/HelloWorld/reducers/helloWorldReducer.js} +0 -0
  41. data/lib/generators/react_on_rails/templates/redux/base/{client/app → app/javascript}/bundles/HelloWorld/startup/HelloWorldApp.jsx +0 -0
  42. data/lib/generators/react_on_rails/templates/redux/base/{client/app/bundles/HelloWorld/store/helloWorldStore.jsx → app/javascript/bundles/HelloWorld/store/helloWorldStore.js} +0 -0
  43. data/lib/react_on_rails/configuration.rb +15 -10
  44. data/lib/react_on_rails/server_rendering_pool/exec.rb +21 -8
  45. data/lib/react_on_rails/test_helper.rb +6 -6
  46. data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +1 -1
  47. data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +3 -1
  48. data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +10 -6
  49. data/lib/react_on_rails/utils.rb +34 -3
  50. data/lib/react_on_rails/version.rb +1 -1
  51. data/lib/react_on_rails/version_checker.rb +1 -1
  52. data/lib/tasks/assets.rake +10 -2
  53. data/package.json +6 -2
  54. data/rakelib/dummy_apps.rake +9 -0
  55. data/rakelib/example_type.rb +8 -19
  56. data/rakelib/examples.rake +3 -5
  57. data/rakelib/run_rspec.rake +17 -0
  58. data/yarn.lock +29 -0
  59. metadata +19 -23
  60. data/lib/generators/react_on_rails/node_generator.rb +0 -24
  61. data/lib/generators/react_on_rails/templates/base/base/Procfile.dev.tt +0 -4
  62. data/lib/generators/react_on_rails/templates/base/base/client/.babelrc +0 -3
  63. data/lib/generators/react_on_rails/templates/base/base/client/REACT_ON_RAILS_CLIENT_README.md +0 -9
  64. data/lib/generators/react_on_rails/templates/base/base/client/package.json.tt +0 -36
  65. data/lib/generators/react_on_rails/templates/base/base/client/webpack.config.js +0 -78
  66. data/lib/generators/react_on_rails/templates/base/base/config/webpacker.yml +0 -28
  67. data/lib/generators/react_on_rails/templates/base/base/package.json.tt +0 -8
  68. data/lib/generators/react_on_rails/templates/node/base/client/node/package.json +0 -10
  69. data/lib/generators/react_on_rails/templates/node/base/client/node/server.js +0 -105
@@ -5,6 +5,7 @@ require_relative "generator_helper"
5
5
 
6
6
  module ReactOnRails
7
7
  module Generators
8
+ # TODO9: Do we need something like this still? How to put in with
8
9
  FALLBACK_OPTION_FOR_NODE_MODULES = <<-TEXT
9
10
  // This fixes an issue with resolving 'react' when using a local symlinked version
10
11
  // of the node_package folder
@@ -28,7 +29,8 @@ module ReactOnRails
28
29
  desc: "Setup prerender true for server rendered examples"
29
30
 
30
31
  def copy_rspec_files
31
- %w[spec/spec_helper.rb
32
+ %w[.eslintrc
33
+ spec/spec_helper.rb
32
34
  spec/rails_helper.rb
33
35
  spec/simplecov_helper.rb
34
36
  .rspec].each { |file| copy_file(file) }
@@ -54,16 +56,16 @@ module ReactOnRails
54
56
  File.open(hello_world_index, "w+") { |f| f.puts new_hello_world_contents }
55
57
  end
56
58
 
57
- def add_yarn_relative_install_script_in_client_package_json
58
- client_package_json = File.join(destination_root, "client", "package.json")
59
- contents = File.read(client_package_json)
59
+ def add_yarn_relative_install_script_in_package_json
60
+ package_json = File.join(destination_root, "package.json")
61
+ contents = File.read(package_json)
60
62
  replacement_value = <<-STRING
61
63
  "scripts": {
62
64
  "postinstall": "yarn link react-on-rails",
63
65
  STRING
64
66
  new_client_package_json_contents = contents.gsub(/ {2}"scripts": {/,
65
67
  replacement_value)
66
- File.open(client_package_json, "w+") { |f| f.puts new_client_package_json_contents }
68
+ File.open(package_json, "w+") { |f| f.puts new_client_package_json_contents }
67
69
  end
68
70
  end
69
71
  end
@@ -19,13 +19,6 @@ module ReactOnRails
19
19
  desc: "Install Redux gems and Redux version of Hello World Example. Default: false",
20
20
  aliases: "-R"
21
21
 
22
- # --redux
23
- class_option :node,
24
- type: :boolean,
25
- default: false,
26
- desc: "Sets up node as a server rendering option. Default: false",
27
- aliases: "-N"
28
-
29
22
  # --ignore-warnings
30
23
  class_option :ignore_warnings,
31
24
  type: :boolean,
@@ -53,9 +46,11 @@ module ReactOnRails
53
46
 
54
47
  def invoke_generators
55
48
  invoke "react_on_rails:base"
56
- invoke "react_on_rails:react_no_redux" unless options.redux?
57
- invoke "react_on_rails:react_with_redux" if options.redux?
58
- invoke "react_on_rails:node" if options.node?
49
+ if options.redux?
50
+ invoke "react_on_rails:react_with_redux"
51
+ else
52
+ invoke "react_on_rails:react_no_redux"
53
+ end
59
54
  end
60
55
 
61
56
  # NOTE: other requirements for existing files such as .gitignore or application.
@@ -11,21 +11,22 @@ module ReactOnRails
11
11
  source_root(File.expand_path("../templates", __FILE__))
12
12
 
13
13
  def copy_base_files
14
- base_path = "base/base/"
15
- base_files = %w[client/app/bundles/HelloWorld/components/HelloWorld.jsx]
16
- base_files.each { |file| copy_file("#{base_path}#{file}", file) }
14
+ base_js_path = "base/base"
15
+ base_files = %w[app/javascript/bundles/HelloWorld/components/HelloWorld.jsx]
16
+ base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) }
17
17
  end
18
18
 
19
19
  def create_appropriate_templates
20
- base_path = "base/base/"
21
- location = "client/app/bundles/HelloWorld/"
22
- source = base_path + location
20
+ base_path = "base/base"
23
21
  config = {
24
22
  component_name: "HelloWorld",
25
- app_relative_path: "../components/HelloWorld"
23
+ app_relative_path: "../bundles/HelloWorld/components/HelloWorld"
26
24
  }
27
- template("#{source}/startup/registration.jsx.tt", "#{location}/startup/registration.jsx", config)
28
- template("#{base_path}app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
25
+
26
+ template("#{base_path}/app/javascript/packs/registration.js.tt",
27
+ "app/javascript/packs/hello-world-bundle.js", config)
28
+ template("#{base_path}/app/views/hello_world/index.html.erb.tt",
29
+ "app/views/hello_world/index.html.erb", config)
29
30
  end
30
31
  end
31
32
  end
@@ -9,33 +9,43 @@ module ReactOnRails
9
9
  source_root(File.expand_path("../templates", __FILE__))
10
10
 
11
11
  def create_redux_directories
12
- dirs = %w[actions constants reducers store]
13
- dirs.each { |name| empty_directory("client/app/bundles/HelloWorld/#{name}") }
12
+ dirs = %w[actions constants containers reducers store startup]
13
+ dirs.each { |name| empty_directory("app/javascript/bundles/HelloWorld/#{name}") }
14
+ end
15
+
16
+ def copy_base_files
17
+ base_js_path = "base/base"
18
+ base_files = %w[app/javascript/bundles/HelloWorld/components/HelloWorld.jsx]
19
+ base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) }
14
20
  end
15
21
 
16
22
  def copy_base_redux_files
17
- base_path = "redux/base/"
18
- %w[client/app/bundles/HelloWorld/components/HelloWorld.jsx
19
- client/app/bundles/HelloWorld/actions/helloWorldActionCreators.jsx
20
- client/app/bundles/HelloWorld/containers/HelloWorldContainer.jsx
21
- client/app/bundles/HelloWorld/constants/helloWorldConstants.jsx
22
- client/app/bundles/HelloWorld/reducers/helloWorldReducer.jsx
23
- client/app/bundles/HelloWorld/store/helloWorldStore.jsx
24
- client/app/bundles/HelloWorld/startup/HelloWorldApp.jsx].each do |file|
25
- copy_file(base_path + file, file)
23
+ base_hello_world_path = "redux/base/app/javascript/bundles/HelloWorld"
24
+ %w[actions/helloWorldActionCreators.js
25
+ containers/HelloWorldContainer.js
26
+ constants/helloWorldConstants.js
27
+ reducers/helloWorldReducer.js
28
+ store/helloWorldStore.js
29
+ startup/HelloWorldApp.jsx].each do |file|
30
+ copy_file("#{base_hello_world_path}/#{file}",
31
+ "app/javascript/bundles/HelloWorld/#{file}")
26
32
  end
27
33
  end
28
34
 
29
35
  def create_appropriate_templates
30
- base_path = "base/base/"
31
- location = "client/app/bundles/HelloWorld/"
32
- source = base_path + location
36
+ base_path = "base/base"
37
+ base_js_path = "#{base_path}/app/javascript"
33
38
  config = {
34
39
  component_name: "HelloWorldApp",
35
- app_relative_path: "./HelloWorldApp"
40
+ app_relative_path: "../bundles/HelloWorld/startup/HelloWorldApp"
36
41
  }
37
- template("#{source}/startup/registration.jsx.tt", "#{location}/startup/registration.jsx", config)
38
- template("#{base_path}app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
42
+
43
+ template("#{base_js_path}/packs/registration.js.tt", "app/javascript/packs/hello-world-bundle.js", config)
44
+ template("#{base_path}/app/views/hello_world/index.html.erb.tt", "app/views/hello_world/index.html.erb", config)
45
+ end
46
+
47
+ def add_redux_yarn_dependencies
48
+ run "yarn add redux react-redux"
39
49
  end
40
50
  end
41
51
  end
@@ -21,3 +21,5 @@ rules:
21
21
 
22
22
  # because template cannot find react-on-rails
23
23
  import/no-unresolved: 0
24
+
25
+ semi: 0
@@ -0,0 +1,4 @@
1
+ web: rails s -p 3000
2
+
3
+ # Next line runs a watch process with webpack
4
+ client: sh -c 'rm -rf public/packs/* || true && bundle exec rake react_on_rails:locale && bin/webpack -w'
@@ -0,0 +1,5 @@
1
+ web: rails s -p 3000
2
+
3
+ # Next line runs the webpack-dev-server
4
+ # You can edit config/webpacker.yml to set HMR to true to see hot reloading
5
+ client: sh -c 'rm -rf public/packs/* || true && bundle exec rake react_on_rails:locale && bin/webpack-dev-server'
@@ -1,3 +1,2 @@
1
1
  <h1>Hello World</h1>
2
2
  <%%= react_component("<%= config[:component_name] %>", props: @hello_world_props, prerender: false) %>
3
-
@@ -2,11 +2,11 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>ReactOnRailsWithWebpacker</title>
5
- <%%= csrf_meta_tags %>
6
- <%%= javascript_pack_tag 'hello-world-bundle' %>
5
+ <%= csrf_meta_tags %>
6
+ <%= javascript_pack_tag 'hello-world-bundle' %>
7
7
  </head>
8
8
 
9
9
  <body>
10
- <%%= yield %>
10
+ <%= yield %>
11
11
  </body>
12
12
  </html>
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # See docs/basics/configuration.md for many more options
4
+
5
+ ReactOnRails.configure do |config|
6
+ # This configures the script to run to build the production assets by webpack. Set this to nil
7
+ # if you don't want react_on_rails building this file for you.
8
+ config.npm_build_production_command = "RAILS_ENV=production bin/webpack"
9
+
10
+ ################################################################################
11
+ ################################################################################
12
+ # TEST CONFIGURATION OPTIONS
13
+ # Below options are used with the use of this test helper:
14
+ # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
15
+ ################################################################################
16
+
17
+ # If you are using this in your spec_helper.rb (or rails_helper.rb):
18
+ #
19
+ # ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
20
+ #
21
+ # with rspec then this controls what yarn command is run
22
+ # to automatically refresh your webpack assets on every test run.
23
+ #
24
+ config.build_test_command = "RAILS_ENV=test bin/webpack"
25
+
26
+ ################################################################################
27
+ ################################################################################
28
+ # SERVER RENDERING OPTIONS
29
+ ################################################################################
30
+ # This is the file used for server rendering of React when using `(prerender: true)`
31
+ # If you are never using server rendering, you should set this to "".
32
+ # Note, there is only one server bundle, unlike JavaScript where you want to minimize the size
33
+ # of the JS sent to the client. For the server rendering, React on Rails creates a pool of
34
+ # JavaScript execution instances which should handle any component requested.
35
+ #
36
+ # While you may configure this to be the same as your client bundle file, this file is typically
37
+ # different. You should have ONE server bundle which can create all of your server rendered
38
+ # React components.
39
+ #
40
+ config.server_bundle_js_file = "hello-world-bundle.js"
41
+ end
@@ -0,0 +1,25 @@
1
+ ---
2
+ extends: eslint-config-shakacode
3
+
4
+ plugins:
5
+ - react
6
+
7
+ globals:
8
+ __DEBUG_SERVER_ERRORS__: true
9
+ __SERVER_ERRORS__: true
10
+
11
+ env:
12
+ browser: true
13
+ node: true
14
+ mocha: true
15
+
16
+ rules:
17
+ no-console: 0
18
+
19
+ # https://github.com/benmosher/eslint-plugin-import/issues/340
20
+ import/no-extraneous-dependencies: 0
21
+
22
+ # because template cannot find react-on-rails
23
+ import/no-unresolved: 0
24
+
25
+ semi: 0
@@ -38,7 +38,6 @@ Capybara.javascript_driver = :poltergeist
38
38
  RSpec.configure do |config|
39
39
  # Ensure that if we are running js tests, we are using latest webpack assets
40
40
  # This will use the defaults of :js and :server_rendering meta tags
41
- ReactOnRails::TestHelper.launch_node if ReactOnRails.configuration.server_render_method == "NodeJS"
42
41
  ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
43
42
 
44
43
  # Remove this line if you"re not using ActiveRecord or ActiveRecord fixtures
@@ -19,6 +19,8 @@
19
19
  #
20
20
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
21
  RSpec.configure do |config|
22
+ ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
23
+
22
24
  # rspec-expectations config goes here. You can use an alternate
23
25
  # assertion/expectation library such as wrong or the stdlib/minitest
24
26
  # assertions if you prefer.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # NOTE: ReactOnRails::Utils.using_webpacker? always will return false when called here.
4
+
3
5
  module ReactOnRails
4
6
  def self.configure
5
7
  yield(configuration)
@@ -81,6 +83,7 @@ module ReactOnRails
81
83
 
82
84
  def self.configuration
83
85
  @configuration ||= Configuration.new(
86
+ node_modules_location: "",
84
87
  generated_assets_dirs: nil,
85
88
 
86
89
  # generated_assets_dirs is deprecated
@@ -97,11 +100,11 @@ module ReactOnRails
97
100
  skip_display_none: nil,
98
101
 
99
102
  # skip_display_none is deprecated
100
- webpack_generated_files: [],
103
+ webpack_generated_files: %w[manifest.json],
101
104
  rendering_extension: nil,
102
- server_render_method: "",
105
+ server_render_method: "ExecJS",
103
106
  symlink_non_digested_assets_regex: nil,
104
- npm_build_test_command: "",
107
+ build_test_command: "",
105
108
  i18n_dir: "",
106
109
  i18n_yml_dir: "",
107
110
  npm_build_production_command: ""
@@ -109,30 +112,32 @@ module ReactOnRails
109
112
  end
110
113
 
111
114
  class Configuration
112
- attr_accessor :server_bundle_js_file, :prerender, :replay_console,
115
+ attr_accessor :node_modules_location, :server_bundle_js_file, :prerender, :replay_console,
113
116
  :trace, :development_mode,
114
117
  :logging_on_server, :server_renderer_pool_size,
115
118
  :server_renderer_timeout, :skip_display_none, :raise_on_prerender_error,
116
119
  :generated_assets_dirs, :generated_assets_dir,
117
- :webpack_generated_files, :rendering_extension, :npm_build_test_command,
120
+ :webpack_generated_files, :rendering_extension, :build_test_command,
118
121
  :npm_build_production_command,
119
122
  :i18n_dir, :i18n_yml_dir,
120
123
  :server_render_method, :symlink_non_digested_assets_regex
121
124
 
122
- def initialize(server_bundle_js_file: nil, prerender: nil, replay_console: nil,
125
+ def initialize(node_modules_location: "", server_bundle_js_file: nil, prerender: nil,
126
+ replay_console: nil,
123
127
  trace: nil, development_mode: nil,
124
128
  logging_on_server: nil, server_renderer_pool_size: nil,
125
- server_renderer_timeout: nil, raise_on_prerender_error: nil,
129
+ server_renderer_timeout: nil, raise_on_prerender_error: true,
126
130
  skip_display_none: nil, generated_assets_dirs: nil,
127
131
  generated_assets_dir: nil, webpack_generated_files: nil,
128
- rendering_extension: nil, npm_build_test_command: nil,
132
+ rendering_extension: nil, build_test_command: nil,
129
133
  npm_build_production_command: nil,
130
134
  i18n_dir: nil, i18n_yml_dir: nil,
131
- server_render_method: nil, symlink_non_digested_assets_regex: nil)
135
+ server_render_method: "ExecJS", symlink_non_digested_assets_regex: nil)
136
+ self.node_modules_location = node_modules_location
132
137
  self.server_bundle_js_file = server_bundle_js_file
133
138
  self.generated_assets_dirs = generated_assets_dirs
134
139
  self.generated_assets_dir = generated_assets_dir
135
- self.npm_build_test_command = npm_build_test_command
140
+ self.build_test_command = build_test_command
136
141
  self.npm_build_production_command = npm_build_production_command
137
142
  self.i18n_dir = i18n_dir
138
143
  self.i18n_yml_dir = i18n_yml_dir
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "open-uri"
4
+
3
5
  module ReactOnRails
4
6
  module ServerRenderingPool
5
7
  # This implementation of the rendering pool uses ExecJS to execute javasript code
@@ -14,11 +16,21 @@ module ReactOnRails
14
16
 
15
17
  def self.reset_pool_if_server_bundle_was_modified
16
18
  return unless ReactOnRails.configuration.development_mode
17
- file_mtime = File.mtime(ReactOnRails::Utils.server_bundle_js_file_path)
18
- @server_bundle_timestamp ||= file_mtime
19
- return if @server_bundle_timestamp == file_mtime
19
+
20
+ server_bundle_js_file_path = ReactOnRails::Utils.server_bundle_js_file_path
21
+
22
+ if Webpacker.dev_server.running?
23
+ return if @last_loaded_server_bundle == server_bundle_js_file_path
24
+ @last_loaded_server_bundle = server_bundle_js_file_path
25
+ else
26
+ # we're not hashing the server name and we can use the mtime
27
+ file_mtime = File.mtime(server_bundle_js_file_path)
28
+ @server_bundle_timestamp ||= file_mtime
29
+ return if @server_bundle_timestamp == file_mtime
30
+ @server_bundle_timestamp = file_mtime
31
+ end
32
+
20
33
  ReactOnRails::ServerRenderingPool.reset_pool
21
- @server_bundle_timestamp = file_mtime
22
34
  end
23
35
 
24
36
  # js_code: JavaScript expression that returns a string.
@@ -83,14 +95,15 @@ module ReactOnRails
83
95
 
84
96
  server_js_file = ReactOnRails::Utils.server_bundle_js_file_path
85
97
 
86
- unless File.exist?(server_js_file)
98
+ # bundle_js_code = File.read(server_js_file)
99
+ begin
100
+ bundle_js_code = open(server_js_file, &:read)
101
+ rescue => e
87
102
  msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be "\
88
103
  "read. You may set the server_bundle_js_file in your configuration to be \"\" to "\
89
- "avoid this warning"
104
+ "avoid this warning.\nError is: #{e}"
90
105
  raise msg
91
106
  end
92
-
93
- bundle_js_code = File.read(server_js_file)
94
107
  # rubocop:disable Layout/IndentHeredoc
95
108
  base_js_code = <<-JS
96
109
  #{console_polyfill}
@@ -44,27 +44,27 @@ module ReactOnRails
44
44
  # an example of usage.
45
45
  #
46
46
  # Typical usage passes all params as nil defaults.
47
- # webpack_assets_status_checker: provide: `up_to_date?`, `whats_not_up_to_date`, `client_dir`
47
+ # webpack_assets_status_checker: provide: `up_to_date?`, `whats_not_up_to_date`, `source_path`
48
48
  # defaults to ReactOnRails::TestHelper::WebpackAssetsStatusChecker
49
49
  # webpack_assets_compiler: provide one method: `def compile`
50
50
  # defaults to ReactOnRails::TestHelper::WebpackAssetsCompiler
51
- # client_dir and generated_assets_dir are passed into the default webpack_assets_status_checker if you
51
+ # source_path and generated_assets_dir are passed into the default webpack_assets_status_checker if you
52
52
  # don't provide one.
53
53
  # webpack_generated_files List of files to check for up-to-date-status, defaulting to
54
54
  # webpack_generated_files in your configuration
55
55
  def self.ensure_assets_compiled(webpack_assets_status_checker: nil,
56
56
  webpack_assets_compiler: nil,
57
- client_dir: nil,
57
+ source_path: nil,
58
58
  generated_assets_dir: nil,
59
59
  webpack_generated_files: nil)
60
60
  ReactOnRails::Utils.check_manifest_not_cached
61
61
  if webpack_assets_status_checker.nil?
62
- client_dir ||= Rails.root.join("client")
63
- generated_assets_dir ||= ReactOnRails.configuration.generated_assets_dir
62
+ source_path ||= ReactOnRails::Utils.source_path
63
+ generated_assets_dir ||= ReactOnRails::Utils.generated_assets_dir
64
64
  webpack_generated_files ||= ReactOnRails.configuration.webpack_generated_files
65
65
 
66
66
  webpack_assets_status_checker ||=
67
- WebpackAssetsStatusChecker.new(client_dir: client_dir,
67
+ WebpackAssetsStatusChecker.new(source_path: source_path,
68
68
  generated_assets_dir: generated_assets_dir,
69
69
  webpack_generated_files: webpack_generated_files)
70
70