react_on_rails 13.0.0 → 13.1.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 +45 -5
- data/Gemfile.development_dependencies +1 -3
- data/NEWS.md +1 -1
- data/README.md +45 -22
- data/docs/additional-details/migrating-from-react-rails.md +1 -1
- data/docs/additional-details/recommended-project-structure.md +1 -1
- data/docs/api/view-helpers-api.md +2 -1
- data/docs/{guides/getting-started.md → getting-started.md} +4 -1
- data/docs/guides/client-vs-server-rendering.md +4 -2
- data/docs/guides/configuration.md +18 -4
- data/docs/guides/file-system-based-automated-bundle-generation.md +188 -0
- data/docs/guides/i18n.md +71 -83
- data/docs/guides/rails-webpacker-react-integration-options.md +4 -3
- data/docs/guides/react-server-rendering.md +1 -1
- data/docs/guides/tutorial.md +15 -8
- data/docs/guides/webpack-configuration.md +1 -1
- data/docs/home.md +2 -2
- data/docs/javascript/server-rendering-tips.md +0 -3
- data/lib/generators/react_on_rails/base_generator.rb +0 -1
- data/lib/generators/react_on_rails/templates/base/base/app/views/layouts/hello_world.html.erb +1 -1
- data/lib/generators/react_on_rails/templates/base/base/babel.config.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/initializers/react_on_rails.rb +13 -0
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/clientWebpackConfig.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/commonWebpackConfig.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/production.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/serverWebpackConfig.js.tt +1 -1
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/test.js.tt +7 -4
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/webpackConfig.js.tt +1 -1
- data/lib/react_on_rails/configuration.rb +11 -33
- data/lib/react_on_rails/helper.rb +40 -4
- data/lib/react_on_rails/locales/base.rb +24 -1
- data/lib/react_on_rails/packs_generator.rb +298 -0
- data/lib/react_on_rails/react_component/render_options.rb +4 -0
- data/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb +0 -6
- data/lib/react_on_rails/test_helper/ensure_assets_compiled.rb +2 -0
- data/lib/react_on_rails/test_helper/webpack_assets_status_checker.rb +19 -3
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/webpacker_utils.rb +14 -0
- data/lib/react_on_rails.rb +1 -0
- data/lib/tasks/generate_packs.rake +11 -0
- data/package.json +2 -2
- data/yarn.lock +5 -5
- metadata +6 -3
@@ -5,13 +5,36 @@ require "erb"
|
|
5
5
|
module ReactOnRails
|
6
6
|
module Locales
|
7
7
|
def self.compile
|
8
|
-
|
8
|
+
config = ReactOnRails.configuration
|
9
|
+
check_config_directory_exists(
|
10
|
+
directory: config.i18n_dir, key_name: "config.i18n_dir",
|
11
|
+
remove_if: "not using the React on Rails i18n feature"
|
12
|
+
)
|
13
|
+
check_config_directory_exists(
|
14
|
+
directory: config.i18n_yml_dir, key_name: "config.i18n_yml_dir",
|
15
|
+
remove_if: "not using this i18n with React on Rails, or if you want to use all translation files"
|
16
|
+
)
|
17
|
+
if config.i18n_output_format&.downcase == "js"
|
9
18
|
ReactOnRails::Locales::ToJs.new
|
10
19
|
else
|
11
20
|
ReactOnRails::Locales::ToJson.new
|
12
21
|
end
|
13
22
|
end
|
14
23
|
|
24
|
+
def self.check_config_directory_exists(directory:, key_name:, remove_if:)
|
25
|
+
return if directory.nil?
|
26
|
+
return if Dir.exist?(directory)
|
27
|
+
|
28
|
+
msg = <<~MSG
|
29
|
+
Error configuring /config/initializers/react_on_rails.rb: invalid value for `#{key_name}`.
|
30
|
+
Directory does not exist: #{directory}. Set to value to nil or comment it
|
31
|
+
out if #{remove_if}.
|
32
|
+
MSG
|
33
|
+
raise ReactOnRails::Error, msg
|
34
|
+
end
|
35
|
+
|
36
|
+
private_class_method :check_config_directory_exists
|
37
|
+
|
15
38
|
class Base
|
16
39
|
def initialize
|
17
40
|
return if i18n_dir.nil?
|
@@ -0,0 +1,298 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module ReactOnRails
|
6
|
+
# rubocop:disable Metrics/ClassLength
|
7
|
+
class PacksGenerator
|
8
|
+
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/.freeze
|
9
|
+
MINIMUM_SHAKAPACKER_MAJOR_VERSION = 6
|
10
|
+
MINIMUM_SHAKAPACKER_MINOR_VERSION = 5
|
11
|
+
MINIMUM_SHAKAPACKER_PATCH_VERSION = 1
|
12
|
+
|
13
|
+
def self.generate
|
14
|
+
packs_generator = PacksGenerator.new
|
15
|
+
packs_generator.verify_setup_and_generate_packs
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.raise_nested_enteries_disabled
|
19
|
+
packs_generator = PacksGenerator.new
|
20
|
+
packs_generator.raise_nested_enteries_disabled
|
21
|
+
end
|
22
|
+
|
23
|
+
def verify_setup_and_generate_packs
|
24
|
+
return unless components_subdirectory.present?
|
25
|
+
|
26
|
+
raise_webpacker_not_installed unless ReactOnRails::WebpackerUtils.using_webpacker?
|
27
|
+
raise_shakapacker_version_incompatible unless shackapacker_version_requirement_met?
|
28
|
+
raise_nested_enteries_disabled unless ReactOnRails::WebpackerUtils.nested_entries?
|
29
|
+
|
30
|
+
is_generated_directory_present = Dir.exist?(generated_packs_directory_path)
|
31
|
+
|
32
|
+
return if is_generated_directory_present && webpack_assets_status_checker.stale_generated_component_packs.empty?
|
33
|
+
|
34
|
+
clean_generated_packs_directory
|
35
|
+
generate_packs
|
36
|
+
end
|
37
|
+
|
38
|
+
def raise_nested_enteries_disabled
|
39
|
+
msg = <<~MSG
|
40
|
+
**ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker. Please update \
|
41
|
+
webpacker.yml to enable nested enteries. for more information read
|
42
|
+
https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker
|
43
|
+
MSG
|
44
|
+
|
45
|
+
raise ReactOnRails::Error, msg
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def generate_packs
|
51
|
+
common_component_to_path.each_value { |component_path| create_pack(component_path) }
|
52
|
+
client_component_to_path.each_value { |component_path| create_pack(component_path) }
|
53
|
+
|
54
|
+
create_server_pack if ReactOnRails.configuration.server_bundle_js_file.present?
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_pack(file_path)
|
58
|
+
output_path = generated_pack_path(file_path)
|
59
|
+
content = pack_file_contents(file_path)
|
60
|
+
|
61
|
+
File.write(output_path, content)
|
62
|
+
|
63
|
+
puts(Rainbow("Generated Packs: #{output_path}").yellow)
|
64
|
+
end
|
65
|
+
|
66
|
+
def pack_file_contents(file_path)
|
67
|
+
registered_component_name = component_name(file_path)
|
68
|
+
<<~FILE_CONTENT
|
69
|
+
import ReactOnRails from 'react-on-rails';
|
70
|
+
import #{registered_component_name} from '#{relative_component_path_from_generated_pack(file_path)}';
|
71
|
+
|
72
|
+
ReactOnRails.register({#{registered_component_name}});
|
73
|
+
FILE_CONTENT
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_server_pack
|
77
|
+
File.write(generated_server_bundle_file_path, generated_server_pack_file_content)
|
78
|
+
|
79
|
+
add_generated_pack_to_server_bundle
|
80
|
+
puts(Rainbow("Generated Server Bundle: #{generated_server_bundle_file_path}").orange)
|
81
|
+
end
|
82
|
+
|
83
|
+
def generated_server_pack_file_content
|
84
|
+
common_components_for_server_bundle = common_component_to_path.delete_if { |k| server_component_to_path.key?(k) }
|
85
|
+
component_for_server_registration_to_path = common_components_for_server_bundle.merge(server_component_to_path)
|
86
|
+
|
87
|
+
server_component_imports = component_for_server_registration_to_path.map do |name, component_path|
|
88
|
+
"import #{name} from '#{relative_path(generated_server_bundle_file_path, component_path)}';"
|
89
|
+
end
|
90
|
+
|
91
|
+
components_to_register = component_for_server_registration_to_path.keys
|
92
|
+
|
93
|
+
<<~FILE_CONTENT
|
94
|
+
import ReactOnRails from 'react-on-rails';
|
95
|
+
|
96
|
+
#{server_component_imports.join("\n")}
|
97
|
+
|
98
|
+
ReactOnRails.register({#{components_to_register.join(",\n")}});
|
99
|
+
FILE_CONTENT
|
100
|
+
end
|
101
|
+
|
102
|
+
def add_generated_pack_to_server_bundle
|
103
|
+
relative_path_to_generated_server_bundle = relative_path(defined_server_bundle_file_path,
|
104
|
+
generated_server_bundle_file_path)
|
105
|
+
content = <<~FILE_CONTENT
|
106
|
+
import "./#{relative_path_to_generated_server_bundle}"\n
|
107
|
+
FILE_CONTENT
|
108
|
+
|
109
|
+
prepend_to_file_if_not_present(defined_server_bundle_file_path, content)
|
110
|
+
end
|
111
|
+
|
112
|
+
def generated_server_bundle_file_path
|
113
|
+
file_ext = File.extname(defined_server_bundle_file_path)
|
114
|
+
generated_server_bundle_file_path = defined_server_bundle_file_path.sub(file_ext, "-generated#{file_ext}")
|
115
|
+
generated_server_bundle_file_name = component_name(generated_server_bundle_file_path)
|
116
|
+
source_entry_path = ReactOnRails::WebpackerUtils.webpacker_source_entry_path
|
117
|
+
|
118
|
+
"#{source_entry_path}/#{generated_server_bundle_file_name}#{file_ext}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def clean_generated_packs_directory
|
122
|
+
FileUtils.rm_rf(generated_packs_directory_path)
|
123
|
+
FileUtils.mkdir_p(generated_packs_directory_path)
|
124
|
+
end
|
125
|
+
|
126
|
+
def defined_server_bundle_file_path
|
127
|
+
ReactOnRails::Utils.server_bundle_js_file_path
|
128
|
+
end
|
129
|
+
|
130
|
+
def generated_packs_directory_path
|
131
|
+
source_entry_path = ReactOnRails::WebpackerUtils.webpacker_source_entry_path
|
132
|
+
|
133
|
+
"#{source_entry_path}/generated"
|
134
|
+
end
|
135
|
+
|
136
|
+
def relative_component_path_from_generated_pack(ror_component_path)
|
137
|
+
component_file_pathname = Pathname.new(ror_component_path)
|
138
|
+
component_generated_pack_path = generated_pack_path(ror_component_path)
|
139
|
+
generated_pack_pathname = Pathname.new(component_generated_pack_path)
|
140
|
+
|
141
|
+
relative_path(generated_pack_pathname, component_file_pathname)
|
142
|
+
end
|
143
|
+
|
144
|
+
def relative_path(from, to)
|
145
|
+
from_path = Pathname.new(from)
|
146
|
+
to_path = Pathname.new(to)
|
147
|
+
|
148
|
+
relative_path = to_path.relative_path_from(from_path)
|
149
|
+
relative_path.sub("../", "")
|
150
|
+
end
|
151
|
+
|
152
|
+
def generated_pack_path(file_path)
|
153
|
+
"#{generated_packs_directory_path}/#{component_name(file_path)}.jsx"
|
154
|
+
end
|
155
|
+
|
156
|
+
def component_name(file_path)
|
157
|
+
basename = File.basename(file_path, File.extname(file_path))
|
158
|
+
|
159
|
+
basename.sub(CONTAINS_CLIENT_OR_SERVER_REGEX, "")
|
160
|
+
end
|
161
|
+
|
162
|
+
def component_name_to_path(paths)
|
163
|
+
paths.to_h { |path| [component_name(path), path] }
|
164
|
+
end
|
165
|
+
|
166
|
+
def common_component_to_path
|
167
|
+
common_components_paths = Dir.glob("#{components_search_path}/*").reject do |f|
|
168
|
+
CONTAINS_CLIENT_OR_SERVER_REGEX.match?(f)
|
169
|
+
end
|
170
|
+
component_name_to_path(common_components_paths)
|
171
|
+
end
|
172
|
+
|
173
|
+
def client_component_to_path
|
174
|
+
client_render_components_paths = Dir.glob("#{components_search_path}/*.client.*")
|
175
|
+
client_specific_components = component_name_to_path(client_render_components_paths)
|
176
|
+
|
177
|
+
duplicate_components = common_component_to_path.slice(*client_specific_components.keys)
|
178
|
+
duplicate_components.each_key { |component| raise_client_component_overrides_common(component) }
|
179
|
+
|
180
|
+
client_specific_components
|
181
|
+
end
|
182
|
+
|
183
|
+
def server_component_to_path
|
184
|
+
server_render_components_paths = Dir.glob("#{components_search_path}/*.server.*")
|
185
|
+
server_specific_components = component_name_to_path(server_render_components_paths)
|
186
|
+
|
187
|
+
duplicate_components = common_component_to_path.slice(*server_specific_components.keys)
|
188
|
+
duplicate_components.each_key { |component| raise_server_component_overrides_common(component) }
|
189
|
+
|
190
|
+
server_specific_components.each_key do |k|
|
191
|
+
raise_missing_client_component(k) unless client_component_to_path.key?(k)
|
192
|
+
end
|
193
|
+
|
194
|
+
server_specific_components
|
195
|
+
end
|
196
|
+
|
197
|
+
def components_search_path
|
198
|
+
source_path = ReactOnRails::WebpackerUtils.webpacker_source_path
|
199
|
+
|
200
|
+
"#{source_path}/**/#{components_subdirectory}"
|
201
|
+
end
|
202
|
+
|
203
|
+
def components_subdirectory
|
204
|
+
ReactOnRails.configuration.components_subdirectory
|
205
|
+
end
|
206
|
+
|
207
|
+
def webpack_assets_status_checker
|
208
|
+
source_path = ReactOnRails::Utils.source_path
|
209
|
+
generated_assets_full_path = ReactOnRails::Utils.generated_assets_full_path
|
210
|
+
webpack_generated_files = ReactOnRails.configuration.webpack_generated_files
|
211
|
+
|
212
|
+
@webpack_assets_status_checker ||= ReactOnRails::TestHelper::WebpackAssetsStatusChecker.new(
|
213
|
+
source_path: source_path,
|
214
|
+
generated_assets_full_path: generated_assets_full_path,
|
215
|
+
webpack_generated_files: webpack_generated_files
|
216
|
+
)
|
217
|
+
end
|
218
|
+
|
219
|
+
def raise_client_component_overrides_common(component_name)
|
220
|
+
msg = <<~MSG
|
221
|
+
**ERROR** ReactOnRails: client specific definition for Component '#{component_name}' overrides the \
|
222
|
+
common definition. Please delete the common definition and have separate server and client files. For more \
|
223
|
+
information, please see https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md
|
224
|
+
MSG
|
225
|
+
|
226
|
+
raise ReactOnRails::Error, msg
|
227
|
+
end
|
228
|
+
|
229
|
+
def raise_server_component_overrides_common(component_name)
|
230
|
+
msg = <<~MSG
|
231
|
+
**ERROR** ReactOnRails: server specific definition for Component '#{component_name}' overrides the \
|
232
|
+
common definition. Please delete the common definition and have separate server and client files. For more \
|
233
|
+
information, please see https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md
|
234
|
+
MSG
|
235
|
+
|
236
|
+
raise ReactOnRails::Error, msg
|
237
|
+
end
|
238
|
+
|
239
|
+
def raise_missing_client_component(component_name)
|
240
|
+
msg = <<~MSG
|
241
|
+
**ERROR** ReactOnRails: Component '#{component_name}' is missing a client specific file. For more \
|
242
|
+
information, please see https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md
|
243
|
+
MSG
|
244
|
+
|
245
|
+
raise ReactOnRails::Error, msg
|
246
|
+
end
|
247
|
+
|
248
|
+
def raise_shakapacker_version_incompatible
|
249
|
+
msg = <<~MSG
|
250
|
+
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{minimum_required_shakapacker_version} or \
|
251
|
+
above to use the automated bundle generation feature. The currently installed version is \
|
252
|
+
#{ReactOnRails::WebpackerUtils.shakapacker_version}.
|
253
|
+
MSG
|
254
|
+
|
255
|
+
raise ReactOnRails::Error, msg
|
256
|
+
end
|
257
|
+
|
258
|
+
def raise_webpacker_not_installed
|
259
|
+
msg = <<~MSG
|
260
|
+
**ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \
|
261
|
+
#{minimum_required_shakapacker_version} or above to use the \
|
262
|
+
automated bundle generation feature.
|
263
|
+
MSG
|
264
|
+
|
265
|
+
raise ReactOnRails::Error, msg
|
266
|
+
end
|
267
|
+
|
268
|
+
def shakapacker_major_minor_version
|
269
|
+
shakapacker_version = ReactOnRails::WebpackerUtils.shakapacker_version
|
270
|
+
match = shakapacker_version.match(ReactOnRails::VersionChecker::MAJOR_MINOR_PATCH_VERSION_REGEX)
|
271
|
+
|
272
|
+
[match[1].to_i, match[2].to_i, match[3].to_i]
|
273
|
+
end
|
274
|
+
|
275
|
+
def shackapacker_version_requirement_met?
|
276
|
+
major = shakapacker_major_minor_version[0]
|
277
|
+
minor = shakapacker_major_minor_version[1]
|
278
|
+
patch = shakapacker_major_minor_version[2]
|
279
|
+
|
280
|
+
major >= MINIMUM_SHAKAPACKER_MAJOR_VERSION && minor >= MINIMUM_SHAKAPACKER_MINOR_VERSION &&
|
281
|
+
patch >= MINIMUM_SHAKAPACKER_PATCH_VERSION
|
282
|
+
end
|
283
|
+
|
284
|
+
def minimum_required_shakapacker_version
|
285
|
+
"#{MINIMUM_SHAKAPACKER_MAJOR_VERSION}.#{MINIMUM_SHAKAPACKER_MINOR_VERSION}.#{MINIMUM_SHAKAPACKER_PATCH_VERSION}"
|
286
|
+
end
|
287
|
+
|
288
|
+
def prepend_to_file_if_not_present(file, text_to_prepend)
|
289
|
+
file_content = File.read(file)
|
290
|
+
|
291
|
+
return if file_content.include?(text_to_prepend)
|
292
|
+
|
293
|
+
content_with_prepended_text = text_to_prepend + file_content
|
294
|
+
File.write(file, content_with_prepended_text)
|
295
|
+
end
|
296
|
+
end
|
297
|
+
# rubocop:enable Metrics/ClassLength
|
298
|
+
end
|
@@ -165,12 +165,6 @@ module ReactOnRails
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def execjs_timer_polyfills
|
168
|
-
if ReactOnRails::Utils.react_on_rails_pro? &&
|
169
|
-
ReactOnRailsPro.configuration.respond_to?(:include_execjs_polyfills) &&
|
170
|
-
ReactOnRailsPro.configuration.include_execjs_polyfills == false
|
171
|
-
return ""
|
172
|
-
end
|
173
|
-
|
174
168
|
<<~JS
|
175
169
|
function getStackTrace () {
|
176
170
|
var stack;
|
@@ -26,12 +26,20 @@ module ReactOnRails
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def stale_generated_webpack_files
|
29
|
+
stale_generated_files(client_files)
|
30
|
+
end
|
31
|
+
|
32
|
+
def stale_generated_component_packs
|
33
|
+
stale_generated_files(component_pack_files)
|
34
|
+
end
|
35
|
+
|
36
|
+
def stale_generated_files(files)
|
29
37
|
manifest_needed = ReactOnRails::WebpackerUtils.using_webpacker? &&
|
30
38
|
!ReactOnRails::WebpackerUtils.manifest_exists?
|
31
39
|
|
32
40
|
return ["manifest.json"] if manifest_needed
|
33
41
|
|
34
|
-
most_recent_mtime = find_most_recent_mtime
|
42
|
+
most_recent_mtime = find_most_recent_mtime(files)
|
35
43
|
all_compiled_assets.each_with_object([]) do |webpack_generated_file, stale_gen_list|
|
36
44
|
if !File.exist?(webpack_generated_file) ||
|
37
45
|
File.mtime(webpack_generated_file) < most_recent_mtime
|
@@ -43,8 +51,8 @@ module ReactOnRails
|
|
43
51
|
|
44
52
|
private
|
45
53
|
|
46
|
-
def find_most_recent_mtime
|
47
|
-
|
54
|
+
def find_most_recent_mtime(files)
|
55
|
+
files.reduce(1.year.ago) do |newest_time, file|
|
48
56
|
mt = File.mtime(file)
|
49
57
|
mt > newest_time ? mt : newest_time
|
50
58
|
end
|
@@ -81,6 +89,14 @@ module ReactOnRails
|
|
81
89
|
@client_files ||= make_file_list(make_globs(source_path)).to_ary
|
82
90
|
end
|
83
91
|
|
92
|
+
def component_pack_files
|
93
|
+
make_file_list(make_globs(components_search_path)).to_ary
|
94
|
+
end
|
95
|
+
|
96
|
+
def components_search_path
|
97
|
+
"#{source_path}/**/#{ReactOnRails.configuration.components_subdirectory}"
|
98
|
+
end
|
99
|
+
|
84
100
|
def make_globs(dirs)
|
85
101
|
Array(dirs).map { |dir| File.join(dir, "**", "*") }
|
86
102
|
end
|
@@ -17,6 +17,12 @@ module ReactOnRails
|
|
17
17
|
Webpacker.dev_server.running?
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.shakapacker_version
|
21
|
+
return nil unless ReactOnRails::Utils.gem_available?("shakapacker")
|
22
|
+
|
23
|
+
Gem.loaded_specs["shakapacker"].version.to_s
|
24
|
+
end
|
25
|
+
|
20
26
|
# This returns either a URL for the webpack-dev-server, non-server bundle or
|
21
27
|
# the hashed server bundle if using the same bundle for the client.
|
22
28
|
# Otherwise returns a file path.
|
@@ -45,6 +51,14 @@ module ReactOnRails
|
|
45
51
|
Webpacker.config.source_path
|
46
52
|
end
|
47
53
|
|
54
|
+
def self.webpacker_source_entry_path
|
55
|
+
Webpacker.config.source_entry_path
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.nested_entries?
|
59
|
+
Webpacker.config.nested_entries?
|
60
|
+
end
|
61
|
+
|
48
62
|
def self.webpacker_public_output_path
|
49
63
|
# Webpacker has the full absolute path of webpacker output files in a Pathname
|
50
64
|
Webpacker.config.public_output_path.to_s
|
data/lib/react_on_rails.rb
CHANGED
@@ -19,6 +19,7 @@ require "react_on_rails/test_helper"
|
|
19
19
|
require "react_on_rails/git_utils"
|
20
20
|
require "react_on_rails/utils"
|
21
21
|
require "react_on_rails/webpacker_utils"
|
22
|
+
require "react_on_rails/packs_generator"
|
22
23
|
require "react_on_rails/test_helper/webpack_assets_compiler"
|
23
24
|
require "react_on_rails/test_helper/webpack_assets_status_checker"
|
24
25
|
require "react_on_rails/test_helper/ensure_assets_compiled"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :react_on_rails do
|
4
|
+
desc <<~DESC
|
5
|
+
If there is a file inside any directory matching config.components_subdirectory, this command generates corresponding packs.
|
6
|
+
DESC
|
7
|
+
|
8
|
+
task generate_packs: :environment do
|
9
|
+
ReactOnRails::PacksGenerator.generate
|
10
|
+
end
|
11
|
+
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-on-rails",
|
3
|
-
"version": "13.
|
3
|
+
"version": "13.1.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": {
|
@@ -15,10 +15,10 @@
|
|
15
15
|
"@babel/preset-react": "^7.12.10",
|
16
16
|
"@babel/types": "^7.12.10",
|
17
17
|
"@types/jest": "^26.0.18",
|
18
|
-
"@types/node": "^14.14.11",
|
19
18
|
"@types/react": "^16.9.23",
|
20
19
|
"@types/react-dom": "^16.9.5",
|
21
20
|
"@types/turbolinks": "^5.2.0",
|
21
|
+
"@types/webpack-env": "^1.17.0",
|
22
22
|
"@typescript-eslint/eslint-plugin": "^4.10.0",
|
23
23
|
"@typescript-eslint/parser": "^4.10.0",
|
24
24
|
"babelify": "^10.0.0",
|
data/yarn.lock
CHANGED
@@ -1594,11 +1594,6 @@
|
|
1594
1594
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.35.tgz#42c953a4e2b18ab931f72477e7012172f4ffa313"
|
1595
1595
|
integrity sha512-Lt+wj8NVPx0zUmUwumiVXapmaLUcAk3yPuHCFVXras9k5VT9TdhJqKqGVUQCD60OTMCl0qxJ57OiTL0Mic3Iag==
|
1596
1596
|
|
1597
|
-
"@types/node@^14.14.11":
|
1598
|
-
version "14.14.11"
|
1599
|
-
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.11.tgz#fc25a4248a5e8d0837019b1d170146d07334abe0"
|
1600
|
-
integrity sha512-BJ97wAUuU3NUiUCp44xzUFquQEvnk1wu7q4CMEUYKJWjdkr0YWYDsm4RFtAvxYsNjLsKcrFt6RvK8r+mnzMbEQ==
|
1601
|
-
|
1602
1597
|
"@types/normalize-package-data@^2.4.0":
|
1603
1598
|
version "2.4.0"
|
1604
1599
|
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
|
@@ -1639,6 +1634,11 @@
|
|
1639
1634
|
resolved "https://registry.yarnpkg.com/@types/turbolinks/-/turbolinks-5.2.0.tgz#cdfd3691143ea2f452113c2a06bd12d9a88b25d6"
|
1640
1635
|
integrity sha512-xEgHb25lj23EaUlsU3Y4KlFH7elhlYINGSnqyn/8zmcMnenY4Idyjk/x9kw1kOoOToY3de9fD8NSwRzNc6f5nw==
|
1641
1636
|
|
1637
|
+
"@types/webpack-env@^1.17.0":
|
1638
|
+
version "1.17.0"
|
1639
|
+
resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.17.0.tgz#f99ce359f1bfd87da90cc4a57cab0a18f34a48d0"
|
1640
|
+
integrity sha512-eHSaNYEyxRA5IAG0Ym/yCyf86niZUIF/TpWKofQI/CVfh5HsMEUyfE2kwFxha4ow0s5g0LfISQxpDKjbRDrizw==
|
1641
|
+
|
1642
1642
|
"@types/yargs-parser@*":
|
1643
1643
|
version "20.2.0"
|
1644
1644
|
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.0.tgz#dd3e6699ba3237f0348cd085e4698780204842f9"
|
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.
|
4
|
+
version: 13.1.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-
|
11
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -168,10 +168,11 @@ files:
|
|
168
168
|
- docs/contributor-info/releasing.md
|
169
169
|
- docs/deployment/elastic-beanstalk.md
|
170
170
|
- docs/deployment/heroku-deployment.md
|
171
|
+
- docs/getting-started.md
|
171
172
|
- docs/guides/client-vs-server-rendering.md
|
172
173
|
- docs/guides/configuration.md
|
173
174
|
- docs/guides/deployment.md
|
174
|
-
- docs/guides/
|
175
|
+
- docs/guides/file-system-based-automated-bundle-generation.md
|
175
176
|
- docs/guides/hmr-and-hot-reloading-with-the-webpack-dev-server.md
|
176
177
|
- docs/guides/how-react-on-rails-works.md
|
177
178
|
- docs/guides/how-to-conditionally-server-render-based-on-device-type.md
|
@@ -277,6 +278,7 @@ files:
|
|
277
278
|
- lib/react_on_rails/locales/base.rb
|
278
279
|
- lib/react_on_rails/locales/to_js.rb
|
279
280
|
- lib/react_on_rails/locales/to_json.rb
|
281
|
+
- lib/react_on_rails/packs_generator.rb
|
280
282
|
- lib/react_on_rails/prerender_error.rb
|
281
283
|
- lib/react_on_rails/react_component/render_options.rb
|
282
284
|
- lib/react_on_rails/server_rendering_js_code.rb
|
@@ -292,6 +294,7 @@ files:
|
|
292
294
|
- lib/react_on_rails/version_syntax_converter.rb
|
293
295
|
- lib/react_on_rails/webpacker_utils.rb
|
294
296
|
- lib/tasks/assets.rake
|
297
|
+
- lib/tasks/generate_packs.rake
|
295
298
|
- lib/tasks/locale.rake
|
296
299
|
- package-scripts.yml
|
297
300
|
- package.json
|