react_on_rails 16.4.0.rc.3 → 16.4.0.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/Gemfile.lock +1 -1
- data/lib/react_on_rails/packs_generator.rb +44 -0
- data/lib/react_on_rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0c040d5433fa1cc76aeb4a740df1f95eed1fca4fd0da9d62a8820a7c849ad3a4
|
|
4
|
+
data.tar.gz: b4e40695d2c0409e523d27017724e626cb13e6ce74489e1930e714b151de0cc2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7827cb7f3064b9740256f3d94803968624318a8849571cefcc238e498b92f9c08bfbc362c194cbc4eac773d55ad65283a32c781ad4dea817d2c412857f33846
|
|
7
|
+
data.tar.gz: 184cf7171b73091ad0a219604dc1d09b3419b024d524b5b43a696efc5995d30fbad4de5f7091944f049c086f6fd44c505dba5aa436258ed9ee9c95f41b88c6c3
|
data/Gemfile.lock
CHANGED
|
@@ -58,6 +58,29 @@ module ReactOnRails
|
|
|
58
58
|
store_to_path.each_value { |store_path| create_store_pack(store_path, verbose: verbose) }
|
|
59
59
|
|
|
60
60
|
create_server_pack(verbose: verbose) if ReactOnRails.configuration.server_bundle_js_file.present?
|
|
61
|
+
|
|
62
|
+
log_rsc_classification_summary if ReactOnRails::Utils.rsc_support_enabled?
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def log_rsc_classification_summary
|
|
66
|
+
all_components = common_component_to_path.merge(client_component_to_path)
|
|
67
|
+
server = []
|
|
68
|
+
client = []
|
|
69
|
+
|
|
70
|
+
all_components.each do |name, path|
|
|
71
|
+
if client_entrypoint?(path)
|
|
72
|
+
client << name
|
|
73
|
+
else
|
|
74
|
+
server << name
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
return if server.empty? && client.empty?
|
|
79
|
+
|
|
80
|
+
summary = +"[react_on_rails] RSC component classification:\n"
|
|
81
|
+
summary << " Server components (no 'use client'): #{server.any? ? server.join(', ') : '(none)'}\n"
|
|
82
|
+
summary << " Client components ('use client' found): #{client.any? ? client.join(', ') : '(none)'}"
|
|
83
|
+
puts Rainbow(summary).cyan
|
|
61
84
|
end
|
|
62
85
|
|
|
63
86
|
def check_for_component_store_name_conflicts
|
|
@@ -128,11 +151,32 @@ module ReactOnRails
|
|
|
128
151
|
first_js_statement_in_code(content).match?(/^["']use client["'](?:;|\s|$)/)
|
|
129
152
|
end
|
|
130
153
|
|
|
154
|
+
# Patterns that indicate a file likely uses client-side features.
|
|
155
|
+
# Used as a heuristic warning — false positives (e.g., patterns in comments) are acceptable
|
|
156
|
+
# because this is a warning, not an error.
|
|
157
|
+
CLIENT_API_PATTERN = /\b(useState|useEffect|useReducer|useCallback|useMemo|useRef|useLayoutEffect|useImperativeHandle|useContext|useSyncExternalStore|useTransition|useDeferredValue)\b|\b(onClick|onChange|onSubmit|onFocus|onBlur|onKeyDown|onKeyUp|onKeyPress|onMouseDown|onMouseUp|onMouseEnter|onMouseLeave)\s*[={]|\bextends\s+(React\.)?(Component|PureComponent)\b/ # rubocop:disable Layout/LineLength
|
|
158
|
+
|
|
159
|
+
def warn_if_likely_client_component(file_path, component)
|
|
160
|
+
content = File.read(file_path)
|
|
161
|
+
matches = content.scan(CLIENT_API_PATTERN).flatten.compact.reject(&:empty?).uniq
|
|
162
|
+
|
|
163
|
+
return if matches.empty?
|
|
164
|
+
|
|
165
|
+
puts Rainbow(
|
|
166
|
+
"[react_on_rails] WARNING: '#{component}' (#{file_path}) appears to use client-side APIs " \
|
|
167
|
+
"(#{matches.first(3).join(', ')}#{matches.length > 3 ? ', ...' : ''}) " \
|
|
168
|
+
"but is missing the 'use client' directive. It will be registered as a server component.\n" \
|
|
169
|
+
"If this is a client component, add '\"use client\";' as the first line of the file."
|
|
170
|
+
).yellow
|
|
171
|
+
end
|
|
172
|
+
|
|
131
173
|
def pack_file_contents(file_path)
|
|
132
174
|
registered_component_name = component_name(file_path)
|
|
133
175
|
load_server_components = ReactOnRails::Utils.rsc_support_enabled?
|
|
134
176
|
|
|
135
177
|
if load_server_components && !client_entrypoint?(file_path)
|
|
178
|
+
warn_if_likely_client_component(file_path, registered_component_name)
|
|
179
|
+
|
|
136
180
|
return <<~FILE_CONTENT.strip
|
|
137
181
|
import registerServerComponent from '#{react_on_rails_npm_package}/registerServerComponent/client';
|
|
138
182
|
|
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: 16.4.0.rc.
|
|
4
|
+
version: 16.4.0.rc.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Gordon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|