react_on_rails 14.1.1 → 14.2.1

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: b0e439ad231345f667bd0397a191854a1fc1265fd6b53aa4ff07297c52cbea88
4
- data.tar.gz: 80499fba8a3696ba0bca1a07742a36c0bc1c286294ebdab57d0f742c94d8a32b
3
+ metadata.gz: f7b7be38f2d494d8dc1b1a6b7e36abc59c80a07f9796d14c938fe71443b22f21
4
+ data.tar.gz: 879b0829934a770b8563fc95a6902baff0de4b6d94fb3ff0421ea29a529dea9d
5
5
  SHA512:
6
- metadata.gz: fe4dd909d8ee7f1ee6e7210acdee7fbede95caa508b41d2f43e88aa11113bbb8d3eb88e4c0b24a826b472b2ac5ed234e5c6ba8ea357488d59d21fd995c010e36
7
- data.tar.gz: 83c5ccc2589399f773872291069f591179a2eb3cd13b8420102bd95f65421a6f00cc9d591a578adb5ae20339a7cd5dba7cf0f87bce25a0041a7ef9e7f3497a3a
6
+ metadata.gz: 2b59fe8de12c8341a509ab13d91e95fd2a4c8f2942a313ded31637151d0ece578168f8ecc058ee9f079ad69a478aafac5f33e1fff40a7250f9859ff22351be90
7
+ data.tar.gz: 54908a56ffded969d93898250b6fd1a4685f5addc6758e596078027b6f027333fb125fe95efdba626c1aa21a3f4baf975274a0f9611b018ca872cff04cef44a1
data/CHANGELOG.md CHANGED
@@ -18,6 +18,28 @@ 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
+ ### [14.2.1] - 2025-04-11
22
+
23
+ #### Fixed
24
+ - Fixed a bug where the `load` event was not firing in Safari by postponing hydration to the next JavaScript task using `setTimeout(callback, 0)`. [PR 1729](https://github.com/shakacode/react_on_rails/pull/1729) by [Romex91](https://github.com/Romex91).
25
+ - Generated client packs now import from `react-on-rails/client` instead of `react-on-rails`. [PR 1706](https://github.com/shakacode/react_on_rails/pull/1706) by [alexeyr-ci](https://github.com/alexeyr-ci).
26
+ - The "optimization opportunity" message when importing the server-side `react-on-rails` instead of `react-on-rails/client` in browsers is now a warning for two reasons:
27
+ - Make it more prominent
28
+ - Include a stack trace when clicked
29
+
30
+ ### [14.2.0] - 2025-03-03
31
+
32
+ #### Added
33
+ - 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).
34
+
35
+ #### Fixed
36
+ - 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).
37
+ - Disable `esModuleInterop` to increase interoperability [PR 1699](https://github.com/shakacode/react_on_rails/pull/1699) by [alexeyr-ci](https://github.com/alexeyr-ci).
38
+ - 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).
39
+
40
+ #### Changed
41
+ - 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).
42
+
21
43
  ### [14.1.1] - 2025-01-15
22
44
 
23
45
  #### Fixed
@@ -1181,7 +1203,8 @@ Best done with Object destructing:
1181
1203
  ##### Fixed
1182
1204
  - Fix several generator-related issues.
1183
1205
 
1184
- [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.1.1...master
1206
+ [Unreleased]: https://github.com/shakacode/react_on_rails/compare/14.2.0...master
1207
+ [14.2.0]: https://github.com/shakacode/react_on_rails/compare/14.1.1...14.2.0
1185
1208
  [14.1.1]: https://github.com/shakacode/react_on_rails/compare/14.1.0...14.1.1
1186
1209
  [14.1.0]: https://github.com/shakacode/react_on_rails/compare/14.0.5...14.1.0
1187
1210
  [14.0.5]: https://github.com/shakacode/react_on_rails/compare/14.0.4...14.0.5
data/CONTRIBUTING.md CHANGED
@@ -9,7 +9,7 @@
9
9
  * After updating code via Git, to prepare all examples:
10
10
  ```sh
11
11
  cd react_on_rails/
12
- bundle && yarn && rake examples:gen_all && rake node_package && rake
12
+ bundle && yarn && rake shakapacker_examples:gen_all && rake node_package && rake
13
13
  ```
14
14
 
15
15
  See [Dev Initial Setup](#dev-initial-setup) below for, well... initial setup,
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- react_on_rails (14.1.0)
4
+ react_on_rails (14.2.0)
5
5
  addressable
6
6
  connection_pool
7
7
  execjs (~> 2.5)
data/knip.ts ADDED
@@ -0,0 +1,80 @@
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: ['node_package/src/ReactOnRails.ts!', 'node_package/src/ReactOnRails.node.ts!'],
8
+ project: ['node_package/src/**/*.[jt]s!', 'node_package/tests/**/*.[jt]s'],
9
+ babel: {
10
+ config: ['node_package/babel.config.js'],
11
+ },
12
+ ignoreBinaries: [
13
+ // Knip fails to detect it's declared in devDependencies
14
+ 'nps',
15
+ // local scripts
16
+ 'node_package/scripts/.*',
17
+ ],
18
+ ignoreDependencies: [
19
+ // Required for TypeScript compilation, but we don't depend on Turbolinks itself.
20
+ '@types/turbolinks',
21
+ // used in package-scripts.yml
22
+ 'concurrently',
23
+ // The Knip ESLint plugin fails to detect these are transitively required by a config,
24
+ // though we don't actually use its rules anywhere.
25
+ 'eslint-plugin-jsx-a11y',
26
+ 'eslint-plugin-react',
27
+ // Used in CI
28
+ '@arethetypeswrong/cli',
29
+ ],
30
+ },
31
+ 'spec/dummy': {
32
+ entry: [
33
+ 'app/assets/config/manifest.js!',
34
+ 'client/app/packs/**/*.js!',
35
+ // Not sure why this isn't detected as a dependency of client/app/packs/server-bundle.js
36
+ 'client/app/generated/server-bundle-generated.js!',
37
+ 'spec/fixtures/automated_packs_generation/**/*.js{x,}',
38
+ 'config/webpack/{production,development,test}.js',
39
+ // Declaring this as webpack.config instead doesn't work correctly
40
+ 'config/webpack/webpack.config.js',
41
+ ],
42
+ project: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}!', 'config/webpack/*.js'],
43
+ paths: {
44
+ 'Assets/*': ['client/app/assets/*'],
45
+ },
46
+ ignoreBinaries: [
47
+ // Has to be installed globally
48
+ 'yalc',
49
+ // Local binaries
50
+ 'bin/.*',
51
+ ],
52
+ ignoreDependencies: [
53
+ // Knip thinks it can be a devDependency, but it's supposed to be in dependencies.
54
+ '@babel/runtime',
55
+ // There's no ReScript plugin for Knip
56
+ '@rescript/react',
57
+ // The Babel plugin fails to detect it
58
+ 'babel-plugin-transform-react-remove-prop-types',
59
+ // This one is weird. It's long-deprecated and shouldn't be necessary.
60
+ // Probably need to update the Webpack config.
61
+ 'node-libs-browser',
62
+ // The below dependencies are not detected by the Webpack plugin
63
+ // due to the config issue.
64
+ 'css-loader',
65
+ 'expose-loader',
66
+ 'file-loader',
67
+ 'imports-loader',
68
+ 'mini-css-extract-plugin',
69
+ 'null-loader',
70
+ 'sass',
71
+ 'sass-loader',
72
+ 'sass-resources-loader',
73
+ 'style-loader',
74
+ 'url-loader',
75
+ ],
76
+ },
77
+ },
78
+ };
79
+
80
+ export default config;
@@ -47,14 +47,10 @@ module ReactOnRails
47
47
 
48
48
  def add_yarn_relative_install_script_in_package_json
49
49
  package_json = File.join(destination_root, "package.json")
50
- contents = File.read(package_json)
51
- replacement_value = <<-STRING
52
- "scripts": {
53
- "postinstall": "yalc link react-on-rails",
54
- STRING
55
- new_client_package_json_contents = contents.gsub(/ {2}"scripts": {/,
56
- replacement_value)
57
- File.open(package_json, "w+") { |f| f.puts new_client_package_json_contents }
50
+ contents = JSON.parse(File.read(package_json))
51
+ contents["scripts"] ||= {}
52
+ contents["scripts"]["postinstall"] = "yalc link react-on-rails"
53
+ File.open(package_json, "w+") { |f| f.puts JSON.pretty_generate(contents) }
58
54
  end
59
55
  end
60
56
  end
@@ -1,4 +1,4 @@
1
- import ReactOnRails from 'react-on-rails';
1
+ import ReactOnRails from 'react-on-rails/client';
2
2
 
3
3
  import <%= config[:component_name] %> from '<%= config[:app_relative_path] %>';
4
4
 
@@ -47,7 +47,7 @@ module ReactOnRails
47
47
  def pack_file_contents(file_path)
48
48
  registered_component_name = component_name(file_path)
49
49
  <<~FILE_CONTENT
50
- import ReactOnRails from 'react-on-rails';
50
+ import ReactOnRails from 'react-on-rails/client';
51
51
  import #{registered_component_name} from '#{relative_component_path_from_generated_pack(file_path)}';
52
52
 
53
53
  ReactOnRails.register({#{registered_component_name}});
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rainbow"
4
+
3
5
  # rubocop:disable: Layout/IndentHeredoc
4
6
  module ReactOnRails
5
7
  class PrerenderError < ::ReactOnRails::Error
@@ -51,11 +53,17 @@ module ReactOnRails
51
53
  message << <<~MSG
52
54
  Encountered error:
53
55
 
54
- #{err}
56
+ #{err.inspect}
55
57
 
56
58
  MSG
57
59
 
58
- backtrace = err.backtrace.first(15).join("\n")
60
+ backtrace = if Utils.full_text_errors_enabled?
61
+ err.backtrace.join("\n")
62
+ else
63
+ "#{Rails.backtrace_cleaner.clean(err.backtrace).join("\n")}\n" +
64
+ Rainbow("The rest of the backtrace is hidden. " \
65
+ "To see the full backtrace, set FULL_TEXT_ERRORS=true.").red
66
+ end
59
67
  else
60
68
  backtrace = nil
61
69
  end
@@ -8,7 +8,9 @@ require "active_support/core_ext/string"
8
8
 
9
9
  module ReactOnRails
10
10
  module Utils
11
- TRUNCATION_FILLER = "\n... TRUNCATED ...\n"
11
+ TRUNCATION_FILLER = "\n... TRUNCATED #{
12
+ Rainbow('To see the full output, set FULL_TEXT_ERRORS=true.').red
13
+ } ...\n".freeze
12
14
 
13
15
  # https://forum.shakacode.com/t/yak-of-the-week-ruby-2-4-pathname-empty-changed-to-look-at-file-size/901
14
16
  # return object if truthy, else return nil
@@ -183,9 +185,14 @@ module ReactOnRails
183
185
  end
184
186
  end
185
187
 
188
+ def self.full_text_errors_enabled?
189
+ ENV["FULL_TEXT_ERRORS"] == "true"
190
+ end
191
+
186
192
  def self.smart_trim(str, max_length = 1000)
187
193
  # From https://stackoverflow.com/a/831583/1009332
188
194
  str = str.to_s
195
+ return str if full_text_errors_enabled?
189
196
  return str unless str.present? && max_length >= 1
190
197
  return str if str.length <= max_length
191
198
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReactOnRails
4
- VERSION = "14.1.1"
4
+ VERSION = "14.2.1"
5
5
  end
@@ -36,8 +36,8 @@ Gem::Specification.new do |s|
36
36
  s.post_install_message = '
37
37
  --------------------------------------------------------------------------------
38
38
  Checkout https://www.shakacode.com/react-on-rails-pro for information about
39
- "React on Rails Pro" which includes one hour a month of support and a gem for
40
- better performance, via caching helpers, and our node rendering server.
39
+ "React on Rails Pro" which includes a gem for better performance, via caching helpers, and our
40
+ node rendering server, support for React 19, and much more.
41
41
  --------------------------------------------------------------------------------
42
42
  '
43
43
  end
data/tsconfig.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
+ "extends": "@tsconfig/node14",
2
3
  "compilerOptions": {
3
4
  "allowJs": true,
4
- "esModuleInterop": true,
5
+ "esModuleInterop": false,
6
+ // needed for Jest tests even though we don't use .tsx
5
7
  "jsx": "react-jsx",
6
- "lib": ["dom", "es2015"],
7
- "module": "CommonJS",
8
+ "lib": ["dom", "es2020"],
9
+ "module": "node16",
8
10
  "noImplicitAny": true,
9
11
  "outDir": "node_package/lib",
10
12
  "strict": true,
11
13
  "incremental": true,
12
- "target": "es5"
14
+ "target": "es2020"
13
15
  },
14
16
  "include": ["node_package/src/**/*"]
15
17
  }
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: 14.1.1
4
+ version: 14.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Gordon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-17 00:00:00.000000000 Z
11
+ date: 2025-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -117,6 +117,7 @@ files:
117
117
  - SUMMARY.md
118
118
  - app/helpers/react_on_rails_helper.rb
119
119
  - docker-compose.yml
120
+ - knip.ts
120
121
  - lib/generators/USAGE
121
122
  - lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
122
123
  - lib/generators/react_on_rails/base_generator.rb
@@ -203,8 +204,8 @@ post_install_message: |2
203
204
 
204
205
  --------------------------------------------------------------------------------
205
206
  Checkout https://www.shakacode.com/react-on-rails-pro for information about
206
- "React on Rails Pro" which includes one hour a month of support and a gem for
207
- better performance, via caching helpers, and our node rendering server.
207
+ "React on Rails Pro" which includes a gem for better performance, via caching helpers, and our
208
+ node rendering server, support for React 19, and much more.
208
209
  --------------------------------------------------------------------------------
209
210
  rdoc_options: []
210
211
  require_paths:
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  - !ruby/object:Gem::Version
221
222
  version: '0'
222
223
  requirements: []
223
- rubygems_version: 3.5.3
224
+ rubygems_version: 3.5.11
224
225
  signing_key:
225
226
  specification_version: 4
226
227
  summary: Rails with react server rendering with webpack.