react_on_rails 16.0.1.rc.2 → 16.0.1.rc.4
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/CHANGELOG.md +52 -1
- data/CLAUDE.md +4 -3
- data/CODING_AGENTS.md +1 -0
- data/Gemfile.lock +1 -1
- data/NEWS.md +1 -1
- data/README.md +15 -8
- data/lib/generators/react_on_rails/base_generator.rb +59 -51
- data/lib/generators/react_on_rails/install_generator.rb +139 -1
- data/lib/generators/react_on_rails/react_with_redux_generator.rb +9 -10
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb.tt +11 -2
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +3 -2
- data/lib/react_on_rails/configuration.rb +63 -50
- data/lib/react_on_rails/json_parse_error.rb +6 -1
- data/lib/react_on_rails/packer_utils.rb +39 -52
- data/lib/react_on_rails/packs_generator.rb +3 -0
- data/lib/react_on_rails/prerender_error.rb +4 -0
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +5 -3
- data/lib/react_on_rails/system_checker.rb +6 -6
- data/lib/react_on_rails/test_helper/webpack_assets_compiler.rb +1 -1
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +1 -2
- data/lib/react_on_rails/test_helper.rb +2 -3
- data/lib/react_on_rails/utils.rb +84 -41
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/tasks/generate_packs.rake +19 -5
- metadata +1 -2
- data/package-lock.json +0 -11984
@@ -52,8 +52,13 @@ module ReactOnRails
|
|
52
52
|
# If exceeded, an error will be thrown for server-side rendered components not registered on the client.
|
53
53
|
# Set to 0 to disable the timeout and wait indefinitely for component registration.
|
54
54
|
component_registry_timeout: DEFAULT_COMPONENT_REGISTRY_TIMEOUT,
|
55
|
-
generated_component_packs_loading_strategy: nil
|
55
|
+
generated_component_packs_loading_strategy: nil,
|
56
|
+
server_bundle_output_path: "ssr-generated",
|
57
|
+
enforce_private_server_bundles: false
|
56
58
|
)
|
59
|
+
# TODO: Add automatic detection of server_bundle_output_path from shakapacker.yml
|
60
|
+
# See feature/shakapacker-yml-integration branch for implementation
|
61
|
+
# Requires Shakapacker v8.5.0+ and semantic version checking
|
57
62
|
end
|
58
63
|
|
59
64
|
class Configuration
|
@@ -68,7 +73,8 @@ module ReactOnRails
|
|
68
73
|
:same_bundle_for_client_and_server, :rendering_props_extension,
|
69
74
|
:make_generated_server_bundle_the_entrypoint,
|
70
75
|
:generated_component_packs_loading_strategy, :immediate_hydration, :rsc_bundle_js_file,
|
71
|
-
:react_client_manifest_file, :react_server_client_manifest_file, :component_registry_timeout
|
76
|
+
:react_client_manifest_file, :react_server_client_manifest_file, :component_registry_timeout,
|
77
|
+
:server_bundle_output_path, :enforce_private_server_bundles
|
72
78
|
|
73
79
|
# rubocop:disable Metrics/AbcSize
|
74
80
|
def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
|
@@ -85,7 +91,7 @@ module ReactOnRails
|
|
85
91
|
random_dom_id: nil, server_render_method: nil, rendering_props_extension: nil,
|
86
92
|
components_subdirectory: nil, auto_load_bundle: nil, immediate_hydration: nil,
|
87
93
|
rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil,
|
88
|
-
component_registry_timeout: nil)
|
94
|
+
component_registry_timeout: nil, server_bundle_output_path: nil, enforce_private_server_bundles: nil)
|
89
95
|
self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
|
90
96
|
self.generated_assets_dirs = generated_assets_dirs
|
91
97
|
self.generated_assets_dir = generated_assets_dir
|
@@ -130,6 +136,8 @@ module ReactOnRails
|
|
130
136
|
self.defer_generated_component_packs = defer_generated_component_packs
|
131
137
|
self.immediate_hydration = immediate_hydration
|
132
138
|
self.generated_component_packs_loading_strategy = generated_component_packs_loading_strategy
|
139
|
+
self.server_bundle_output_path = server_bundle_output_path
|
140
|
+
self.enforce_private_server_bundles = enforce_private_server_bundles
|
133
141
|
end
|
134
142
|
# rubocop:enable Metrics/AbcSize
|
135
143
|
|
@@ -139,13 +147,13 @@ module ReactOnRails
|
|
139
147
|
ensure_webpack_generated_files_exists
|
140
148
|
configure_generated_assets_dirs_deprecation
|
141
149
|
configure_skip_display_none_deprecation
|
142
|
-
ensure_generated_assets_dir_present
|
143
150
|
check_server_render_method_is_only_execjs
|
144
151
|
error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
|
145
152
|
# check_deprecated_settings
|
146
153
|
adjust_precompile_task
|
147
154
|
check_component_registry_timeout
|
148
155
|
validate_generated_component_packs_loading_strategy
|
156
|
+
validate_enforce_private_server_bundles
|
149
157
|
end
|
150
158
|
|
151
159
|
private
|
@@ -180,7 +188,7 @@ module ReactOnRails
|
|
180
188
|
1. Use :sync or :defer loading strategy instead of :async
|
181
189
|
2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
|
182
190
|
MSG
|
183
|
-
if PackerUtils.
|
191
|
+
if PackerUtils.supports_async_loading?
|
184
192
|
self.generated_component_packs_loading_strategy ||= :async
|
185
193
|
elsif generated_component_packs_loading_strategy.nil?
|
186
194
|
Rails.logger.warn("**WARNING** #{msg}")
|
@@ -194,15 +202,40 @@ module ReactOnRails
|
|
194
202
|
raise ReactOnRails::Error, "generated_component_packs_loading_strategy must be either :async, :defer, or :sync"
|
195
203
|
end
|
196
204
|
|
205
|
+
def validate_enforce_private_server_bundles
|
206
|
+
return unless enforce_private_server_bundles
|
207
|
+
|
208
|
+
# Check if server_bundle_output_path is nil
|
209
|
+
if server_bundle_output_path.nil?
|
210
|
+
raise ReactOnRails::Error, "enforce_private_server_bundles is set to true, but " \
|
211
|
+
"server_bundle_output_path is nil. Please set server_bundle_output_path " \
|
212
|
+
"to a directory outside of the public directory."
|
213
|
+
end
|
214
|
+
|
215
|
+
# Check if server_bundle_output_path is inside public directory
|
216
|
+
# Skip validation if Rails.root is not available (e.g., in tests)
|
217
|
+
return unless defined?(Rails) && Rails.root
|
218
|
+
|
219
|
+
public_path = Rails.root.join("public").to_s
|
220
|
+
server_output_path = File.expand_path(server_bundle_output_path, Rails.root.to_s)
|
221
|
+
|
222
|
+
return unless server_output_path.start_with?(public_path)
|
223
|
+
|
224
|
+
raise ReactOnRails::Error, "enforce_private_server_bundles is set to true, but " \
|
225
|
+
"server_bundle_output_path (#{server_bundle_output_path}) is inside " \
|
226
|
+
"the public directory. Please set it to a directory outside of public."
|
227
|
+
end
|
228
|
+
|
229
|
+
def check_minimum_shakapacker_version
|
230
|
+
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_basic_pack_generation unless
|
231
|
+
ReactOnRails::PackerUtils.supports_basic_pack_generation?
|
232
|
+
end
|
233
|
+
|
197
234
|
def check_autobundling_requirements
|
198
|
-
raise_missing_components_subdirectory
|
199
|
-
return unless components_subdirectory.present?
|
235
|
+
raise_missing_components_subdirectory unless components_subdirectory.present?
|
200
236
|
|
201
|
-
ReactOnRails::PackerUtils.raise_shakapacker_not_installed unless ReactOnRails::PackerUtils.using_packer?
|
202
237
|
ReactOnRails::PackerUtils.raise_shakapacker_version_incompatible_for_autobundling unless
|
203
|
-
ReactOnRails::PackerUtils.
|
204
|
-
ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION
|
205
|
-
)
|
238
|
+
ReactOnRails::PackerUtils.supports_autobundling?
|
206
239
|
ReactOnRails::PackerUtils.raise_nested_entries_disabled unless ReactOnRails::PackerUtils.nested_entries?
|
207
240
|
end
|
208
241
|
|
@@ -221,8 +254,8 @@ module ReactOnRails
|
|
221
254
|
# We set it very big so that it is not used, and then clean just
|
222
255
|
# removes files older than 1 hour.
|
223
256
|
versions = 100_000
|
224
|
-
puts "Invoking task
|
225
|
-
Rake::Task["
|
257
|
+
puts "Invoking task shakapacker:clean from React on Rails"
|
258
|
+
Rake::Task["shakapacker:clean"].invoke(versions)
|
226
259
|
}
|
227
260
|
|
228
261
|
if Rake::Task.task_defined?("assets:precompile")
|
@@ -237,22 +270,20 @@ module ReactOnRails
|
|
237
270
|
end
|
238
271
|
|
239
272
|
def error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
|
240
|
-
return unless ReactOnRails::PackerUtils.using_packer?
|
241
|
-
|
242
273
|
return if generated_assets_dir.blank?
|
243
274
|
|
244
275
|
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
|
245
276
|
|
246
277
|
if File.expand_path(generated_assets_dir) == packer_public_output_path.to_s
|
247
278
|
Rails.logger.warn("You specified generated_assets_dir in `config/initializers/react_on_rails.rb` " \
|
248
|
-
"with
|
279
|
+
"with Shakapacker. " \
|
249
280
|
"Remove this line from your configuration file.")
|
250
281
|
else
|
251
282
|
msg = <<~MSG
|
252
|
-
Error configuring /config/initializers/react_on_rails.rb: You are using
|
283
|
+
Error configuring /config/initializers/react_on_rails.rb: You are using Shakapacker
|
253
284
|
and your specified value for generated_assets_dir = #{generated_assets_dir}
|
254
285
|
that does not match the value for public_output_path specified in
|
255
|
-
|
286
|
+
shakapacker.yml = #{packer_public_output_path}. You should remove the configuration
|
256
287
|
value for "generated_assets_dir" from your config/initializers/react_on_rails.rb file.
|
257
288
|
MSG
|
258
289
|
raise ReactOnRails::Error, msg
|
@@ -271,37 +302,21 @@ module ReactOnRails
|
|
271
302
|
raise ReactOnRails::Error, msg
|
272
303
|
end
|
273
304
|
|
274
|
-
def ensure_generated_assets_dir_present
|
275
|
-
return if generated_assets_dir.present? || ReactOnRails::PackerUtils.using_packer?
|
276
|
-
|
277
|
-
self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
|
278
|
-
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
|
279
|
-
end
|
280
|
-
|
281
305
|
def configure_generated_assets_dirs_deprecation
|
282
306
|
return if generated_assets_dirs.blank?
|
283
307
|
|
284
|
-
|
285
|
-
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
|
286
|
-
# rubocop:disable Layout/LineLength
|
287
|
-
packer_name = ReactOnRails::PackerUtils.packer_type&.upcase_first
|
308
|
+
packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path
|
288
309
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
310
|
+
msg = <<~MSG
|
311
|
+
ReactOnRails Configuration Warning: The 'generated_assets_dirs' configuration option is no longer supported.
|
312
|
+
Since Shakapacker is now required, public asset paths are automatically determined from your shakapacker.yml configuration.
|
313
|
+
Please remove 'config.generated_assets_dirs' from your config/initializers/react_on_rails.rb file.
|
314
|
+
Public assets will be loaded from: #{packer_public_output_path}
|
315
|
+
If you need to customize the public output path, configure it in config/shakapacker.yml under 'public_output_path'.
|
316
|
+
Note: Private server bundles are configured separately via server_bundle_output_path.
|
317
|
+
MSG
|
295
318
|
|
296
|
-
Rails.logger.warn
|
297
|
-
"generated_assets_dirs"
|
298
|
-
if generated_assets_dir.blank?
|
299
|
-
self.generated_assets_dir = generated_assets_dirs
|
300
|
-
else
|
301
|
-
Rails.logger.warn "[DEPRECATION] ReactOnRails. You have both generated_assets_dirs and " \
|
302
|
-
"generated_assets_dir defined. Define ONLY generated_assets_dir if NOT using Shakapacker " \
|
303
|
-
"and define neither if using Webpacker"
|
304
|
-
end
|
319
|
+
Rails.logger.warn msg
|
305
320
|
end
|
306
321
|
|
307
322
|
def ensure_webpack_generated_files_exists
|
@@ -333,17 +348,15 @@ module ReactOnRails
|
|
333
348
|
end
|
334
349
|
|
335
350
|
def compile_command_conflict_message
|
336
|
-
packer_name = ReactOnRails::PackerUtils.packer_type.upcase_first
|
337
|
-
packer_type = ReactOnRails::PackerUtils.packer_type
|
338
351
|
<<~MSG
|
339
352
|
|
340
|
-
React on Rails and
|
353
|
+
React on Rails and Shakapacker error in configuration!
|
341
354
|
In order to use config/react_on_rails.rb config.build_production_command,
|
342
|
-
you must edit config
|
343
|
-
'
|
355
|
+
you must edit config/shakapacker.yml to include this value in the default configuration:
|
356
|
+
'shakapacker_precompile: false'
|
344
357
|
|
345
358
|
Alternatively, remove the config/react_on_rails.rb config.build_production_command and the
|
346
|
-
default bin
|
359
|
+
default bin/shakapacker script will be used for assets:precompile.
|
347
360
|
|
348
361
|
MSG
|
349
362
|
end
|
@@ -7,7 +7,12 @@ module ReactOnRails
|
|
7
7
|
def initialize(parse_error:, json:)
|
8
8
|
@json = json
|
9
9
|
@original_error = parse_error
|
10
|
-
|
10
|
+
message = <<~MSG
|
11
|
+
#{parse_error.message}
|
12
|
+
|
13
|
+
#{Utils.default_troubleshooting_section}
|
14
|
+
MSG
|
15
|
+
super(message)
|
11
16
|
end
|
12
17
|
|
13
18
|
def to_honeybadger_context
|
@@ -1,44 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "shakapacker"
|
4
|
+
|
3
5
|
module ReactOnRails
|
4
6
|
module PackerUtils
|
5
|
-
def self.using_packer?
|
6
|
-
using_shakapacker_const?
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.using_shakapacker_const?
|
10
|
-
return @using_shakapacker_const if defined?(@using_shakapacker_const)
|
11
|
-
|
12
|
-
@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
|
13
|
-
shakapacker_version_requirement_met?("8.2.0")
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.packer_type
|
17
|
-
return "shakapacker" if using_shakapacker_const?
|
18
|
-
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.packer
|
23
|
-
return nil unless using_packer?
|
24
|
-
|
25
|
-
require "shakapacker"
|
26
|
-
::Shakapacker
|
27
|
-
end
|
28
|
-
|
29
7
|
def self.dev_server_running?
|
30
|
-
|
31
|
-
|
32
|
-
packer.dev_server.running?
|
8
|
+
Shakapacker.dev_server.running?
|
33
9
|
end
|
34
10
|
|
35
11
|
def self.dev_server_url
|
36
|
-
"#{
|
12
|
+
"#{Shakapacker.dev_server.protocol}://#{Shakapacker.dev_server.host_with_port}"
|
37
13
|
end
|
38
14
|
|
39
15
|
def self.shakapacker_version
|
40
16
|
return @shakapacker_version if defined?(@shakapacker_version)
|
41
|
-
return nil unless ReactOnRails::Utils.gem_available?("shakapacker")
|
42
17
|
|
43
18
|
@shakapacker_version = Gem.loaded_specs["shakapacker"].version.to_s
|
44
19
|
end
|
@@ -53,14 +28,28 @@ module ReactOnRails
|
|
53
28
|
end
|
54
29
|
|
55
30
|
def self.shakapacker_version_requirement_met?(required_version)
|
56
|
-
|
31
|
+
@version_checks ||= {}
|
32
|
+
@version_checks[required_version] ||= Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.supports_async_loading?
|
36
|
+
shakapacker_version_requirement_met?("8.2.0")
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.supports_basic_pack_generation?
|
40
|
+
shakapacker_version_requirement_met?(ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.supports_autobundling?
|
44
|
+
min_version = ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING
|
45
|
+
::Shakapacker.config.respond_to?(:nested_entries?) && shakapacker_version_requirement_met?(min_version)
|
57
46
|
end
|
58
47
|
|
59
48
|
# This returns either a URL for the webpack-dev-server, non-server bundle or
|
60
49
|
# the hashed server bundle if using the same bundle for the client.
|
61
50
|
# Otherwise returns a file path.
|
62
51
|
def self.bundle_js_uri_from_packer(bundle_name)
|
63
|
-
hashed_bundle_name =
|
52
|
+
hashed_bundle_name = ::Shakapacker.manifest.lookup!(bundle_name)
|
64
53
|
|
65
54
|
# Support for hashing the server-bundle and having that built
|
66
55
|
# the webpack-dev-server is provided by the config value
|
@@ -69,7 +58,7 @@ module ReactOnRails
|
|
69
58
|
is_bundle_running_on_server = (bundle_name == ReactOnRails.configuration.server_bundle_js_file) ||
|
70
59
|
(bundle_name == ReactOnRails.configuration.rsc_bundle_js_file)
|
71
60
|
|
72
|
-
if
|
61
|
+
if ::Shakapacker.dev_server.running? && (!is_bundle_running_on_server ||
|
73
62
|
ReactOnRails.configuration.same_bundle_for_client_and_server)
|
74
63
|
"#{dev_server_url}#{hashed_bundle_name}"
|
75
64
|
else
|
@@ -78,7 +67,7 @@ module ReactOnRails
|
|
78
67
|
end
|
79
68
|
|
80
69
|
def self.public_output_uri_path
|
81
|
-
"#{
|
70
|
+
"#{::Shakapacker.config.public_output_path.relative_path_from(::Shakapacker.config.public_path)}/"
|
82
71
|
end
|
83
72
|
|
84
73
|
# The function doesn't ensure that the asset exists.
|
@@ -93,42 +82,40 @@ module ReactOnRails
|
|
93
82
|
end
|
94
83
|
|
95
84
|
def self.precompile?
|
96
|
-
|
97
|
-
|
98
|
-
false
|
85
|
+
::Shakapacker.config.shakapacker_precompile?
|
99
86
|
end
|
100
87
|
|
101
88
|
def self.packer_source_path
|
102
|
-
|
89
|
+
::Shakapacker.config.source_path
|
103
90
|
end
|
104
91
|
|
105
92
|
def self.packer_source_entry_path
|
106
|
-
|
93
|
+
::Shakapacker.config.source_entry_path
|
107
94
|
end
|
108
95
|
|
109
96
|
def self.nested_entries?
|
110
|
-
|
97
|
+
::Shakapacker.config.nested_entries?
|
111
98
|
end
|
112
99
|
|
113
100
|
def self.packer_public_output_path
|
114
|
-
|
101
|
+
::Shakapacker.config.public_output_path.to_s
|
115
102
|
end
|
116
103
|
|
117
104
|
def self.manifest_exists?
|
118
|
-
|
105
|
+
::Shakapacker.config.public_manifest_path.exist?
|
119
106
|
end
|
120
107
|
|
121
108
|
def self.packer_source_path_explicit?
|
122
|
-
|
109
|
+
::Shakapacker.config.send(:data)[:source_path].present?
|
123
110
|
end
|
124
111
|
|
125
112
|
def self.check_manifest_not_cached
|
126
|
-
return unless
|
113
|
+
return unless ::Shakapacker.config.cache_manifest?
|
127
114
|
|
128
115
|
msg = <<-MSG.strip_heredoc
|
129
116
|
ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the
|
130
117
|
ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper
|
131
|
-
To fix this: edit your config
|
118
|
+
To fix this: edit your config/shakapacker.yml file and set cache_manifest to false for test.
|
132
119
|
MSG
|
133
120
|
puts wrap_message(msg)
|
134
121
|
exit!
|
@@ -149,7 +136,7 @@ module ReactOnRails
|
|
149
136
|
def self.raise_nested_entries_disabled
|
150
137
|
msg = <<~MSG
|
151
138
|
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \
|
152
|
-
config
|
139
|
+
config/shakapacker.yml to enable nested entries. for more information read
|
153
140
|
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker
|
154
141
|
MSG
|
155
142
|
|
@@ -158,19 +145,19 @@ module ReactOnRails
|
|
158
145
|
|
159
146
|
def self.raise_shakapacker_version_incompatible_for_autobundling
|
160
147
|
msg = <<~MSG
|
161
|
-
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::PacksGenerator::
|
162
|
-
above to use the automated bundle generation feature
|
163
|
-
#{ReactOnRails::PackerUtils.shakapacker_version}.
|
148
|
+
**ERROR** ReactOnRails: Please upgrade ::Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING} or \
|
149
|
+
above to use the automated bundle generation feature (which requires nested_entries support). \
|
150
|
+
The currently installed version is #{ReactOnRails::PackerUtils.shakapacker_version}. \
|
151
|
+
Basic pack generation requires ::Shakapacker #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or above.
|
164
152
|
MSG
|
165
153
|
|
166
154
|
raise ReactOnRails::Error, msg
|
167
155
|
end
|
168
156
|
|
169
|
-
def self.
|
157
|
+
def self.raise_shakapacker_version_incompatible_for_basic_pack_generation
|
170
158
|
msg = <<~MSG
|
171
|
-
**ERROR** ReactOnRails:
|
172
|
-
|
173
|
-
automated bundle generation feature.
|
159
|
+
**ERROR** ReactOnRails: Please upgrade ::Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or \
|
160
|
+
above to use basic pack generation features. The currently installed version is #{ReactOnRails::PackerUtils.shakapacker_version}.
|
174
161
|
MSG
|
175
162
|
|
176
163
|
raise ReactOnRails::Error, msg
|
@@ -9,6 +9,8 @@ module ReactOnRails
|
|
9
9
|
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/
|
10
10
|
COMPONENT_EXTENSIONS = /\.(jsx?|tsx?)$/
|
11
11
|
MINIMUM_SHAKAPACKER_VERSION = "6.5.1"
|
12
|
+
# Auto-registration requires nested_entries support which was added in 7.0.0
|
13
|
+
MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_BUNDLING = "7.0.0"
|
12
14
|
|
13
15
|
def self.instance
|
14
16
|
@instance ||= PacksGenerator.new
|
@@ -164,6 +166,7 @@ module ReactOnRails
|
|
164
166
|
|
165
167
|
def add_generated_pack_to_server_bundle
|
166
168
|
return if ReactOnRails.configuration.make_generated_server_bundle_the_entrypoint
|
169
|
+
return if ReactOnRails.configuration.server_bundle_js_file.blank?
|
167
170
|
|
168
171
|
relative_path_to_generated_server_bundle = relative_path(server_bundle_entrypoint,
|
169
172
|
generated_server_bundle_file_path)
|
@@ -77,6 +77,7 @@ module ReactOnRails
|
|
77
77
|
if err.message.include?("ReferenceError: self is not defined")
|
78
78
|
msg << "\nError indicates that you may have code-splitting incorrectly enabled.\n"
|
79
79
|
end
|
80
|
+
msg << "\n#{Utils.default_troubleshooting_section}\n"
|
80
81
|
raise ReactOnRails::Error, msg, err.backtrace
|
81
82
|
end
|
82
83
|
|
@@ -122,7 +123,7 @@ module ReactOnRails
|
|
122
123
|
rescue StandardError => e
|
123
124
|
msg = "You specified server rendering JS file: #{server_js_file}, but it cannot be " \
|
124
125
|
"read. You may set the server_bundle_js_file in your configuration to be \"\" to " \
|
125
|
-
"avoid this warning.\nError is: #{e}"
|
126
|
+
"avoid this warning.\nError is: #{e}\n\n#{Utils.default_troubleshooting_section}"
|
126
127
|
raise ReactOnRails::Error, msg
|
127
128
|
end
|
128
129
|
|
@@ -149,7 +150,8 @@ module ReactOnRails
|
|
149
150
|
msg = "ERROR when compiling base_js_code! " \
|
150
151
|
"See file #{file_name} to " \
|
151
152
|
"correlate line numbers of error. Error is\n\n#{e.message}" \
|
152
|
-
"\n\n#{e.backtrace.join("\n")}"
|
153
|
+
"\n\n#{e.backtrace.join("\n")}" \
|
154
|
+
"\n\n#{Utils.default_troubleshooting_section}"
|
153
155
|
Rails.logger.error(msg)
|
154
156
|
trace_js_code_used("Error when compiling JavaScript code for the context.", base_js_code,
|
155
157
|
file_name, force: true)
|
@@ -227,7 +229,7 @@ module ReactOnRails
|
|
227
229
|
encoding_type = match[:encoding]
|
228
230
|
response.body.force_encoding(encoding_type)
|
229
231
|
rescue StandardError => e
|
230
|
-
msg = "file_url_to_string #{url} failed\nError is: #{e}"
|
232
|
+
msg = "file_url_to_string #{url} failed\nError is: #{e}\n\n#{Utils.default_troubleshooting_section}"
|
231
233
|
raise ReactOnRails::Error, msg
|
232
234
|
end
|
233
235
|
|
@@ -618,14 +618,14 @@ module ReactOnRails
|
|
618
618
|
version = shakapacker_match[1].strip
|
619
619
|
|
620
620
|
begin
|
621
|
-
#
|
622
|
-
|
623
|
-
threshold_version = Gem::Version.new("8.2")
|
621
|
+
# Validate version string format
|
622
|
+
Gem::Version.new(version)
|
624
623
|
|
625
|
-
if
|
626
|
-
add_success("✅ Shakapacker #{version} (supports React on Rails auto-
|
624
|
+
if ReactOnRails::PackerUtils.supports_autobundling?
|
625
|
+
add_success("✅ Shakapacker #{version} (supports React on Rails auto-bundling)")
|
627
626
|
else
|
628
|
-
add_warning("⚠️ Shakapacker #{version} - Version
|
627
|
+
add_warning("⚠️ Shakapacker #{version} - Version 7.0+ with nested_entries support needed " \
|
628
|
+
"for React on Rails auto-bundling")
|
629
629
|
end
|
630
630
|
rescue ArgumentError
|
631
631
|
# Fallback for invalid version strings
|
@@ -16,7 +16,7 @@ module ReactOnRails
|
|
16
16
|
|
17
17
|
React on Rails is aborting your test run
|
18
18
|
|
19
|
-
If you wish to use the config
|
19
|
+
If you wish to use the config/shakapacker.yml compile option for tests
|
20
20
|
them remove your call to the ReactOnRails test helper.
|
21
21
|
MSG
|
22
22
|
puts Rainbow(msg).red
|
@@ -31,8 +31,7 @@ module ReactOnRails
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def stale_generated_files(files)
|
34
|
-
manifest_needed = ReactOnRails::PackerUtils.
|
35
|
-
!ReactOnRails::PackerUtils.manifest_exists?
|
34
|
+
manifest_needed = !ReactOnRails::PackerUtils.manifest_exists?
|
36
35
|
|
37
36
|
return ["manifest.json"] if manifest_needed
|
38
37
|
|
@@ -86,10 +86,9 @@ module ReactOnRails
|
|
86
86
|
puts
|
87
87
|
@printed_once = true
|
88
88
|
|
89
|
-
if ReactOnRails::
|
90
|
-
ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules?
|
89
|
+
if ReactOnRails::Utils.using_packer_source_path_is_not_defined_and_custom_node_modules?
|
91
90
|
msg = <<-MSG.strip_heredoc
|
92
|
-
WARNING: Define config
|
91
|
+
WARNING: Define config/shakapacker.yml to include sourcePath to configure
|
93
92
|
the location of your JavaScript source for React on Rails.
|
94
93
|
Default location of #{source_path} is used.
|
95
94
|
MSG
|