react_on_rails 15.0.0.rc.1 → 15.0.0.rc.2
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 +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/eslint.config.ts +8 -1
- data/knip.ts +3 -0
- data/lib/generators/react_on_rails/templates/base/base/config/webpack/development.js.tt +1 -5
- data/lib/react_on_rails/configuration.rb +1 -1
- data/lib/react_on_rails/helper.rb +1 -2
- data/lib/react_on_rails/packer_utils.rb +10 -13
- data/lib/react_on_rails/packs_generator.rb +1 -1
- data/lib/react_on_rails/react_component/render_options.rb +1 -9
- data/lib/react_on_rails/version.rb +1 -1
- data/lib/react_on_rails/version_checker.rb +14 -20
- 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: 50ca168413057bb25fbd6ca60307bb48baceabcef86cbbd4a8141bb5913e9ca5
|
4
|
+
data.tar.gz: 6cf924cd26ae04b10d303e0c761daf19af7bd3d15417421e56c6492b6e4264ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3485bf92e659aa921d0352ee43e3cd56b836818c17a6d643332a5e5fecaac0da696e2ab1723215d069d25201cf1da41bfadea2546bf435bfea01924ba4010096
|
7
|
+
data.tar.gz: a7e120190894dd8b34637274a6fb8407c8ab6b7a7e6608b744244868d661ba8e11e3d1925a7eaa86d27905cc2db2c870453f6a7af8c795c504d1dd988f0d7130
|
data/CHANGELOG.md
CHANGED
@@ -23,6 +23,14 @@ After a release, please make sure to run `bundle exec rake update_changelog`. Th
|
|
23
23
|
|
24
24
|
Changes since the last non-beta release.
|
25
25
|
|
26
|
+
#### Fixed
|
27
|
+
|
28
|
+
- Enable support for ReactRefreshWebpackPlugin v0.6.0 by adding conditional logic regarding configuration. [PR 1748](https://github.com/shakacode/react_on_rails/pull/1748) by [judahmeek](https://github.com/judahmeek).
|
29
|
+
|
30
|
+
- Replace RenderOptions.renderRequestId and use local trackers instead. This change should only be relevant to ReactOnRails Pro users. [PR 1745](https://github.com/shakacode/react_on_rails/pull/1745) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
|
31
|
+
|
32
|
+
- Fixed invalid warnings about non-exact versions when using a pre-release version of React on Rails, as well as missing warnings when using different pre-release versions of the gem and the Node package. [PR 1742](https://github.com/shakacode/react_on_rails/pull/1742) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
|
33
|
+
|
26
34
|
### [15.0.0-rc.1] - 2025-06-18
|
27
35
|
|
28
36
|
#### Improved
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -92,7 +92,7 @@ Ruby on Rails >=5, rails/webpacker >= 4.2 or shakapacker > 6, Ruby >= 3.0.0
|
|
92
92
|
|
93
93
|
# Support
|
94
94
|
|
95
|
-
- [Click to join **React + Rails Slack**](https://
|
95
|
+
- [Click to join **React + Rails Slack**](https://join.slack.com/t/reactrails/shared_invite/zt-38oicm9d0-OO0V~bdg4aYNuZuUbRFSXg).
|
96
96
|
|
97
97
|
- [**Subscribe**](https://app.mailerlite.com/webforms/landing/l1d9x5) for announcements of new releases of React on Rails and of our latest [blog articles](https://blog.shakacode.com) and tutorials.
|
98
98
|
- [Discussions](https://github.com/shakacode/react_on_rails/discussions): Post your questions regarding React on Rails
|
data/eslint.config.ts
CHANGED
@@ -2,6 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import { globalIgnores } from 'eslint/config';
|
3
3
|
import jest from 'eslint-plugin-jest';
|
4
4
|
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
5
|
+
import testingLibrary from 'eslint-plugin-testing-library';
|
5
6
|
import globals from 'globals';
|
6
7
|
import tsEslint from 'typescript-eslint';
|
7
8
|
import { includeIgnoreFile } from '@eslint/compat';
|
@@ -198,11 +199,17 @@ const config = tsEslint.config([
|
|
198
199
|
{
|
199
200
|
files: ['node_package/tests/**', '**/*.test.{js,jsx,ts,tsx}'],
|
200
201
|
|
201
|
-
extends: [
|
202
|
+
extends: [
|
203
|
+
jest.configs['flat/recommended'],
|
204
|
+
jest.configs['flat/style'],
|
205
|
+
testingLibrary.configs['flat/dom'],
|
206
|
+
],
|
202
207
|
|
203
208
|
rules: {
|
204
209
|
// Allows Jest mocks before import
|
205
210
|
'import/first': 'off',
|
211
|
+
// Avoiding these methods complicates tests and isn't useful for our purposes
|
212
|
+
'testing-library/no-node-access': 'off',
|
206
213
|
},
|
207
214
|
},
|
208
215
|
// must be the last config in the array
|
data/knip.ts
CHANGED
@@ -45,6 +45,9 @@ const config: KnipConfig = {
|
|
45
45
|
'@eslint/js',
|
46
46
|
// used by Jest
|
47
47
|
'jsdom',
|
48
|
+
// This is an optional peer dependency because users without RSC don't need it
|
49
|
+
// but Knip doesn't like such dependencies to be referenced directly in code
|
50
|
+
'react-on-rails-rsc',
|
48
51
|
],
|
49
52
|
},
|
50
53
|
'spec/dummy': {
|
@@ -13,11 +13,7 @@ const developmentEnvOnly = (clientWebpackConfig, _serverWebpackConfig) => {
|
|
13
13
|
// eslint-disable-next-line global-require
|
14
14
|
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
|
15
15
|
clientWebpackConfig.plugins.push(
|
16
|
-
new ReactRefreshWebpackPlugin({
|
17
|
-
overlay: {
|
18
|
-
sockPort: devServer.port,
|
19
|
-
},
|
20
|
-
}),
|
16
|
+
new ReactRefreshWebpackPlugin({}),
|
21
17
|
);
|
22
18
|
}
|
23
19
|
};
|
@@ -180,7 +180,7 @@ module ReactOnRails
|
|
180
180
|
1. Use :sync or :defer loading strategy instead of :async
|
181
181
|
2. Upgrade to Shakapacker v8.2.0 or above to enable async script loading
|
182
182
|
MSG
|
183
|
-
if PackerUtils.shakapacker_version_requirement_met?(
|
183
|
+
if PackerUtils.shakapacker_version_requirement_met?("8.2.0")
|
184
184
|
self.generated_component_packs_loading_strategy ||= :async
|
185
185
|
elsif generated_component_packs_loading_strategy.nil?
|
186
186
|
Rails.logger.warn("**WARNING** #{msg}")
|
@@ -650,8 +650,7 @@ module ReactOnRails
|
|
650
650
|
"data-trace" => (render_options.trace ? true : nil),
|
651
651
|
"data-dom-id" => render_options.dom_id,
|
652
652
|
"data-store-dependencies" => render_options.store_dependencies&.to_json,
|
653
|
-
"data-force-load" => (render_options.force_load ? true : nil)
|
654
|
-
"data-render-request-id" => render_options.render_request_id)
|
653
|
+
"data-force-load" => (render_options.force_load ? true : nil))
|
655
654
|
|
656
655
|
if render_options.force_load
|
657
656
|
component_specification_tag.concat(
|
@@ -10,7 +10,7 @@ module ReactOnRails
|
|
10
10
|
return @using_shakapacker_const if defined?(@using_shakapacker_const)
|
11
11
|
|
12
12
|
@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
|
13
|
-
shakapacker_version_requirement_met?(
|
13
|
+
shakapacker_version_requirement_met?("7.0.0")
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.using_webpacker_const?
|
@@ -57,15 +57,16 @@ module ReactOnRails
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.shakapacker_version_as_array
|
60
|
-
|
60
|
+
return @shakapacker_version_as_array if defined?(@shakapacker_version_as_array)
|
61
61
|
|
62
|
-
|
62
|
+
match = shakapacker_version.match(ReactOnRails::VersionChecker::VERSION_PARTS_REGEX)
|
63
|
+
|
64
|
+
# match[4] is the pre-release version, not normally a number but something like "beta.1" or `nil`
|
65
|
+
@shakapacker_version_as_array = [match[1].to_i, match[2].to_i, match[3].to_i, match[4]].compact
|
63
66
|
end
|
64
67
|
|
65
68
|
def self.shakapacker_version_requirement_met?(required_version)
|
66
|
-
|
67
|
-
|
68
|
-
Gem::Version.new(shakapacker_version) >= Gem::Version.new(req_ver)
|
69
|
+
Gem::Version.new(shakapacker_version) >= Gem::Version.new(required_version)
|
69
70
|
end
|
70
71
|
|
71
72
|
# This returns either a URL for the webpack-dev-server, non-server bundle or
|
@@ -171,9 +172,9 @@ module ReactOnRails
|
|
171
172
|
|
172
173
|
def self.raise_shakapacker_version_incompatible_for_autobundling
|
173
174
|
msg = <<~MSG
|
174
|
-
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{
|
175
|
+
**ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or \
|
175
176
|
above to use the automated bundle generation feature. The currently installed version is \
|
176
|
-
#{
|
177
|
+
#{ReactOnRails::PackerUtils.shakapacker_version}.
|
177
178
|
MSG
|
178
179
|
|
179
180
|
raise ReactOnRails::Error, msg
|
@@ -182,15 +183,11 @@ module ReactOnRails
|
|
182
183
|
def self.raise_shakapacker_not_installed
|
183
184
|
msg = <<~MSG
|
184
185
|
**ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \
|
185
|
-
#{
|
186
|
+
#{ReactOnRails::PacksGenerator::MINIMUM_SHAKAPACKER_VERSION} or above to use the \
|
186
187
|
automated bundle generation feature.
|
187
188
|
MSG
|
188
189
|
|
189
190
|
raise ReactOnRails::Error, msg
|
190
191
|
end
|
191
|
-
|
192
|
-
def self.semver_to_string(ary)
|
193
|
-
"#{ary[0]}.#{ary[1]}.#{ary[2]}"
|
194
|
-
end
|
195
192
|
end
|
196
193
|
end
|
@@ -6,7 +6,7 @@ module ReactOnRails
|
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
7
7
|
class PacksGenerator
|
8
8
|
CONTAINS_CLIENT_OR_SERVER_REGEX = /\.(server|client)($|\.)/
|
9
|
-
MINIMUM_SHAKAPACKER_VERSION =
|
9
|
+
MINIMUM_SHAKAPACKER_VERSION = "6.5.1"
|
10
10
|
|
11
11
|
def self.instance
|
12
12
|
@instance ||= PacksGenerator.new
|
@@ -15,17 +15,9 @@ module ReactOnRails
|
|
15
15
|
def initialize(react_component_name: required("react_component_name"), options: required("options"))
|
16
16
|
@react_component_name = react_component_name.camelize
|
17
17
|
@options = options
|
18
|
-
# The render_request_id serves as a unique identifier for each render request.
|
19
|
-
# We cannot rely solely on dom_id, as it should be unique for each component on the page,
|
20
|
-
# but the server can render the same page multiple times concurrently for different users.
|
21
|
-
# Therefore, we need an additional unique identifier that can be used both on the client and server.
|
22
|
-
# This ID can also be used to associate specific data with a particular rendered component
|
23
|
-
# on either the server or client.
|
24
|
-
# This ID is only present if RSC support is enabled because it's only used in that case.
|
25
|
-
@render_request_id = self.class.generate_request_id if ReactOnRails::Utils.rsc_support_enabled?
|
26
18
|
end
|
27
19
|
|
28
|
-
attr_reader :react_component_name
|
20
|
+
attr_reader :react_component_name
|
29
21
|
|
30
22
|
def throw_js_errors
|
31
23
|
options.fetch(:throw_js_errors, false)
|
@@ -6,7 +6,8 @@ module ReactOnRails
|
|
6
6
|
class VersionChecker
|
7
7
|
attr_reader :node_package_version
|
8
8
|
|
9
|
-
|
9
|
+
# Semver uses - to separate pre-release, but RubyGems use .
|
10
|
+
VERSION_PARTS_REGEX = /(\d+)\.(\d+)\.(\d+)(?:[-.]([0-9A-Za-z.-]+))?/
|
10
11
|
|
11
12
|
def self.build
|
12
13
|
new(NodePackageVersion.build)
|
@@ -23,13 +24,7 @@ module ReactOnRails
|
|
23
24
|
return if node_package_version.raw.nil? || node_package_version.local_path_or_url?
|
24
25
|
return log_node_semver_version_warning if node_package_version.semver_wildcard?
|
25
26
|
|
26
|
-
|
27
|
-
gem_major_minor_patch = gem_major_minor_patch_version
|
28
|
-
versions_match = node_major_minor_patch[0] == gem_major_minor_patch[0] &&
|
29
|
-
node_major_minor_patch[1] == gem_major_minor_patch[1] &&
|
30
|
-
node_major_minor_patch[2] == gem_major_minor_patch[2]
|
31
|
-
|
32
|
-
log_differing_versions_warning unless versions_match
|
27
|
+
log_differing_versions_warning unless node_package_version.parts == gem_version_parts
|
33
28
|
end
|
34
29
|
|
35
30
|
private
|
@@ -39,20 +34,20 @@ module ReactOnRails
|
|
39
34
|
Detected: #{node_package_version.raw}
|
40
35
|
gem: #{gem_version}
|
41
36
|
Ensure the installed version of the gem is the same as the version of
|
42
|
-
your installed
|
43
|
-
Do not use
|
37
|
+
your installed Node package. Do not use >= or ~> in your Gemfile for react_on_rails.
|
38
|
+
Do not use ^, ~, or other non-exact versions in your package.json for react-on-rails.
|
44
39
|
Run `yarn add react-on-rails --exact` in the directory containing folder node_modules.
|
45
40
|
MSG
|
46
41
|
end
|
47
42
|
|
48
43
|
def log_differing_versions_warning
|
49
|
-
msg = "**WARNING** ReactOnRails: ReactOnRails gem and
|
44
|
+
msg = "**WARNING** ReactOnRails: ReactOnRails gem and Node package versions do not match\n#{common_error_msg}"
|
50
45
|
Rails.logger.warn(msg)
|
51
46
|
end
|
52
47
|
|
53
48
|
def log_node_semver_version_warning
|
54
|
-
msg = "**WARNING** ReactOnRails: Your
|
55
|
-
"
|
49
|
+
msg = "**WARNING** ReactOnRails: Your Node package version for react-on-rails is not an exact version\n" \
|
50
|
+
"#{common_error_msg}"
|
56
51
|
Rails.logger.warn(msg)
|
57
52
|
end
|
58
53
|
|
@@ -60,9 +55,8 @@ module ReactOnRails
|
|
60
55
|
ReactOnRails::VERSION
|
61
56
|
end
|
62
57
|
|
63
|
-
def
|
64
|
-
|
65
|
-
[match[1], match[2], match[3]]
|
58
|
+
def gem_version_parts
|
59
|
+
gem_version.match(VERSION_PARTS_REGEX)&.captures&.compact
|
66
60
|
end
|
67
61
|
|
68
62
|
class NodePackageVersion
|
@@ -100,7 +94,7 @@ module ReactOnRails
|
|
100
94
|
# See https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies
|
101
95
|
# We want to disallow all expressions other than exact versions
|
102
96
|
# and the ones allowed by local_path_or_url?
|
103
|
-
raw.blank? || raw.
|
97
|
+
raw.blank? || raw.start_with?(/[~^><*]/) || raw.include?(" - ") || raw.include?(" || ")
|
104
98
|
end
|
105
99
|
|
106
100
|
def local_path_or_url?
|
@@ -110,15 +104,15 @@ module ReactOnRails
|
|
110
104
|
!raw.nil? && raw.include?("/") && !raw.start_with?("npm:")
|
111
105
|
end
|
112
106
|
|
113
|
-
def
|
107
|
+
def parts
|
114
108
|
return if local_path_or_url?
|
115
109
|
|
116
|
-
match = raw.match(
|
110
|
+
match = raw.match(VERSION_PARTS_REGEX)
|
117
111
|
unless match
|
118
112
|
raise ReactOnRails::Error, "Cannot parse version number '#{raw}' (only exact versions are supported)"
|
119
113
|
end
|
120
114
|
|
121
|
-
|
115
|
+
match.captures.compact
|
122
116
|
end
|
123
117
|
|
124
118
|
private
|