react_on_rails 15.0.0.alpha.1 → 15.0.0.alpha.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d60051000fbd817b3499b1de6f13c9abeaf5627bee250c50bf0d748ce3532a5
4
- data.tar.gz: 4eccfe81e12b647503fa6e690c514d4d14d6704ab1e5c7f64282cafa7709d6e2
3
+ metadata.gz: b8be0076e31792c3b46d9c518eb59b087de8400c822b92d4edcf8df5e7bea1dd
4
+ data.tar.gz: 05bbe89b0d5d5ce19347e0970c41a8643f92c54a71ce7a5b0ce9e41d66d18509
5
5
  SHA512:
6
- metadata.gz: 99004f6792fe209d21474c7b5b311ac8a02cce27740b69164e44079983a5852895aa99ed12530043ba64ad6920d189cb6b19ce3957aca83b6bab06f75bf702ee
7
- data.tar.gz: 2be5eb3178a913c90c7b4e640812bccc479245d0052d95751317f543c80e7bf9429f9fd61cbc1c5edb917aafbead33502c75fb63fd8ab183480aaa44124f3dc5
6
+ metadata.gz: b3c76f79b5f4a8d55b484d85294b3252df79e7e1ee29e855b6300aa4b5caf90ff57fb1fbcbec4185aea125694865c9231f8d823f680313d129792d47cc0b8a6c
7
+ data.tar.gz: dfe6da1e900b8c74db2a3c2d1f7c61659afec2021f35ecc89503de33a7c5f26ae9d93ceb2071f9adb1552012712ed697f8612d6f35508c3f7c6d85d6778b266b
data/CHANGELOG.md CHANGED
@@ -18,7 +18,47 @@ Please follow the recommendations outlined at [keepachangelog.com](http://keepac
18
18
  ### [Unreleased]
19
19
  Changes since the last non-beta release.
20
20
 
21
- #### Added(https://github.com/AbanoubGhadban).
21
+ See [Release Notes](docs/release-notes/15.0.0.md) for full details.
22
+
23
+ #### Added
24
+ - React Server Components Support (Pro Feature) [PR 1644](https://github.com/shakacode/react_on_rails/pull/1644) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
25
+ - Improved component and store hydration performance [PR 1656](https://github.com/shakacode/react_on_rails/pull/1656) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
26
+
27
+ #### Breaking Changes
28
+ - `ReactOnRails.reactOnRailsPageLoaded` is now an async function
29
+ - `force_load` configuration now defaults to `true`
30
+ - `defer_generated_component_packs` configuration now defaults to `false`
31
+
32
+ ### [14.2.0] - 2025-03-03
33
+
34
+ #### Added
35
+ - Add export option 'react-on-rails/client' to avoid shipping server-rendering code to browsers (~5KB improvement) [PR 1697](https://github.com/shakacode/react_on_rails/pull/1697) by [Romex91](https://github.com/Romex91).
36
+
37
+ #### Fixed
38
+ - Fix obscure errors by introducing FULL_TEXT_ERRORS [PR 1695](https://github.com/shakacode/react_on_rails/pull/1695) by [Romex91](https://github.com/Romex91).
39
+ - Disable `esModuleInterop` to increase interoperability [PR 1699](https://github.com/shakacode/react_on_rails/pull/1699) by [alexeyr-ci](https://github.com/alexeyr-ci).
40
+ - Resolved 14.1.1 incompatibility with eslint & made sure that spec/dummy is linted by eslint. [PR 1693](https://github.com/shakacode/react_on_rails/pull/1693) by [judahmeek](https://github.com/judahmeek).
41
+
42
+ #### Changed
43
+ - More up-to-date TS config [PR 1700](https://github.com/shakacode/react_on_rails/pull/1700) by [alexeyr-ci](https://github.com/alexeyr-ci).
44
+
45
+ ### [14.1.1] - 2025-01-15
46
+
47
+ #### Fixed
48
+
49
+ - Separated streamServerRenderedReactComponent from the ReactOnRails object in order to stop users from getting errors during webpack compilation about needing the `stream-browserify` package. [PR 1680](https://github.com/shakacode/react_on_rails/pull/1680) by [judahmeek](https://github.com/judahmeek).
50
+ - Removed obsolete `js-yaml` peer dependency. [PR 1678](https://github.com/shakacode/react_on_rails/pull/1678) by [alexeyr-ci](https://github.com/alexeyr-ci).
51
+
52
+ ### [14.1.0] - 2025-01-06
53
+
54
+ #### Fixed
55
+
56
+ - Incorrect type and confusing name for `ReactOnRails.registerStore`, use `registerStoreGenerators` instead. [PR 1651](https://github.com/shakacode/react_on_rails/pull/1651) by [alexeyr-ci](https://github.com/alexeyr-ci).
57
+ - Changed the ReactOnRails' version checker to use `ReactOnRails.configuration.node_modules_location` to determine the location of the package.json that the `react-on-rails` dependency is expected to be set by.
58
+ - Also, all errors that would be raised by the version checking have been converted to `Rails.Logger` warnings to avoid any breaking changes. [PR 1657](https://github.com/shakacode/react_on_rails/pull/1657) by [judahmeek](https://github.com/judahmeek).
59
+ - Enable use as a `git:` dependency. [PR 1664](https://github.com/shakacode/react_on_rails/pull/1664) by [alexeyr-ci](https://github.com/alexeyr-ci).
60
+
61
+ #### Added
22
62
  - Added streaming server rendering support:
23
63
  - [PR #1633](https://github.com/shakacode/react_on_rails/pull/1633) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
24
64
  - New `stream_react_component` helper for adding streamed components to views
@@ -26,13 +66,11 @@ Changes since the last non-beta release.
26
66
  - Enables progressive page loading and improved performance for server-rendered React components
27
67
  - Added support for replaying console logs that occur during server rendering of streamed React components. This enables debugging of server-side rendering issues by capturing and displaying console output on the client and on the server output. [PR #1647](https://github.com/shakacode/react_on_rails/pull/1647) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
28
68
  - Added support for handling errors happening during server rendering of streamed React components. It handles errors that happen during the initial render and errors that happen inside suspense boundaries. [PR #1648](https://github.com/shakacode/react_on_rails/pull/1648) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
69
+ - Added support for passing options to `YAML.safe_load` when loading locale files with `config.i18n_yml_safe_load_options`. [PR #1668](https://github.com/shakacode/react_on_rails/pull/1668) by [dzirtusss](https://github.com/dzirtusss).
29
70
 
30
71
  #### Changed
31
72
  - Console replay script generation now awaits the render request promise before generating, allowing it to capture console logs from asynchronous operations. This requires using a version of the Node renderer that supports replaying async console logs. [PR #1649](https://github.com/shakacode/react_on_rails/pull/1649) by [AbanoubGhadban](https://github.com/AbanoubGhadban).
32
73
 
33
- #### Fixed
34
- - Incorrect type and confusing name for `ReactOnRails.registerStore`, use `registerStoreGenerators` instead. [PR 1651](https://github.com/shakacode/react_on_rails/pull/1651) by [alexeyr-ci](https://github.com/alexeyr-ci).
35
-
36
74
  ### [14.0.5] - 2024-08-20
37
75
  #### Fixed
38
76
  - Should force load react-components which send over turbo-stream [PR #1620](https://github.com/shakacode/react_on_rails/pull/1620) by [theforestvn88](https://github.com/theforestvn88).
@@ -1167,7 +1205,10 @@ Best done with Object destructing:
1167
1205
  ##### Fixed
1168
1206
  - Fix several generator-related issues.
1169
1207
 
1170
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.0.5...master
1208
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.2.0...master
1209
+ [14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0
1210
+ [14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
1211
+ [14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0
1171
1212
  [14.0.5]: https://github.com/shakacode/react_on_rails/compare/14.0.4...14.0.5
1172
1213
  [14.0.4]: https://github.com/shakacode/react_on_rails/compare/14.0.3...14.0.4
1173
1214
  [14.0.3]: https://github.com/shakacode/react_on_rails/compare/14.0.2...14.0.3
data/CONTRIBUTING.md CHANGED
@@ -6,20 +6,14 @@
6
6
 
7
7
  ## To run tests:
8
8
  * [Yalc](https://github.com/whitecolor/yalc) must be installed globally for most local development.
9
- * After updating code via git, to prepare all examples and run all tests:
10
-
9
+ * After updating code via Git, to prepare all examples:
11
10
  ```sh
12
11
  cd react_on_rails/
13
- bundle && yarn && rake examples:gen_all && rake node_package && rake
12
+ bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake
14
13
  ```
15
14
 
16
- In order to run tests in browser
17
- ```
18
- yarn global add browserify babelify tape-run faucet
19
- browserify -t babelify node_package/tests/*.js | tape-run | faucet
20
- ```
21
-
22
- See Dev Initial Setup, below for, well... initial setup.
15
+ See [Dev Initial Setup](#dev-initial-setup) below for, well... initial setup,
16
+ and [Running tests](#running-tests) for more details on running tests.
23
17
 
24
18
  # IDE/IDE SETUP
25
19
  It's critical to configure your IDE/editor to ignore certain directories. Otherwise your IDE might slow to a crawl!
@@ -153,21 +147,23 @@ script/convert
153
147
  yarn run dummy:spec
154
148
  ```
155
149
 
156
- ### Run NPM JS tests
150
+ ## Running tests
151
+
152
+ ### JS tests
157
153
 
158
154
  ```sh
159
155
  cd react_on_rails/
160
- yarn test
156
+ yarn run test
161
157
  ```
162
158
 
163
- ### Run spec/dummy tests
159
+ ### spec/dummy tests
164
160
 
165
161
  ```sh
166
162
  cd react_on_rails/spec/dummy
167
163
  rspec
168
164
  ```
169
165
 
170
- ### Run most tests and linting
166
+ ### Linting, type checking and JS tests together
171
167
 
172
168
  ```sh
173
169
  cd react_on_rails/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (14.0.5)
4
+ react_on_rails (14.2.0)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
data/README.md CHANGED
@@ -23,7 +23,7 @@
23
23
 
24
24
  -----
25
25
 
26
- *These are the docs for React on Rails 13. To see the older docs: [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0) and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
26
+ *These are the docs for React on Rails 14. To see the older docs and code: [v13](https://github.com/shakacode/react_on_rails/tree/13.4.0), [v12](https://github.com/shakacode/react_on_rails/tree/12.6.0), and [v11](https://github.com/shakacode/react_on_rails/tree/11.3.0).*
27
27
 
28
28
  # About
29
29
  React on Rails integrates Rails with (server rendering of) [React](https://github.com/facebook/react).
data/knip.ts ADDED
@@ -0,0 +1,91 @@
1
+ import type { KnipConfig } from 'knip';
2
+
3
+ const config: KnipConfig = {
4
+ // ! at the end means files are used in production
5
+ workspaces: {
6
+ '.': {
7
+ entry: [
8
+ 'node_package/src/ReactOnRails.node.ts!',
9
+ 'node_package/src/ReactOnRailsRSC.ts!',
10
+ 'node_package/src/registerServerComponent/client.ts!',
11
+ 'node_package/src/registerServerComponent/server.ts!',
12
+ 'node_package/src/RSCClientRoot.ts!',
13
+ ],
14
+ project: ['node_package/src/**/*.[jt]s{x,}!', 'node_package/tests/**/*.[jt]s{x,}'],
15
+ babel: {
16
+ config: ['node_package/babel.config.js'],
17
+ },
18
+ ignore: [
19
+ 'node_package/tests/emptyForTesting.js',
20
+ ],
21
+ ignoreBinaries: [
22
+ // Knip fails to detect it's declared in devDependencies
23
+ 'nps',
24
+ // local scripts
25
+ 'node_package/scripts/.*',
26
+ ],
27
+ ignoreDependencies: [
28
+ // Required for TypeScript compilation, but we don't depend on Turbolinks itself.
29
+ '@types/turbolinks',
30
+ // used in package-scripts.yml
31
+ 'concurrently',
32
+ // The Knip ESLint plugin fails to detect these are transitively required by a config,
33
+ // though we don't actually use its rules anywhere.
34
+ 'eslint-plugin-jsx-a11y',
35
+ 'eslint-plugin-react',
36
+ // Used in CI
37
+ '@arethetypeswrong/cli',
38
+ // used by Jest
39
+ 'jsdom',
40
+ ],
41
+ },
42
+ 'spec/dummy': {
43
+ entry: [
44
+ 'app/assets/config/manifest.js!',
45
+ 'client/app/packs/**/*.js!',
46
+ // Not sure why this isn't detected as a dependency of client/app/packs/server-bundle.js
47
+ 'client/app/generated/server-bundle-generated.js!',
48
+ 'spec/fixtures/automated_packs_generation/**/*.js{x,}',
49
+ 'config/webpack/{production,development,test}.js',
50
+ // Declaring this as webpack.config instead doesn't work correctly
51
+ 'config/webpack/webpack.config.js',
52
+ ],
53
+ project: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!', 'config/webpack/*.js'],
54
+ paths: {
55
+ 'Assets/*': ['client/app/assets/*'],
56
+ },
57
+ ignoreBinaries: [
58
+ // Has to be installed globally
59
+ 'yalc',
60
+ // Local binaries
61
+ 'bin/.*',
62
+ ],
63
+ ignoreDependencies: [
64
+ // Knip thinks it can be a devDependency, but it's supposed to be in dependencies.
65
+ '@babel/runtime',
66
+ // There's no ReScript plugin for Knip
67
+ '@rescript/react',
68
+ // The Babel plugin fails to detect it
69
+ 'babel-plugin-transform-react-remove-prop-types',
70
+ // This one is weird. It's long-deprecated and shouldn't be necessary.
71
+ // Probably need to update the Webpack config.
72
+ 'node-libs-browser',
73
+ // The below dependencies are not detected by the Webpack plugin
74
+ // due to the config issue.
75
+ 'css-loader',
76
+ 'expose-loader',
77
+ 'file-loader',
78
+ 'imports-loader',
79
+ 'mini-css-extract-plugin',
80
+ 'null-loader',
81
+ 'sass',
82
+ 'sass-loader',
83
+ 'sass-resources-loader',
84
+ 'style-loader',
85
+ 'url-loader',
86
+ ],
87
+ },
88
+ },
89
+ };
90
+
91
+ export default config;
@@ -9,6 +9,8 @@ module ReactOnRails
9
9
  end
10
10
 
11
11
  DEFAULT_GENERATED_ASSETS_DIR = File.join(%w[public webpack], Rails.env).freeze
12
+ DEFAULT_REACT_CLIENT_MANIFEST_FILE = "react-client-manifest.json"
13
+ DEFAULT_COMPONENT_REGISTRY_TIMEOUT = 5000
12
14
 
13
15
  def self.configuration
14
16
  @configuration ||= Configuration.new(
@@ -17,6 +19,8 @@ module ReactOnRails
17
19
  # generated_assets_dirs is deprecated
18
20
  generated_assets_dir: "",
19
21
  server_bundle_js_file: "",
22
+ rsc_bundle_js_file: "",
23
+ react_client_manifest_file: DEFAULT_REACT_CLIENT_MANIFEST_FILE,
20
24
  prerender: false,
21
25
  auto_load_bundle: false,
22
26
  replay_console: true,
@@ -39,9 +43,13 @@ module ReactOnRails
39
43
  i18n_output_format: nil,
40
44
  components_subdirectory: nil,
41
45
  make_generated_server_bundle_the_entrypoint: false,
42
- defer_generated_component_packs: true,
46
+ defer_generated_component_packs: false,
43
47
  # forces the loading of React components
44
- force_load: false
48
+ force_load: true,
49
+ # Maximum time in milliseconds to wait for client-side component registration after page load.
50
+ # If exceeded, an error will be thrown for server-side rendered components not registered on the client.
51
+ # Set to 0 to disable the timeout and wait indefinitely for component registration.
52
+ component_registry_timeout: DEFAULT_COMPONENT_REGISTRY_TIMEOUT
45
53
  )
46
54
  end
47
55
 
@@ -52,11 +60,12 @@ module ReactOnRails
52
60
  :generated_assets_dirs, :generated_assets_dir, :components_subdirectory,
53
61
  :webpack_generated_files, :rendering_extension, :build_test_command,
54
62
  :build_production_command, :i18n_dir, :i18n_yml_dir, :i18n_output_format,
63
+ :i18n_yml_safe_load_options,
55
64
  :server_render_method, :random_dom_id, :auto_load_bundle,
56
65
  :same_bundle_for_client_and_server, :rendering_props_extension,
57
66
  :make_generated_server_bundle_the_entrypoint,
58
- :defer_generated_component_packs,
59
- :force_load
67
+ :defer_generated_component_packs, :force_load, :rsc_bundle_js_file,
68
+ :react_client_manifest_file, :component_registry_timeout
60
69
 
61
70
  # rubocop:disable Metrics/AbcSize
62
71
  def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender: nil,
@@ -69,9 +78,10 @@ module ReactOnRails
69
78
  rendering_extension: nil, build_test_command: nil,
70
79
  build_production_command: nil, defer_generated_component_packs: nil,
71
80
  same_bundle_for_client_and_server: nil,
72
- i18n_dir: nil, i18n_yml_dir: nil, i18n_output_format: nil,
81
+ i18n_dir: nil, i18n_yml_dir: nil, i18n_output_format: nil, i18n_yml_safe_load_options: nil,
73
82
  random_dom_id: nil, server_render_method: nil, rendering_props_extension: nil,
74
- components_subdirectory: nil, auto_load_bundle: nil, force_load: nil)
83
+ components_subdirectory: nil, auto_load_bundle: nil, force_load: nil,
84
+ rsc_bundle_js_file: nil, react_client_manifest_file: nil, component_registry_timeout: nil)
75
85
  self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
76
86
  self.generated_assets_dirs = generated_assets_dirs
77
87
  self.generated_assets_dir = generated_assets_dir
@@ -80,6 +90,7 @@ module ReactOnRails
80
90
  self.i18n_dir = i18n_dir
81
91
  self.i18n_yml_dir = i18n_yml_dir
82
92
  self.i18n_output_format = i18n_output_format
93
+ self.i18n_yml_safe_load_options = i18n_yml_safe_load_options
83
94
 
84
95
  self.random_dom_id = random_dom_id
85
96
  self.prerender = prerender
@@ -94,9 +105,12 @@ module ReactOnRails
94
105
  self.raise_on_prerender_error = raise_on_prerender_error
95
106
  self.skip_display_none = skip_display_none
96
107
  self.rendering_props_extension = rendering_props_extension
108
+ self.component_registry_timeout = component_registry_timeout
97
109
 
98
110
  # Server rendering:
99
111
  self.server_bundle_js_file = server_bundle_js_file
112
+ self.rsc_bundle_js_file = rsc_bundle_js_file
113
+ self.react_client_manifest_file = react_client_manifest_file
100
114
  self.same_bundle_for_client_and_server = same_bundle_for_client_and_server
101
115
  self.server_renderer_pool_size = self.development_mode ? 1 : server_renderer_pool_size
102
116
  self.server_renderer_timeout = server_renderer_timeout # seconds
@@ -124,10 +138,19 @@ module ReactOnRails
124
138
  error_if_using_packer_and_generated_assets_dir_not_match_public_output_path
125
139
  # check_deprecated_settings
126
140
  adjust_precompile_task
141
+ check_component_registry_timeout
127
142
  end
128
143
 
129
144
  private
130
145
 
146
+ def check_component_registry_timeout
147
+ self.component_registry_timeout = DEFAULT_COMPONENT_REGISTRY_TIMEOUT if component_registry_timeout.nil?
148
+
149
+ return if component_registry_timeout.is_a?(Integer) && component_registry_timeout >= 0
150
+
151
+ raise ReactOnRails::Error, "component_registry_timeout must be a positive integer"
152
+ end
153
+
131
154
  def check_autobundling_requirements
132
155
  raise_missing_components_subdirectory if auto_load_bundle && !components_subdirectory.present?
133
156
  return unless components_subdirectory.present?
@@ -239,10 +262,12 @@ module ReactOnRails
239
262
  def ensure_webpack_generated_files_exists
240
263
  return unless webpack_generated_files.empty?
241
264
 
242
- files = ["manifest.json"]
243
- files << server_bundle_js_file if server_bundle_js_file.present?
244
-
245
- self.webpack_generated_files = files
265
+ self.webpack_generated_files = [
266
+ "manifest.json",
267
+ server_bundle_js_file,
268
+ rsc_bundle_js_file,
269
+ react_client_manifest_file
270
+ ].compact_blank
246
271
  end
247
272
 
248
273
  def configure_skip_display_none_deprecation
@@ -5,9 +5,7 @@ require "rails/railtie"
5
5
  module ReactOnRails
6
6
  class Engine < ::Rails::Engine
7
7
  config.to_prepare do
8
- if File.exist?(VersionChecker::NodePackageVersion.package_json_path)
9
- VersionChecker.build.raise_if_gem_and_node_package_versions_differ
10
- end
8
+ VersionChecker.build.log_if_gem_and_node_package_versions_differ
11
9
  ReactOnRails::ServerRenderingPool.reset_pool
12
10
  end
13
11
  end