react_on_rails 17.0.0.rc.7 → 17.0.0.rc.8
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/Gemfile.lock +1 -1
- data/lib/react_on_rails/doctor.rb +9 -5
- data/lib/react_on_rails/rsc_rspack_support.rb +54 -15
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47532eab3f7e0341d454e53ac835f3b9034d0af9a0550107e62561701ac6d4f0
|
|
4
|
+
data.tar.gz: a4103c943cd5fc7854b65b1815bd51003c176d9578201a4ca7cfc93bde1ee883
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b045aba9d3e83811a02f1fe26f8f7d47d4ab686cb9d224f0feb07cb91c052b3c7ef30065522bea5a84793549a0812cf926ba7653ed56cb41e793a1c61aa3242
|
|
7
|
+
data.tar.gz: 6145020e4b0102198e0f3561c1beedfbc135d45da5d6f9af02d6d7a6fc6fe579203c636f133a5b1223c183045a1f18966d1a42a2fae682d12e2b255dda5f8a36
|
data/Gemfile.lock
CHANGED
|
@@ -3644,18 +3644,18 @@ module ReactOnRails
|
|
|
3644
3644
|
end
|
|
3645
3645
|
|
|
3646
3646
|
def detected_rspack_version_for_rsc
|
|
3647
|
-
package_root =
|
|
3647
|
+
package_root = resolved_rsc_package_root
|
|
3648
3648
|
installed_version = nil
|
|
3649
3649
|
unless package_root_missing?(package_root)
|
|
3650
3650
|
installed_version = installed_package_version(package_root, RSC_RSPACK_PACKAGE)
|
|
3651
3651
|
end
|
|
3652
|
-
installed_version || declared_rspack_version_for_rsc
|
|
3652
|
+
installed_version || declared_rspack_version_for_rsc(package_root)
|
|
3653
3653
|
rescue StandardError
|
|
3654
3654
|
nil
|
|
3655
3655
|
end
|
|
3656
3656
|
|
|
3657
|
-
def declared_rspack_version_for_rsc
|
|
3658
|
-
package_json_path = package_json_path_for("declared Rspack version")
|
|
3657
|
+
def declared_rspack_version_for_rsc(package_root = resolved_rsc_package_root)
|
|
3658
|
+
package_json_path = package_json_path_for("declared Rspack version", package_root)
|
|
3659
3659
|
return nil unless package_json_path
|
|
3660
3660
|
|
|
3661
3661
|
rsc_declared_package_version(package_json_path, RSC_RSPACK_PACKAGE)
|
|
@@ -3665,10 +3665,14 @@ module ReactOnRails
|
|
|
3665
3665
|
rsc_rspack_version_requirement_error(
|
|
3666
3666
|
rspack_version,
|
|
3667
3667
|
error_prefix: "🚫",
|
|
3668
|
-
package_json_path: package_json_path_for("RSC Rspack version")
|
|
3668
|
+
package_json_path: package_json_path_for("RSC Rspack version", resolved_rsc_package_root)
|
|
3669
3669
|
)
|
|
3670
3670
|
end
|
|
3671
3671
|
|
|
3672
|
+
def resolved_rsc_package_root
|
|
3673
|
+
rsc_configured_package_root(resolved_package_root)
|
|
3674
|
+
end
|
|
3675
|
+
|
|
3672
3676
|
def check_rsc_rspack_lazy_compilation
|
|
3673
3677
|
return unless active_assets_bundler == "rspack"
|
|
3674
3678
|
|
|
@@ -5,7 +5,7 @@ require "open3"
|
|
|
5
5
|
require_relative "utils"
|
|
6
6
|
|
|
7
7
|
module ReactOnRails
|
|
8
|
-
module RscRspackSupport
|
|
8
|
+
module RscRspackSupport # rubocop:disable Metrics/ModuleLength
|
|
9
9
|
RSC_RSPACK_PACKAGE = "@rspack/core"
|
|
10
10
|
RSC_RSPACK_V2_PACKAGES = %w[
|
|
11
11
|
@rspack/core
|
|
@@ -37,6 +37,11 @@ module ReactOnRails
|
|
|
37
37
|
[a-z0-9][a-z0-9._-]*
|
|
38
38
|
\z
|
|
39
39
|
}x
|
|
40
|
+
NODE_PACKAGE_RESOLUTION_SCRIPT = <<~JS
|
|
41
|
+
const packageName = process.argv[1];
|
|
42
|
+
const nodeModulesPath = process.argv[2];
|
|
43
|
+
console.log(require.resolve(packageName + '/package.json', { paths: [nodeModulesPath] }));
|
|
44
|
+
JS
|
|
40
45
|
|
|
41
46
|
private
|
|
42
47
|
|
|
@@ -83,25 +88,32 @@ module ReactOnRails
|
|
|
83
88
|
MSG
|
|
84
89
|
end
|
|
85
90
|
|
|
86
|
-
def rsc_installed_package_version(package_root, package_name, &)
|
|
87
|
-
version = rsc_installed_package_json(package_root, package_name, &)&.fetch("version", nil)
|
|
91
|
+
def rsc_installed_package_version(package_root, package_name, node_modules_path: nil, &)
|
|
92
|
+
version = rsc_installed_package_json(package_root, package_name, node_modules_path:, &)&.fetch("version", nil)
|
|
88
93
|
version if version&.match?(/\A\d+\.\d+\.\d+/)
|
|
89
94
|
end
|
|
90
95
|
|
|
91
|
-
def rsc_flat_installed_package_version(package_root, package_name)
|
|
92
|
-
version = rsc_flat_installed_package_json(package_root, package_name)&.fetch("version", nil)
|
|
96
|
+
def rsc_flat_installed_package_version(package_root, package_name, node_modules_path: nil)
|
|
97
|
+
version = rsc_flat_installed_package_json(package_root, package_name, node_modules_path:)&.fetch("version", nil)
|
|
93
98
|
version if version&.match?(/\A\d+\.\d+\.\d+/)
|
|
94
99
|
end
|
|
95
100
|
|
|
96
|
-
def rsc_installed_package_json(package_root, package_name, &)
|
|
101
|
+
def rsc_installed_package_json(package_root, package_name, node_modules_path: nil, &)
|
|
97
102
|
return nil unless valid_rsc_package_name?(package_name)
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
resolved_path = rsc_resolved_node_package_json_path(
|
|
105
|
+
package_root,
|
|
106
|
+
package_name,
|
|
107
|
+
NODE_PACKAGE_RESOLUTION_SCRIPT,
|
|
108
|
+
node_modules_path:,
|
|
109
|
+
&
|
|
110
|
+
)
|
|
101
111
|
# package_name has passed PACKAGE_NAME_PATTERN, so this fallback cannot escape node_modules.
|
|
102
112
|
# It covers classic flat node_modules layouts; pnpm virtual-store layouts rely on Node resolution above.
|
|
103
113
|
# Limitation: a stale orphaned directory can still be read if Node resolution fails.
|
|
104
|
-
|
|
114
|
+
if resolved_path.empty?
|
|
115
|
+
resolved_path = rsc_flat_installed_package_json_path(package_root, package_name, node_modules_path:)
|
|
116
|
+
end
|
|
105
117
|
return nil unless File.exist?(resolved_path)
|
|
106
118
|
|
|
107
119
|
JSON.parse(File.read(resolved_path))
|
|
@@ -109,10 +121,10 @@ module ReactOnRails
|
|
|
109
121
|
nil
|
|
110
122
|
end
|
|
111
123
|
|
|
112
|
-
def rsc_flat_installed_package_json(package_root, package_name)
|
|
124
|
+
def rsc_flat_installed_package_json(package_root, package_name, node_modules_path: nil)
|
|
113
125
|
return nil unless valid_rsc_package_name?(package_name)
|
|
114
126
|
|
|
115
|
-
package_json_path = rsc_flat_installed_package_json_path(package_root, package_name)
|
|
127
|
+
package_json_path = rsc_flat_installed_package_json_path(package_root, package_name, node_modules_path:)
|
|
116
128
|
return nil unless File.exist?(package_json_path)
|
|
117
129
|
|
|
118
130
|
JSON.parse(File.read(package_json_path))
|
|
@@ -120,8 +132,8 @@ module ReactOnRails
|
|
|
120
132
|
nil
|
|
121
133
|
end
|
|
122
134
|
|
|
123
|
-
def rsc_flat_installed_package_json_path(package_root, package_name)
|
|
124
|
-
File.join(package_root,
|
|
135
|
+
def rsc_flat_installed_package_json_path(package_root, package_name, node_modules_path: nil)
|
|
136
|
+
File.join(rsc_node_modules_path(package_root, node_modules_path), package_name, "package.json")
|
|
125
137
|
end
|
|
126
138
|
|
|
127
139
|
def rsc_support_enabled_config_value
|
|
@@ -164,9 +176,16 @@ module ReactOnRails
|
|
|
164
176
|
major.to_i
|
|
165
177
|
end
|
|
166
178
|
|
|
167
|
-
def rsc_resolved_node_package_json_path(package_root, package_name, script, &)
|
|
179
|
+
def rsc_resolved_node_package_json_path(package_root, package_name, script, node_modules_path: nil, &)
|
|
168
180
|
# Boot/doctor validation only. This is intentionally outside the request path.
|
|
169
|
-
stdout, _stderr, status = Open3.capture3(
|
|
181
|
+
stdout, _stderr, status = Open3.capture3(
|
|
182
|
+
"node",
|
|
183
|
+
"-e",
|
|
184
|
+
script,
|
|
185
|
+
package_name,
|
|
186
|
+
rsc_node_modules_path(package_root, node_modules_path),
|
|
187
|
+
chdir: package_root
|
|
188
|
+
)
|
|
170
189
|
unless status.success?
|
|
171
190
|
yield(package_name) if block_given?
|
|
172
191
|
return ""
|
|
@@ -178,6 +197,26 @@ module ReactOnRails
|
|
|
178
197
|
""
|
|
179
198
|
end
|
|
180
199
|
|
|
200
|
+
def rsc_configured_package_root(default_package_root)
|
|
201
|
+
configured_path = ReactOnRails.configuration.node_modules_location.to_s
|
|
202
|
+
return default_package_root if configured_path.empty?
|
|
203
|
+
|
|
204
|
+
rails_root = defined?(Rails) && Rails.respond_to?(:root) ? Rails.root.to_s : Dir.pwd
|
|
205
|
+
File.expand_path(configured_path, rails_root)
|
|
206
|
+
rescue StandardError
|
|
207
|
+
default_package_root
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def rsc_node_modules_path(package_root, node_modules_path = nil)
|
|
211
|
+
resolved_node_modules_path = node_modules_path.to_s
|
|
212
|
+
return resolved_node_modules_path unless resolved_node_modules_path.empty?
|
|
213
|
+
|
|
214
|
+
package_root_string = package_root.to_s
|
|
215
|
+
return package_root_string if File.basename(package_root_string) == "node_modules"
|
|
216
|
+
|
|
217
|
+
File.join(package_root_string, "node_modules")
|
|
218
|
+
end
|
|
219
|
+
|
|
181
220
|
def rsc_detected_package_manager
|
|
182
221
|
ReactOnRails::Utils.detect_package_manager
|
|
183
222
|
rescue StandardError
|
|
@@ -262,7 +262,7 @@ module ReactOnRails
|
|
|
262
262
|
end
|
|
263
263
|
|
|
264
264
|
def detected_rspack_version_for_rsc
|
|
265
|
-
package_root = File.dirname(node_package_version.package_json)
|
|
265
|
+
package_root = rsc_configured_package_root(File.dirname(node_package_version.package_json))
|
|
266
266
|
declared_spec = package_dependency_spec(RSC_RSPACK_PACKAGE)
|
|
267
267
|
declared_version = rsc_normalized_declared_package_version(declared_spec) || declared_spec
|
|
268
268
|
declared_major_version = rsc_package_major_version(declared_spec)
|