diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 480e75ebb..a6ae7a864 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -14,6 +14,9 @@ jobs: matrix: os: [ubuntu-latest] ruby: ['2.7', '3.0'] + env: + # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: ${{ github.workspace }}/LintingGemfile steps: - uses: actions/checkout@v4 @@ -23,7 +26,5 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - name: Install linting gems - run: gem install rubocop rubocop-performance rubocop-minitest - name: Run rubocop - run: rubocop + run: bundle exec rubocop diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index f81b04b4d..e25ee7819 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -89,7 +89,7 @@ jobs: with: persist-credentials: false - uses: actions/setup-node@v3 - - run: npm -g install yalc ${{ matrix.js_package_manager.installer }} + - run: sudo npm -g install yalc ${{ matrix.js_package_manager.installer }} - run: yalc publish - name: Save root node_modules to cache uses: actions/cache@v3 @@ -105,12 +105,13 @@ jobs: with: bundler: 2.4.9 ruby-version: ${{ matrix.ruby }} + - run: bundle config set --local path 'test/dummy/vendor/bundle' - run: ./test/bin/create-fake-js-package-managers ${{ matrix.js_package_manager.installer }} - name: Save dummy app ruby gems to cache uses: actions/cache@v3 with: path: test/dummy/vendor/bundle - key: dummy-app-gem-cache-${{ hashFiles('${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile.lock') }} + key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.gemfile)) }} - name: Install Ruby Gems for dummy app run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=test/dummy/vendor/bundle || bundle _2.4.9_ install --frozen --path=test/dummy/vendor/bundle --jobs=4 --retry=3 - run: cd test/dummy && yalc add react_ujs && ${{ matrix.js_package_manager.installer }} install diff --git a/Appraisals b/Appraisals index 967ed8ecb..cce17d3b3 100644 --- a/Appraisals +++ b/Appraisals @@ -1,5 +1,4 @@ appraise 'sprockets_4' do - gem 'rails', '~> 7.0.x' gem 'sprockets', '~> 4.0.x' gem 'sprockets-rails' gem 'turbolinks', '~> 5' @@ -7,7 +6,6 @@ appraise 'sprockets_4' do end appraise 'sprockets_3' do - gem 'rails', '~> 7.0.x' gem 'sprockets', '~> 3.5' gem 'sprockets-rails' gem 'turbolinks', '~> 5' @@ -15,14 +13,5 @@ appraise 'sprockets_3' do end appraise 'shakapacker' do - gem 'rails', '~> 7.0.x' gem 'shakapacker', '7.2.0' end - -appraise 'base' do - # Appraisal adds `turbolinks` to this gemfile because it is - # present in `./Gemfile`. - # But it causes this gemfile to break, so it must be removed - # from `./gemfiles/rails_5_no_sprockets.gemfile` manually. - gem 'rails', '~> 7.0.x' -end diff --git a/CHANGELOG.md b/CHANGELOG.md index f31cc7306..3401de745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,26 @@ -# react-rails +# Changelog for React-Rails -If you need help upgrading `react-rails`, `webpacker` to `shakapacker`, or JS packages, contact justin@shakacode.com. The ShakaCode.com team is helping to maintain this Ruby gem. You also might want to consider the [react_on_rails](https://github.com/shakacode/react_on_rails) gem. +If you need help upgrading `react-rails`, `webpacker` to `shakapacker`, or JS packages, contact justin@shakacode.com. We can upgrade your project and improve your development and customer experiences, allowing you to focus on building new features or fixing bugs instead. -[#1209 2.7 Release Discussion](https://github.com/reactjs/react-rails/issues/1209) +For an overview of working with us, see our [Client Engagement Model](https://www.shakacode.com/blog/client-engagement-model/) article and [how we bill for time](https://www.shakacode.com/blog/shortcut-jira-trello-github-toggl-time-and-task-tracking/). + +We also specialize in helping development teams lower infrastructure and CI costs. Check out our project [Control Plane Flow](https://github.com/shakacode/control-plane-flow/), which can allow you to get the ease of Heroku with the power of Kubernetes and big cost savings. + +If you think ShakaCode can help your project, [click here](https://meetings.hubspot.com/justingordon/30-minute-consultation) to book a call with [Justin Gordon](mailto:justin@shakacode.com), the creator of React on Rails and Shakapacker. + +You also might want to consider the [react_on_rails](https://github.com/shakacode/react_on_rails) gem. ## Unreleased Changes since the last non-beta release. -_Please add entries here for your pull requests that are not yet released. Include LINKS for PRs and committers._ +_Please add entries here for your pull requests that have not yet been released. Include LINKS for PRs and committers._ + +## [3.2.1] - 2024-05-16 + +#### Fixed +- Replaced call to ReactRailsUJS.unmountComponents that was erroneously removed by [PR 1290](https://github.com/reactjs/react-rails/pull/1305) in 3.0.0 [PR 1339](https://github.com/reactjs/react-rails/pull/1339). + +- Prevent roots from being re-created when using React 18 [PR 1305](https://github.com/reactjs/react-rails/pull/1305) by [diogobeda](https://github.com/diogobeda) ## [3.2.0] - 2024-01-10 @@ -43,6 +56,8 @@ _Please add entries here for your pull requests that are not yet released. Inclu ## [2.7.0] - 2023-05-06 +[#1209 2.7 Release Discussion](https://github.com/reactjs/react-rails/issues/1209) + #### New Features - Camelizes keys with primitive values, in addition to hashes #946 - Expose alternative implementations for `ReactUJS.getConstructor` #1050 @@ -573,7 +588,8 @@ _Please add entries here for your pull requests that are not yet released. Inclu - Server rendering with `prerender: true` - Transform `.jsx` in the asset pipeline -[Unreleased]: https://github.com/reactjs/react-rails/compare/v3.2.0...main +[Unreleased]: https://github.com/reactjs/react-rails/compare/v3.2.1...main +[3.2.1]: https://github.com/reactjs/react-rails/compare/v3.2.1...v3.2.1 [3.2.0]: https://github.com/reactjs/react-rails/compare/v3.1.1...v3.2.0 [3.1.1]: https://github.com/reactjs/react-rails/compare/v3.1.0...v3.1.1 [3.1.0]: https://github.com/reactjs/react-rails/compare/v3.0.0...v3.1.0 diff --git a/Gemfile b/Gemfile index 8926579c4..c56c88f84 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,3 @@ source "http://rubygems.org/" gemspec -# This is an optional dev-dependency, required whenever sprockets is required diff --git a/Gemfile.lock b/Gemfile.lock index 4583cca96..086186705 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - react-rails (3.2.0) + react-rails (3.2.1) babel-transpiler (>= 0.7.0) connection_pool execjs @@ -11,25 +11,71 @@ PATH GEM remote: http://rubygems.org/ specs: - actionpack (6.0.2.1) - actionview (= 6.0.2.1) - activesupport (= 6.0.2.1) - rack (~> 2.0, >= 2.0.8) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (6.0.2.1) - activesupport (= 6.0.2.1) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activesupport (6.0.2.1) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) + globalid (>= 0.3.6) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) appraisal (2.4.1) @@ -64,6 +110,7 @@ GEM concurrent-ruby (1.1.10) connection_pool (2.3.0) crass (1.0.6) + date (3.3.4) docile (1.1.5) erubi (1.9.0) es5-shim-rails (4.0.1) @@ -73,6 +120,8 @@ GEM ffi (1.15.5) formatador (1.1.0) gem-release (2.2.2) + globalid (1.2.1) + activesupport (>= 6.1) guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -99,12 +148,30 @@ GEM crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.2.8) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) - mini_mime (1.0.2) - mini_portile2 (2.8.5) + mini_mime (1.1.2) + mini_portile2 (2.8.6) minitest (5.17.0) + minitest-retry (0.2.2) + minitest (>= 5.0) nenv (0.3.0) + net-imap (0.4.11) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) nokogiri (1.14.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) @@ -127,17 +194,32 @@ GEM rack (2.2.6.4) rack-test (2.0.2) rack (>= 1.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + bundler (>= 1.15.0) + railties (= 7.0.8.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.4) loofah (~> 2.19, >= 2.19.1) - railties (6.0.2.1) - actionpack (= 6.0.2.1) - activesupport (= 6.0.2.1) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) rake (13.0.1) rb-fsevent (0.11.2) rb-inotify (0.10.1) @@ -157,11 +239,18 @@ GEM simplecov-html (0.10.2) test-unit (2.5.5) thor (1.2.1) - thread_safe (0.3.6) tilt (2.1.0) - tzinfo (1.2.10) - thread_safe (~> 0.1) + timeout (0.4.1) + turbo-rails (2.0.5) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) websocket (1.2.9) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.6.6) @@ -183,11 +272,14 @@ DEPENDENCIES guard-minitest jbuilder listen (~> 3.0.0) + minitest-retry package_json pry-byebug + rails (~> 7.0.7, >= 7.0.7.2) react-rails! selenium-webdriver test-unit (~> 2.5) + turbo-rails BUNDLED WITH 2.4.9 diff --git a/LintingGemfile b/LintingGemfile new file mode 100644 index 000000000..7edffc5aa --- /dev/null +++ b/LintingGemfile @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +source "http://rubygems.org/" +# To install gems from this Gemfile locally, use BUNDLE_GEMFILE=./LintingGemfile bundle exec rubocop +gem "rubocop" +gem "rubocop-minitest" +gem "rubocop-performance" diff --git a/LintingGemfile.lock b/LintingGemfile.lock new file mode 100644 index 000000000..85af7abf3 --- /dev/null +++ b/LintingGemfile.lock @@ -0,0 +1,47 @@ +GEM + remote: http://rubygems.org/ + specs: + ast (2.4.2) + json (2.7.2) + language_server-protocol (3.17.0.3) + parallel (1.24.0) + parser (3.3.1.0) + ast (~> 2.4.1) + racc + racc (1.7.3) + rainbow (3.1.1) + regexp_parser (2.9.0) + rexml (3.2.6) + rubocop (1.63.5) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + rubocop-minitest (0.35.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-performance (1.21.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (1.13.0) + unicode-display_width (2.5.0) + +PLATFORMS + x86_64-darwin-20 + x86_64-linux + +DEPENDENCIES + rubocop + rubocop-minitest + rubocop-performance + +BUNDLED WITH + 2.4.9 diff --git a/README.md b/README.md index 354803e5e..235af5008 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,7 @@ [![npm](https://img.shields.io/npm/v/react_ujs.svg?style=flat-square)](https://www.npmjs.com/package/react_ujs) [![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml) -## News -V3.0.0 is released with Shakapacker v7 support, including SSR. Please try it out and report any issues. We'll try to address any critical issues ASAP. - -For version 2.7 documentation checkout [2.7-stable](https://github.com/reactjs/react-rails/tree/2.7-stable) branch. +For version 2.7 documentation, visit the [2.7-stable](https://github.com/reactjs/react-rails/tree/2.7-stable) branch. ## Summary React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits: @@ -16,12 +13,26 @@ React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) * Supports Sprockets 4.x, 3.x * Lets you use [JSX](http://facebook.github.io/react/docs/jsx-in-depth.html), [ES6](http://es6-features.org/), [TypeScript](https://www.typescriptlang.org/), [CoffeeScript](http://coffeescript.org/) +--- + +While ShakaCode will continue to support this gem, you might consider migrating to [React on Rails](https://github.com/shakacode/react_on_rails) or [React on Rails Pro with proper Node rendering](https://www.shakacode.com/react-on-rails-pro/). + +Why? React on Rails code receives much more active development and testing. For example, consider the [ReactRailsUJS](https://github.com/reactjs/react-rails/blob/master/react_ujs/index.js) implementation compared to the [ReactOnRails Node package](https://github.com/shakacode/react_on_rails/tree/master/node_package) which is written in TypeScript. For another example, React on Rails has work underway to support the latest React features, such as [React Server Components](https://react.dev/reference/rsc/server-components). + +You can find [migration to React on Rails steps here](https://github.com/reactjs/react-rails/blob/master/docs/migrating-from-react-rails-to-react_on_rails.md). + --- ## ShakaCode Support -[ShakaCode](https://www.shakacode.com) offers support for upgrading this gem, and related gems such as Webpacker and using Shakapacker. If interested, contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com). We're also [hiring](https://jobs.lever.co/shakacode/3bdbfdb3-4495-4611-a279-01dddb351abe)! +[ShakaCode](https://www.shakacode.com) focuses on helping Ruby on Rails teams use React and Webpack better. We can upgrade your project and improve your development and customer experiences, allowing you to focus on building new features or fixing bugs instead. + +For an overview of working with us, see our [Client Engagement Model](https://www.shakacode.com/blog/client-engagement-model/) article and [how we bill for time](https://www.shakacode.com/blog/shortcut-jira-trello-github-toggl-time-and-task-tracking/). + +We also specialize in helping development teams lower infrastructure and CI costs. Check out our project [Control Plane Flow](https://github.com/shakacode/control-plane-flow/), which can allow you to get the ease of Heroku with the power of Kubernetes and big cost savings. + +If you think ShakaCode can help your project, [click here](https://meetings.hubspot.com/justingordon/30-minute-consultation) to book a call with [Justin Gordon](mailto:justin@shakacode.com), the creator of React on Rails and Shakapacker. -Here's a testimonial of how ShakaCode can help, from [Florian GรถรŸler](https://github.com/FGoessler) of [Blinkist](https://www.blinkist.com/), January 2, 2023: +Here's a testimonial of how ShakaCode can help from [Florian GรถรŸler](https://github.com/FGoessler) of [Blinkist](https://www.blinkist.com/), January 2, 2023: > Hey Justin ๐Ÿ‘‹ > > I just wanted to let you know that we today shipped the webpacker to shakapacker upgrades and it all seems to be running smoothly! Thanks again for all your support and your teams work! ๐Ÿ˜ @@ -30,11 +41,11 @@ Here's a testimonial of how ShakaCode can help, from [Florian GรถรŸler](https:// > > Have a great 2023 and maybe we get to work together again later in the year! ๐Ÿ™Œ -Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2118154). Here's [another review of a Shakapacker migration that led to more work](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2096078). +Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by=date_DESC#review-2118154). ## Resources * [Click to join **React + Rails Slack**](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE). Then join the channel `#react-rails`. -* If you are upgrading, you might consider migrating to the [react_on_rails](https://github.com/shakacode/react_on_rails) gem. +* If upgrading, consider migrating to the [react_on_rails](https://github.com/shakacode/react_on_rails) gem. * Source code example utilizing React-Rails: https://github.com/BookOfGreg/react-rails-example-app ## Documentation @@ -77,32 +88,24 @@ Read the [full review here](https://clutch.co/profile/shakacode#reviews?sort_by= - [HMR](docs/common-errors.md#hmr) - [Tests in component directory](docs/common-errors.md#tests-in-component-directory) -After reading this README file, additional information about React-Rails can be found in the Wiki page: +After reading this README file, additional information about React-Rails can be found on the Wiki page: https://github.com/reactjs/React-Rails/wiki -The Wiki page features a significant amount of additional information about React-Rails which includes instructional articles and answers to the most frequently asked questions. +The Wiki page features a significant amount of additional information about React-Rails, including instructional articles and answers to the most frequently asked questions. ## Related Projects -- [webpacker-react](https://github.com/renchap/webpacker-react): Integration of React with Rails utilizing Webpack with Hot Module Replacement (HMR). -- [The React on Rails Course](https://learnetto.com/users/hrishio/courses/the-free-react-on-rails-5-course) A video course which teaches the basics of React and how to get started using it in Rails with `react-rails`. - [react\_on\_rails](https://github.com/shakacode/react_on_rails): Integration of React with Rails utilizing Webpack, Redux, React-Router. -- [react-rails-hot-loader](https://github.com/rmosolgo/react-rails-hot-loader) Simple live-reloader for `react-rails`. +- [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro/):React on Rails with Node rendering and many other performance enhancements. - [react-rails-benchmark_renderer](https://github.com/pboling/react-rails-benchmark_renderer) adds performance instrumentation to server rendering. - [Ruby Hyperstack](https://hyperstack.org/): Use Ruby to build reactive user interfaces with React. ## Contributing -๐ŸŽ‰ Thanks for taking the time to contribute! ๐ŸŽ‰ - -With 5 Million+ downloads of the react-rails Gem and another 2 Million+ downloads of react_ujs on NPM, you're helping the biggest React + Rails community! - -By contributing to React-Rails, you agree to abide by the [code of conduct](https://github.com/reactjs/react-rails/blob/main/CODE_OF_CONDUCT.md). - -You can always help by submitting patches or triaging issues. Even offering reproduction steps to issues is incredibly helpful! +๐ŸŽ‰ Thanks for taking the time to contribute! ๐ŸŽ‰ See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details. # Supporters -The following companies support the development of this and other open-source projects maintained by ShakaCode by providing licenses to the ShakaCode team. ShakaCode stands by the usefulness of these products! +The following companies provide licenses to the ShakaCode team, supporting the development of this and other open-source projects maintained by ShakaCode. ShakaCode stands by the usefulness of these products!

@@ -130,5 +133,12 @@ The following companies support the development of this and other open-source pr BrowserStack + + + HoneyBadger + + + +--- -Please see our [Contribution guide](https://github.com/reactjs/react-rails/blob/main/CONTRIBUTING.md) for more info. +ShakaCode is [hiring](https://jobs.lever.co/shakacode/3bdbfdb3-4495-4611-a279-01dddddb351abe)! diff --git a/docs/get-started.md b/docs/get-started.md index 97f1a300d..3d34a2792 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -194,12 +194,16 @@ Then modify the webpack config to use it as a plugin: ```js // config/webpack/webpack.config.js -const { webpackConfig, merge } = require("shakapacker"); -const ForkTSCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); +const { generateWebpackConfig, merge } = require('shakapacker') +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); -module.exports = merge(webpackConfig, { - plugins: [new ForkTSCheckerWebpackPlugin()], -}); +const webpackConfig = generateWebpackConfig() + +module.exports = merge( + webpackConfig, { + plugins: [new ForkTsCheckerWebpackPlugin()] + } +); ``` Doing this will allow React-Rails to support the .tsx extension. Additionally, it is recommended to add `ts` and `tsx` to the `server_renderer_extensions` in your application configuration: diff --git a/gemfiles/base.gemfile.lock b/gemfiles/base.gemfile.lock index a21eb747e..d2f56557e 100644 --- a/gemfiles/base.gemfile.lock +++ b/gemfiles/base.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - react-rails (3.1.1) + react-rails (3.2.0) babel-transpiler (>= 0.7.0) connection_pool execjs @@ -11,67 +11,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -110,7 +110,7 @@ GEM concurrent-ruby (1.2.2) connection_pool (2.4.0) crass (1.0.6) - date (3.3.3) + date (3.3.4) docile (1.1.5) erubi (1.12.0) es5-shim-rails (4.0.1) @@ -120,8 +120,8 @@ GEM ffi (1.15.5) formatador (1.1.0) gem-release (2.2.2) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -153,22 +153,26 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.18.0) + minitest-retry (0.2.2) + minitest (>= 5.0) nenv (0.3.0) - net-imap (0.3.4) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.5.0) net-protocol - nio4r (2.5.9) + nio4r (2.7.3) + nokogiri (1.13.8-x86_64-darwin) + racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) @@ -186,28 +190,28 @@ GEM rack (2.2.7) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.4.3) + railties (= 7.0.8.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -217,9 +221,9 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.7.0) - rexml (3.2.5) + rexml (3.2.6) rubyzip (2.3.2) - selenium-webdriver (4.8.3) + selenium-webdriver (4.9.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -230,13 +234,13 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.2) test-unit (2.5.5) - thor (1.2.1) - tilt (2.1.0) - timeout (0.3.2) + thor (1.2.2) + tilt (2.2.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -259,6 +263,7 @@ DEPENDENCIES guard-minitest jbuilder listen (~> 3.0.0) + minitest-retry package_json pry-byebug rails (~> 7.0.x) diff --git a/gemfiles/shakapacker.gemfile b/gemfiles/shakapacker.gemfile index bbd6c5b47..f062cae03 100644 --- a/gemfiles/shakapacker.gemfile +++ b/gemfiles/shakapacker.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org/" -gem "rails", "~> 7.0.x" gem "shakapacker", "7.2.0" gemspec path: "../" diff --git a/gemfiles/shakapacker.gemfile.lock b/gemfiles/shakapacker.gemfile.lock index 7c2d64807..bfada4231 100644 --- a/gemfiles/shakapacker.gemfile.lock +++ b/gemfiles/shakapacker.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - react-rails (3.1.1) + react-rails (3.2.0) babel-transpiler (>= 0.7.0) connection_pool execjs @@ -11,67 +11,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -110,7 +110,7 @@ GEM concurrent-ruby (1.2.2) connection_pool (2.4.0) crass (1.0.6) - date (3.3.3) + date (3.3.4) docile (1.1.5) erubi (1.12.0) es5-shim-rails (4.0.1) @@ -153,22 +153,24 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) minitest (5.18.0) + minitest-retry (0.2.2) + minitest (>= 5.0) nenv (0.3.0) - net-imap (0.3.4) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.5.0) net-protocol - nio4r (2.5.9) + nio4r (2.7.3) nokogiri (1.14.3-x86_64-darwin) racc (~> 1.4) nokogiri (1.14.3-x86_64-linux) @@ -190,28 +192,28 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.4.3) + railties (= 7.0.8.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -221,9 +223,9 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (2.7.0) - rexml (3.2.5) + rexml (3.2.6) rubyzip (2.3.2) - selenium-webdriver (4.8.3) + selenium-webdriver (4.9.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -241,13 +243,17 @@ GEM simplecov-html (~> 0.10.0) simplecov-html (0.10.2) test-unit (2.5.5) - thor (1.2.1) - tilt (2.1.0) - timeout (0.3.2) + thor (1.2.2) + tilt (2.2.0) + timeout (0.4.1) + turbo-rails (2.0.5) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - websocket (1.2.9) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -270,13 +276,15 @@ DEPENDENCIES guard-minitest jbuilder listen (~> 3.0.0) + minitest-retry package_json pry-byebug - rails (~> 7.0.x) + rails (~> 7.0.7, >= 7.0.7.2) react-rails! selenium-webdriver shakapacker (= 7.2.0) test-unit (~> 2.5) + turbo-rails BUNDLED WITH 2.4.9 diff --git a/gemfiles/sprockets_3.gemfile b/gemfiles/sprockets_3.gemfile index ca312487d..cfbf1cf3a 100644 --- a/gemfiles/sprockets_3.gemfile +++ b/gemfiles/sprockets_3.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org/" -gem "rails", "~> 7.0.x" gem "sprockets", "~> 3.5" gem "sprockets-rails" gem "turbolinks", "~> 5" diff --git a/gemfiles/sprockets_3.gemfile.lock b/gemfiles/sprockets_3.gemfile.lock index d6c114564..5199577aa 100644 --- a/gemfiles/sprockets_3.gemfile.lock +++ b/gemfiles/sprockets_3.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - react-rails (3.1.1) + react-rails (3.2.0) babel-transpiler (>= 0.7.0) connection_pool execjs @@ -11,67 +11,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -96,7 +96,6 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) - childprocess (3.0.0) codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) coderay (1.1.2) @@ -110,7 +109,7 @@ GEM concurrent-ruby (1.1.10) connection_pool (2.2.2) crass (1.0.6) - date (3.3.3) + date (3.3.4) docile (1.1.5) erubi (1.11.0) es5-shim-rails (4.0.1) @@ -154,23 +153,25 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) method_source (0.9.2) mini_mime (1.1.2) mini_racer (0.6.4) libv8-node (~> 16.19.0.0) minitest (5.16.3) + minitest-retry (0.2.2) + minitest (>= 5.0) nenv (0.3.0) - net-imap (0.3.4) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.5.0) net-protocol - nio4r (2.5.9) + nio4r (2.7.3) nokogiri (1.13.8-x86_64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) @@ -190,28 +191,28 @@ GEM rack (2.2.4) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.4.3) + railties (= 7.0.8.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -221,10 +222,12 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (1.6.0) - rubyzip (2.0.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) + rexml (3.2.6) + rubyzip (2.3.2) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) shellany (0.0.1) simplecov (0.13.0) docile (~> 1.1.0) @@ -241,13 +244,18 @@ GEM test-unit (2.5.5) thor (1.2.1) tilt (2.0.10) - timeout (0.3.2) + timeout (0.4.1) + turbo-rails (2.0.5) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -271,14 +279,16 @@ DEPENDENCIES jbuilder listen (~> 3.0.0) mini_racer + minitest-retry package_json pry-byebug - rails (~> 7.0.x) + rails (~> 7.0.7, >= 7.0.7.2) react-rails! selenium-webdriver sprockets (~> 3.5) sprockets-rails test-unit (~> 2.5) + turbo-rails turbolinks (~> 5) BUNDLED WITH diff --git a/gemfiles/sprockets_4.gemfile b/gemfiles/sprockets_4.gemfile index 245032a24..f58f2eb47 100644 --- a/gemfiles/sprockets_4.gemfile +++ b/gemfiles/sprockets_4.gemfile @@ -2,7 +2,6 @@ source "http://rubygems.org/" -gem "rails", "~> 7.0.x" gem "sprockets", "~> 4.0.x" gem "sprockets-rails" gem "turbolinks", "~> 5" diff --git a/gemfiles/sprockets_4.gemfile.lock b/gemfiles/sprockets_4.gemfile.lock index 0de2c85bf..de4452e0f 100644 --- a/gemfiles/sprockets_4.gemfile.lock +++ b/gemfiles/sprockets_4.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - react-rails (3.1.1) + react-rails (3.2.0) babel-transpiler (>= 0.7.0) connection_pool execjs @@ -11,67 +11,67 @@ PATH GEM remote: http://rubygems.org/ specs: - actioncable (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4.3) - actionpack (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activesupport (= 7.0.4.3) + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4.3) - actionview (= 7.0.4.3) - activesupport (= 7.0.4.3) - rack (~> 2.0, >= 2.2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4.3) - actionpack (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4.3) - activesupport (= 7.0.4.3) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4.3) - activesupport (= 7.0.4.3) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) globalid (>= 0.3.6) - activemodel (7.0.4.3) - activesupport (= 7.0.4.3) - activerecord (7.0.4.3) - activemodel (= 7.0.4.3) - activesupport (= 7.0.4.3) - activestorage (7.0.4.3) - actionpack (= 7.0.4.3) - activejob (= 7.0.4.3) - activerecord (= 7.0.4.3) - activesupport (= 7.0.4.3) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4.3) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -96,7 +96,6 @@ GEM rack-test (>= 0.6.3) regexp_parser (~> 1.5) xpath (~> 3.2) - childprocess (3.0.0) codeclimate-test-reporter (1.0.9) simplecov (<= 0.13) coderay (1.1.2) @@ -110,7 +109,7 @@ GEM concurrent-ruby (1.1.10) connection_pool (2.2.2) crass (1.0.6) - date (3.3.3) + date (3.3.4) docile (1.1.5) erubi (1.11.0) es5-shim-rails (4.0.1) @@ -154,23 +153,25 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) method_source (0.9.2) mini_mime (1.1.2) mini_racer (0.6.4) libv8-node (~> 16.19.0.0) minitest (5.16.3) + minitest-retry (0.2.2) + minitest (>= 5.0) nenv (0.3.0) - net-imap (0.3.4) + net-imap (0.4.11) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.5.0) net-protocol - nio4r (2.5.9) + nio4r (2.7.3) nokogiri (1.13.8-x86_64-darwin) racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) @@ -190,28 +191,28 @@ GEM rack (2.2.4) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (7.0.4.3) - actioncable (= 7.0.4.3) - actionmailbox (= 7.0.4.3) - actionmailer (= 7.0.4.3) - actionpack (= 7.0.4.3) - actiontext (= 7.0.4.3) - actionview (= 7.0.4.3) - activejob (= 7.0.4.3) - activemodel (= 7.0.4.3) - activerecord (= 7.0.4.3) - activestorage (= 7.0.4.3) - activesupport (= 7.0.4.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) bundler (>= 1.15.0) - railties (= 7.0.4.3) + railties (= 7.0.8.1) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.3) loofah (~> 2.3) - railties (7.0.4.3) - actionpack (= 7.0.4.3) - activesupport (= 7.0.4.3) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -221,10 +222,12 @@ GEM rb-inotify (0.10.1) ffi (~> 1.0) regexp_parser (1.6.0) - rubyzip (2.0.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) - rubyzip (>= 1.2.2) + rexml (3.2.6) + rubyzip (2.3.2) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) shellany (0.0.1) simplecov (0.13.0) docile (~> 1.1.0) @@ -241,13 +244,18 @@ GEM test-unit (2.5.5) thor (1.2.1) tilt (2.0.10) - timeout (0.3.2) + timeout (0.4.1) + turbo-rails (2.0.5) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - websocket-driver (0.7.5) + websocket (1.2.10) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) @@ -271,14 +279,16 @@ DEPENDENCIES jbuilder listen (~> 3.0.0) mini_racer + minitest-retry package_json pry-byebug - rails (~> 7.0.x) + rails (~> 7.0.7, >= 7.0.7.2) react-rails! selenium-webdriver sprockets (~> 4.0.x) sprockets-rails test-unit (~> 2.5) + turbo-rails turbolinks (~> 5) BUNDLED WITH diff --git a/lib/assets/javascripts/react_ujs.js b/lib/assets/javascripts/react_ujs.js index 0362f6109..4b4ee1308 100644 --- a/lib/assets/javascripts/react_ujs.js +++ b/lib/assets/javascripts/react_ujs.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom","react-dom/server"],t):"object"==typeof exports?exports.ReactRailsUJS=t(require("react"),require("react-dom"),require("react-dom/server")):e.ReactRailsUJS=t(e.React,e.ReactDOM,e.ReactDOMServer)}(self,((__WEBPACK_EXTERNAL_MODULE__787__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__997__)=>(()=>{var __webpack_modules__={634:(e,t,n)=>{"use strict";var o=n(156);t.createRoot=o.createRoot,t.hydrateRoot=o.hydrateRoot},10:(e,t,n)=>{var o=n(787),r=n(156),a=n(997),u=n(230),c=n(121),d=n(831),i=n(37),s=n(39),{supportsHydration:_,reactHydrate:l,createReactRootLike:p}=n(198),f=n(613),v={CLASS_NAME_ATTR:"data-react-class",PROPS_ATTR:"data-react-props",RENDER_ATTR:"data-hydrate",CACHE_ID_ATTR:"data-react-cache-id",TURBOLINKS_PERMANENT_ATTR:"data-turbolinks-permanent",jQuery:"undefined"!=typeof window&&void 0!==window.jQuery&&window.jQuery,components:{},roots:[],findDOMNodes:function(e){var t,n,o=v.CLASS_NAME_ATTR;switch(typeof e){case"undefined":t="["+o+"]",n=document;break;case"object":t="["+o+"]",n=e;break;case"string":t=e+"["+o+"], "+e+" ["+o+"]",n=document}return v.jQuery?v.jQuery(t,n):n.querySelectorAll(t)},getConstructor:c,constructorFromGlobal:c,constructorFromRequireContext:d,constructorFromRequireContextWithGlobalFallback:i,useContext:function(e){this.getConstructor=i(e)},useContexts:function(e){this.getConstructor=s(e)},serverRender:function(e,t,n){var r=this.getConstructor(t),u=o.createElement(r,n);return a[e](u)},mountComponents:function(e){for(var t=v,n=t.findDOMNodes(e),r=0;r{var o=n(528),r=n(921),a=n(228),u=n(724),c=n(968);e.exports=function(e){e.handleEvent&&("undefined"!=typeof Turbolinks&&void 0!==Turbolinks.EVENTS&&c.teardown(e),a.teardown(e),u.teardown(e),r.teardown(e),o.teardown(e)),"addEventListener"in window?(e.handleEvent=function(e,t){document.addEventListener(e,t)},e.removeEvent=function(e,t){document.removeEventListener(e,t)}):(e.handleEvent=function(e,t){window.attachEvent(e,t)},e.removeEvent=function(e,t){window.detachEvent(e,t)}),"undefined"!=typeof Turbolinks&&Turbolinks.supported?void 0!==Turbolinks.EVENTS?c.setup(e):void 0!==Turbolinks.controller?a.setup(e):u.setup(e):"undefined"!=typeof $&&"function"==typeof $.pjax?r.setup(e):o.setup(e)}},528:e=>{e.exports={setup:function(e){"addEventListener"in window?e.handleEvent("DOMContentLoaded",e.handleMount):e.handleEvent("onload",e.handleMount)},teardown:function(e){e.removeEvent("DOMContentLoaded",e.handleMount),e.removeEvent("onload",e.handleMount)}}},921:e=>{e.exports={setup:function(e){e.handleEvent("ready",e.handleMount),e.handleEvent("pjax:end",e.handleMount),e.handleEvent("pjax:beforeReplace",e.handleUnmount)},teardown:function(e){e.removeEvent("ready",e.handleMount),e.removeEvent("pjax:end",e.handleMount),e.removeEvent("pjax:beforeReplace",e.handleUnmount)}}},228:e=>{e.exports={setup:function(e){e.handleEvent("turbolinks:load",e.handleMount)},teardown:function(e){e.removeEvent("turbolinks:load",e.handleMount)}}},968:e=>{e.exports={setup:function(e){e.handleEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)},teardown:function(e){e.removeEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)}}},724:e=>{e.exports={setup:function(e){Turbolinks.pagesCached(0),e.handleEvent("page:change",e.handleMount),e.handleEvent("page:receive",e.handleUnmount)},teardown:function(e){e.removeEvent("page:change",e.handleMount),e.removeEvent("page:receive",e.handleUnmount)}}},121:function(module){var topLevel="undefined"==typeof window?this:window;module.exports=function(className){var constructor;return constructor=topLevel[className],constructor||(constructor=eval(className)),constructor&&constructor.default&&(constructor=constructor.default),constructor}},831:e=>{e.exports=function(e){return function(t){var n=t.split("."),o=n.shift(),r=n,a=e("./"+o);return r.forEach((function(e){a=a[e]})),a.__esModule&&(a=a.default),a}}},37:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=r(e);return function(e){var n;try{n=t(e)}catch(t){try{n=o(e)}catch(e){console.error(t),console.error(e)}}return n}}},39:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=e.map((e=>r(e)));return function(e){var n;try{var r,a,u=0;do{r=t[u];try{n=r(e)}catch(e){a||(a=e)}u+=1}while(u{"use strict";n.r(t),n.d(t,{createReactRootLike:()=>_,reactHydrate:()=>s,supportsHydration:()=>i});var o=n(156),r=n.n(o),a=n(613),u=n.n(a);let c=r();if(u())try{c=n(634)}catch(e){c=r()}const d=c;function i(){return"function"==typeof d.hydrate||"function"==typeof d.hydrateRoot}function s(e,t){return"function"==typeof d.hydrateRoot?d.hydrateRoot(e,t):d.hydrate(t,e)}function _(e){return u()?d.createRoot(e):function(e){return{render:t=>d.render(t,e)}}(e)}},613:(e,t,n)=>{var o,r=n(156);o=void 0!==r&&(r.version.split(".")[0]||16)>=18,e.exports=o},787:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__787__},156:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__156__},997:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__997__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(10);return __webpack_exports__})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom","react-dom/server"],t):"object"==typeof exports?exports.ReactRailsUJS=t(require("react"),require("react-dom"),require("react-dom/server")):e.ReactRailsUJS=t(e.React,e.ReactDOM,e.ReactDOMServer)}(self,((__WEBPACK_EXTERNAL_MODULE__787__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__997__)=>(()=>{var __webpack_modules__={634:(e,t,n)=>{"use strict";var o=n(156);t.createRoot=o.createRoot,t.hydrateRoot=o.hydrateRoot},10:(e,t,n)=>{var o=n(787),r=n(156),a=n(997),u=n(230),c=n(121),i=n(831),d=n(37),s=n(39),{supportsHydration:_,reactHydrate:l,createReactRootLike:p}=n(198),f=n(613),v={CLASS_NAME_ATTR:"data-react-class",PROPS_ATTR:"data-react-props",RENDER_ATTR:"data-hydrate",CACHE_ID_ATTR:"data-react-cache-id",TURBOLINKS_PERMANENT_ATTR:"data-turbolinks-permanent",jQuery:"undefined"!=typeof window&&void 0!==window.jQuery&&window.jQuery,components:{},roots:[],findDOMNodes:function(e){var t,n,o=v.CLASS_NAME_ATTR;switch(typeof e){case"undefined":t="["+o+"]",n=document;break;case"object":t="["+o+"]",n=e;break;case"string":t=e+"["+o+"], "+e+" ["+o+"]",n=document}return v.jQuery?v.jQuery(t,n):n.querySelectorAll(t)},getConstructor:c,constructorFromGlobal:c,constructorFromRequireContext:i,constructorFromRequireContextWithGlobalFallback:d,useContext:function(e){this.getConstructor=d(e)},useContexts:function(e){this.getConstructor=s(e)},serverRender:function(e,t,n){var r=this.getConstructor(t),u=o.createElement(r,n);return a[e](u)},mountComponents:function(e){for(var t=v,n=t.findDOMNodes(e),r=0;r{var o=n(528),r=n(921),a=n(228),u=n(724),c=n(968);e.exports=function(e){e.handleEvent&&("undefined"!=typeof Turbolinks&&void 0!==Turbolinks.EVENTS&&c.teardown(e),a.teardown(e),u.teardown(e),r.teardown(e),o.teardown(e)),"addEventListener"in window?(e.handleEvent=function(e,t){document.addEventListener(e,t)},e.removeEvent=function(e,t){document.removeEventListener(e,t)}):(e.handleEvent=function(e,t){window.attachEvent(e,t)},e.removeEvent=function(e,t){window.detachEvent(e,t)}),"undefined"!=typeof Turbolinks&&Turbolinks.supported?void 0!==Turbolinks.EVENTS?c.setup(e):void 0!==Turbolinks.controller?a.setup(e):u.setup(e):"undefined"!=typeof $&&"function"==typeof $.pjax?r.setup(e):o.setup(e)}},528:e=>{e.exports={setup:function(e){"addEventListener"in window?e.handleEvent("DOMContentLoaded",e.handleMount):e.handleEvent("onload",e.handleMount)},teardown:function(e){e.removeEvent("DOMContentLoaded",e.handleMount),e.removeEvent("onload",e.handleMount)}}},921:e=>{e.exports={setup:function(e){e.handleEvent("ready",e.handleMount),e.handleEvent("pjax:end",e.handleMount),e.handleEvent("pjax:beforeReplace",e.handleUnmount)},teardown:function(e){e.removeEvent("ready",e.handleMount),e.removeEvent("pjax:end",e.handleMount),e.removeEvent("pjax:beforeReplace",e.handleUnmount)}}},228:e=>{e.exports={setup:function(e){e.handleEvent("turbolinks:load",e.handleMount)},teardown:function(e){e.removeEvent("turbolinks:load",e.handleMount)}}},968:e=>{e.exports={setup:function(e){e.handleEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)},teardown:function(e){e.removeEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)}}},724:e=>{e.exports={setup:function(e){Turbolinks.pagesCached(0),e.handleEvent("page:change",e.handleMount),e.handleEvent("page:receive",e.handleUnmount)},teardown:function(e){e.removeEvent("page:change",e.handleMount),e.removeEvent("page:receive",e.handleUnmount)}}},121:function(module){var topLevel="undefined"==typeof window?this:window;module.exports=function(className){var constructor;return constructor=topLevel[className],constructor||(constructor=eval(className)),constructor&&constructor.default&&(constructor=constructor.default),constructor}},831:e=>{e.exports=function(e){return function(t){var n=t.split("."),o=n.shift(),r=n,a=e("./"+o);return r.forEach((function(e){a=a[e]})),a.__esModule&&(a=a.default),a}}},37:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=r(e);return function(e){var n;try{n=t(e)}catch(t){try{n=o(e)}catch(e){console.error(t),console.error(e)}}return n}}},39:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=e.map((e=>r(e)));return function(e){var n;try{var r,a,u=0;do{r=t[u];try{n=r(e)}catch(e){a||(a=e)}u+=1}while(u{"use strict";n.r(t),n.d(t,{createReactRootLike:()=>_,reactHydrate:()=>s,supportsHydration:()=>d});var o=n(156),r=n.n(o),a=n(613),u=n.n(a);let c=r();if(u())try{c=n(634)}catch(e){c=r()}const i=c;function d(){return"function"==typeof i.hydrate||"function"==typeof i.hydrateRoot}function s(e,t){return"function"==typeof i.hydrateRoot?i.hydrateRoot(e,t):i.hydrate(t,e)}function _(e){return u()?i.createRoot(e):function(e){return{render:t=>i.render(t,e)}}(e)}},613:(e,t,n)=>{var o,r=n(156);o=void 0!==r&&(r.version.split(".")[0]||16)>=18,e.exports=o},787:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__787__},156:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__156__},997:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__997__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(10);return __webpack_exports__})())); \ No newline at end of file diff --git a/lib/react/rails/version.rb b/lib/react/rails/version.rb index 01c34b9c3..8d4f95bdb 100644 --- a/lib/react/rails/version.rb +++ b/lib/react/rails/version.rb @@ -4,6 +4,6 @@ module React module Rails # If you change this, make sure to update VERSIONS.md # and republish the UJS by updating package.json and `bundle exec rake ujs:publish` - VERSION = "3.2.0" + VERSION = "3.2.1" end end diff --git a/package.json b/package.json index c82c33051..767544725 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react_ujs", - "version": "3.2.0", + "version": "3.2.1", "description": "Rails UJS for the react-rails gem", "repository": "reactjs/react-rails", "main": "react_ujs/index.js", diff --git a/react-rails.gemspec b/react-rails.gemspec index 39f06120e..b977bfadc 100644 --- a/react-rails.gemspec +++ b/react-rails.gemspec @@ -29,7 +29,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'test-unit', '~> 2.5' s.add_development_dependency 'pry-byebug' s.add_development_dependency 'package_json' - + s.add_development_dependency 'rails', '~> 7.0.7', '>= 7.0.7.2' + s.add_development_dependency 'turbo-rails' + s.add_development_dependency 'minitest-retry' s.add_dependency 'connection_pool' s.add_dependency 'execjs' diff --git a/react_ujs/dist/react_ujs.js b/react_ujs/dist/react_ujs.js index 0362f6109..4b4ee1308 100644 --- a/react_ujs/dist/react_ujs.js +++ b/react_ujs/dist/react_ujs.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom","react-dom/server"],t):"object"==typeof exports?exports.ReactRailsUJS=t(require("react"),require("react-dom"),require("react-dom/server")):e.ReactRailsUJS=t(e.React,e.ReactDOM,e.ReactDOMServer)}(self,((__WEBPACK_EXTERNAL_MODULE__787__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__997__)=>(()=>{var __webpack_modules__={634:(e,t,n)=>{"use strict";var o=n(156);t.createRoot=o.createRoot,t.hydrateRoot=o.hydrateRoot},10:(e,t,n)=>{var o=n(787),r=n(156),a=n(997),u=n(230),c=n(121),d=n(831),i=n(37),s=n(39),{supportsHydration:_,reactHydrate:l,createReactRootLike:p}=n(198),f=n(613),v={CLASS_NAME_ATTR:"data-react-class",PROPS_ATTR:"data-react-props",RENDER_ATTR:"data-hydrate",CACHE_ID_ATTR:"data-react-cache-id",TURBOLINKS_PERMANENT_ATTR:"data-turbolinks-permanent",jQuery:"undefined"!=typeof window&&void 0!==window.jQuery&&window.jQuery,components:{},roots:[],findDOMNodes:function(e){var t,n,o=v.CLASS_NAME_ATTR;switch(typeof e){case"undefined":t="["+o+"]",n=document;break;case"object":t="["+o+"]",n=e;break;case"string":t=e+"["+o+"], "+e+" ["+o+"]",n=document}return v.jQuery?v.jQuery(t,n):n.querySelectorAll(t)},getConstructor:c,constructorFromGlobal:c,constructorFromRequireContext:d,constructorFromRequireContextWithGlobalFallback:i,useContext:function(e){this.getConstructor=i(e)},useContexts:function(e){this.getConstructor=s(e)},serverRender:function(e,t,n){var r=this.getConstructor(t),u=o.createElement(r,n);return a[e](u)},mountComponents:function(e){for(var t=v,n=t.findDOMNodes(e),r=0;r{var o=n(528),r=n(921),a=n(228),u=n(724),c=n(968);e.exports=function(e){e.handleEvent&&("undefined"!=typeof Turbolinks&&void 0!==Turbolinks.EVENTS&&c.teardown(e),a.teardown(e),u.teardown(e),r.teardown(e),o.teardown(e)),"addEventListener"in window?(e.handleEvent=function(e,t){document.addEventListener(e,t)},e.removeEvent=function(e,t){document.removeEventListener(e,t)}):(e.handleEvent=function(e,t){window.attachEvent(e,t)},e.removeEvent=function(e,t){window.detachEvent(e,t)}),"undefined"!=typeof Turbolinks&&Turbolinks.supported?void 0!==Turbolinks.EVENTS?c.setup(e):void 0!==Turbolinks.controller?a.setup(e):u.setup(e):"undefined"!=typeof $&&"function"==typeof $.pjax?r.setup(e):o.setup(e)}},528:e=>{e.exports={setup:function(e){"addEventListener"in window?e.handleEvent("DOMContentLoaded",e.handleMount):e.handleEvent("onload",e.handleMount)},teardown:function(e){e.removeEvent("DOMContentLoaded",e.handleMount),e.removeEvent("onload",e.handleMount)}}},921:e=>{e.exports={setup:function(e){e.handleEvent("ready",e.handleMount),e.handleEvent("pjax:end",e.handleMount),e.handleEvent("pjax:beforeReplace",e.handleUnmount)},teardown:function(e){e.removeEvent("ready",e.handleMount),e.removeEvent("pjax:end",e.handleMount),e.removeEvent("pjax:beforeReplace",e.handleUnmount)}}},228:e=>{e.exports={setup:function(e){e.handleEvent("turbolinks:load",e.handleMount)},teardown:function(e){e.removeEvent("turbolinks:load",e.handleMount)}}},968:e=>{e.exports={setup:function(e){e.handleEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)},teardown:function(e){e.removeEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)}}},724:e=>{e.exports={setup:function(e){Turbolinks.pagesCached(0),e.handleEvent("page:change",e.handleMount),e.handleEvent("page:receive",e.handleUnmount)},teardown:function(e){e.removeEvent("page:change",e.handleMount),e.removeEvent("page:receive",e.handleUnmount)}}},121:function(module){var topLevel="undefined"==typeof window?this:window;module.exports=function(className){var constructor;return constructor=topLevel[className],constructor||(constructor=eval(className)),constructor&&constructor.default&&(constructor=constructor.default),constructor}},831:e=>{e.exports=function(e){return function(t){var n=t.split("."),o=n.shift(),r=n,a=e("./"+o);return r.forEach((function(e){a=a[e]})),a.__esModule&&(a=a.default),a}}},37:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=r(e);return function(e){var n;try{n=t(e)}catch(t){try{n=o(e)}catch(e){console.error(t),console.error(e)}}return n}}},39:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=e.map((e=>r(e)));return function(e){var n;try{var r,a,u=0;do{r=t[u];try{n=r(e)}catch(e){a||(a=e)}u+=1}while(u{"use strict";n.r(t),n.d(t,{createReactRootLike:()=>_,reactHydrate:()=>s,supportsHydration:()=>i});var o=n(156),r=n.n(o),a=n(613),u=n.n(a);let c=r();if(u())try{c=n(634)}catch(e){c=r()}const d=c;function i(){return"function"==typeof d.hydrate||"function"==typeof d.hydrateRoot}function s(e,t){return"function"==typeof d.hydrateRoot?d.hydrateRoot(e,t):d.hydrate(t,e)}function _(e){return u()?d.createRoot(e):function(e){return{render:t=>d.render(t,e)}}(e)}},613:(e,t,n)=>{var o,r=n(156);o=void 0!==r&&(r.version.split(".")[0]||16)>=18,e.exports=o},787:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__787__},156:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__156__},997:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__997__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(10);return __webpack_exports__})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom"),require("react-dom/server")):"function"==typeof define&&define.amd?define(["react","react-dom","react-dom/server"],t):"object"==typeof exports?exports.ReactRailsUJS=t(require("react"),require("react-dom"),require("react-dom/server")):e.ReactRailsUJS=t(e.React,e.ReactDOM,e.ReactDOMServer)}(self,((__WEBPACK_EXTERNAL_MODULE__787__,__WEBPACK_EXTERNAL_MODULE__156__,__WEBPACK_EXTERNAL_MODULE__997__)=>(()=>{var __webpack_modules__={634:(e,t,n)=>{"use strict";var o=n(156);t.createRoot=o.createRoot,t.hydrateRoot=o.hydrateRoot},10:(e,t,n)=>{var o=n(787),r=n(156),a=n(997),u=n(230),c=n(121),i=n(831),d=n(37),s=n(39),{supportsHydration:_,reactHydrate:l,createReactRootLike:p}=n(198),f=n(613),v={CLASS_NAME_ATTR:"data-react-class",PROPS_ATTR:"data-react-props",RENDER_ATTR:"data-hydrate",CACHE_ID_ATTR:"data-react-cache-id",TURBOLINKS_PERMANENT_ATTR:"data-turbolinks-permanent",jQuery:"undefined"!=typeof window&&void 0!==window.jQuery&&window.jQuery,components:{},roots:[],findDOMNodes:function(e){var t,n,o=v.CLASS_NAME_ATTR;switch(typeof e){case"undefined":t="["+o+"]",n=document;break;case"object":t="["+o+"]",n=e;break;case"string":t=e+"["+o+"], "+e+" ["+o+"]",n=document}return v.jQuery?v.jQuery(t,n):n.querySelectorAll(t)},getConstructor:c,constructorFromGlobal:c,constructorFromRequireContext:i,constructorFromRequireContextWithGlobalFallback:d,useContext:function(e){this.getConstructor=d(e)},useContexts:function(e){this.getConstructor=s(e)},serverRender:function(e,t,n){var r=this.getConstructor(t),u=o.createElement(r,n);return a[e](u)},mountComponents:function(e){for(var t=v,n=t.findDOMNodes(e),r=0;r{var o=n(528),r=n(921),a=n(228),u=n(724),c=n(968);e.exports=function(e){e.handleEvent&&("undefined"!=typeof Turbolinks&&void 0!==Turbolinks.EVENTS&&c.teardown(e),a.teardown(e),u.teardown(e),r.teardown(e),o.teardown(e)),"addEventListener"in window?(e.handleEvent=function(e,t){document.addEventListener(e,t)},e.removeEvent=function(e,t){document.removeEventListener(e,t)}):(e.handleEvent=function(e,t){window.attachEvent(e,t)},e.removeEvent=function(e,t){window.detachEvent(e,t)}),"undefined"!=typeof Turbolinks&&Turbolinks.supported?void 0!==Turbolinks.EVENTS?c.setup(e):void 0!==Turbolinks.controller?a.setup(e):u.setup(e):"undefined"!=typeof $&&"function"==typeof $.pjax?r.setup(e):o.setup(e)}},528:e=>{e.exports={setup:function(e){"addEventListener"in window?e.handleEvent("DOMContentLoaded",e.handleMount):e.handleEvent("onload",e.handleMount)},teardown:function(e){e.removeEvent("DOMContentLoaded",e.handleMount),e.removeEvent("onload",e.handleMount)}}},921:e=>{e.exports={setup:function(e){e.handleEvent("ready",e.handleMount),e.handleEvent("pjax:end",e.handleMount),e.handleEvent("pjax:beforeReplace",e.handleUnmount)},teardown:function(e){e.removeEvent("ready",e.handleMount),e.removeEvent("pjax:end",e.handleMount),e.removeEvent("pjax:beforeReplace",e.handleUnmount)}}},228:e=>{e.exports={setup:function(e){e.handleEvent("turbolinks:load",e.handleMount)},teardown:function(e){e.removeEvent("turbolinks:load",e.handleMount)}}},968:e=>{e.exports={setup:function(e){e.handleEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)},teardown:function(e){e.removeEvent(Turbolinks.EVENTS.CHANGE,e.handleMount),e.removeEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,e.handleUnmount)}}},724:e=>{e.exports={setup:function(e){Turbolinks.pagesCached(0),e.handleEvent("page:change",e.handleMount),e.handleEvent("page:receive",e.handleUnmount)},teardown:function(e){e.removeEvent("page:change",e.handleMount),e.removeEvent("page:receive",e.handleUnmount)}}},121:function(module){var topLevel="undefined"==typeof window?this:window;module.exports=function(className){var constructor;return constructor=topLevel[className],constructor||(constructor=eval(className)),constructor&&constructor.default&&(constructor=constructor.default),constructor}},831:e=>{e.exports=function(e){return function(t){var n=t.split("."),o=n.shift(),r=n,a=e("./"+o);return r.forEach((function(e){a=a[e]})),a.__esModule&&(a=a.default),a}}},37:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=r(e);return function(e){var n;try{n=t(e)}catch(t){try{n=o(e)}catch(e){console.error(t),console.error(e)}}return n}}},39:(e,t,n)=>{var o=n(121),r=n(831);e.exports=function(e){var t=e.map((e=>r(e)));return function(e){var n;try{var r,a,u=0;do{r=t[u];try{n=r(e)}catch(e){a||(a=e)}u+=1}while(u{"use strict";n.r(t),n.d(t,{createReactRootLike:()=>_,reactHydrate:()=>s,supportsHydration:()=>d});var o=n(156),r=n.n(o),a=n(613),u=n.n(a);let c=r();if(u())try{c=n(634)}catch(e){c=r()}const i=c;function d(){return"function"==typeof i.hydrate||"function"==typeof i.hydrateRoot}function s(e,t){return"function"==typeof i.hydrateRoot?i.hydrateRoot(e,t):i.hydrate(t,e)}function _(e){return u()?i.createRoot(e):function(e){return{render:t=>i.render(t,e)}}(e)}},613:(e,t,n)=>{var o,r=n(156);o=void 0!==r&&(r.version.split(".")[0]||16)>=18,e.exports=o},787:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__787__},156:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__156__},997:e=>{"use strict";e.exports=__WEBPACK_EXTERNAL_MODULE__997__}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(10);return __webpack_exports__})())); \ No newline at end of file diff --git a/react_ujs/index.js b/react_ujs/index.js index 0e0a209a5..2d8a70aaf 100644 --- a/react_ujs/index.js +++ b/react_ujs/index.js @@ -131,11 +131,8 @@ var ReactRailsUJS = { if (hydrate && supportsHydration()) { component = reactHydrate(node, component); } else { - const root = createReactRootLike(node) + const root = this.findOrCreateRoot(node); component = root.render(component); - if(supportsRootApi) { - this.roots.push({"node": node, "root": root}) - } } } } @@ -164,19 +161,44 @@ var ReactRailsUJS = { detectEvents(this) }, - unmountRoot: function(node) { - var targetRoots = this.roots.filter( + findOrCreateRoot: function(node) { + var root = this.findRoot(node); + if (!root) { + root = createReactRootLike(node); + if(supportsRootApi) { + this.roots.push({"node": node, "root": root}) + } + } + + return root; + }, + + findRoot: function(node) { + if (!supportsRootApi) { + return; + } + var rootElement = this.roots.find( function(rootElement) { return rootElement["node"] && (rootElement["node"] === node) } - ) - targetRoots.forEach( + ); + if (rootElement) { + return rootElement["root"]; + } + }, + + unmountRoot: function(node) { + var targetRoot = this.findRoot(node); + if (!targetRoot) { + return; + } + + targetRoot.unmount(); + this.roots = this.roots.filter( function(rootElement) { - rootElement["root"].unmount(); - rootElement["root"] = null; - rootElement["node"] = null; + return rootElement["node"] !== node } - ) + ); } } @@ -193,6 +215,7 @@ ReactRailsUJS.handleUnmount = function(e) { if (e && e.target) { target = e.target; } + ReactRailsUJS.unmountComponents(target); } diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 1ff0944d0..e21efdd56 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -3,5 +3,5 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception + # protect_from_forgery with: :exception end diff --git a/test/dummy/app/controllers/counters_controller.rb b/test/dummy/app/controllers/counters_controller.rb new file mode 100644 index 000000000..2d4296db4 --- /dev/null +++ b/test/dummy/app/controllers/counters_controller.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class CountersController < ApplicationController + def index + @counters = [{ name: "Counter 1" }] + end + + def create + @counter = { name: "Counter 2" } + end +end diff --git a/test/dummy/app/javascript/components/Counter.js b/test/dummy/app/javascript/components/Counter.js new file mode 100644 index 000000000..f1bcd6446 --- /dev/null +++ b/test/dummy/app/javascript/components/Counter.js @@ -0,0 +1,23 @@ +var React = require("react"); +var createReactClass = require("create-react-class"); + +module.exports = createReactClass({ + getInitialState: function () { + return { count: 0 }; + }, + handleClick: function () { + this.setState({ count: this.state.count + 1 }); + }, + render: function () { + return ( +
+

+ {this.props.name} - {this.state.count} +

+ +
+ ); + }, +}); diff --git a/test/dummy/app/javascript/controllers/mount_counters.js b/test/dummy/app/javascript/controllers/mount_counters.js new file mode 100644 index 000000000..363687524 --- /dev/null +++ b/test/dummy/app/javascript/controllers/mount_counters.js @@ -0,0 +1,26 @@ +var { Controller } = require("@hotwired/stimulus"); +var ReactRailsUJS = require("react_ujs"); + +module.exports = class extends Controller { + connect() { + this.observeChange(); + } + + disconnect() { + this.observer.disconnect(); + } + + observeChange() { + var element = this.element; + var callback = function (mutationsList, _observer) { + mutationsList.forEach(function (mutation) { + if (mutation.type === "childList") { + ReactRailsUJS.mountComponents(element); + } + }); + }; + + this.observer = new MutationObserver(callback); + this.observer.observe(this.element, { childList: true }); + } +}; diff --git a/test/dummy/app/javascript/packs/application.js b/test/dummy/app/javascript/packs/application.js index bffb39c69..74444a371 100644 --- a/test/dummy/app/javascript/packs/application.js +++ b/test/dummy/app/javascript/packs/application.js @@ -1,8 +1,15 @@ -var ctx = require.context("components", true) -var ReactRailsUJS = require("react_ujs") -ReactRailsUJS.useContext(ctx) -var React = require("react") +require("@hotwired/turbo-rails"); +var { Application } = require("@hotwired/stimulus"); +var MountCountersController = require("../controllers/mount_counters"); -window.GlobalComponent = function(props) { - return React.createElement("h1", null, "Global Component") -} +window.Stimulus = Application.start(); +Stimulus.register("mount-counters", MountCountersController); + +var ctx = require.context("components", true); +var ReactRailsUJS = require("react_ujs"); +ReactRailsUJS.useContext(ctx); +var React = require("react"); + +window.GlobalComponent = function (props) { + return React.createElement("h1", null, "Global Component"); +}; diff --git a/test/dummy/app/views/counters/create.turbo_stream.erb b/test/dummy/app/views/counters/create.turbo_stream.erb new file mode 100644 index 000000000..e0e93eb23 --- /dev/null +++ b/test/dummy/app/views/counters/create.turbo_stream.erb @@ -0,0 +1,3 @@ +<%= turbo_stream.append :counters do %> + <%= react_component("Counter", @counter) %> +<% end %> diff --git a/test/dummy/app/views/counters/index.html.erb b/test/dummy/app/views/counters/index.html.erb new file mode 100644 index 000000000..bbac3df62 --- /dev/null +++ b/test/dummy/app/views/counters/index.html.erb @@ -0,0 +1,10 @@ +

React 18 bug reproduction

+ +<%= turbo_frame_tag :counters, data: { controller: "mount-counters" } do %> + <% @counters.each do |counter| %> + <%= react_component("Counter", counter) %> + <% end %> +<% end %> +<%= form_with(url: counters_path, method: :post, data: { turbo: true, turbo_stream: true }) do |form| %> + <%= form.submit "Add counter" %> +<% end %> diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index 30727da9b..6bf5f8447 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -3,7 +3,6 @@ Dummy <% if ShakapackerHelpers.available? %> - <%= javascript_include_tag "turbolinks_only", "data-turbolinks-track" => true %> <%= javascript_pack_tag "application" %> <% elsif SprocketsHelpers.available? %> <%= javascript_include_tag "application", "data-turbolinks-track" => true %> diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index d517d901a..5a4178854 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require File.expand_path("boot", __dir__) +require_relative("../../support/sprockets_helpers") +require_relative("../../support/webpacker_helpers") # Pick the frameworks you want: # require "active_record/railtie" @@ -18,6 +20,9 @@ module Dummy class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 7.0 + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb index d0f0d3b5d..4b63f2893 100644 --- a/test/dummy/config/initializers/backtrace_silencers.rb +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb index aa7435fbc..dc8474221 100644 --- a/test/dummy/config/initializers/inflections.rb +++ b/test/dummy/config/initializers/inflections.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb index f75864f9c..df5ec138c 100644 --- a/test/dummy/config/initializers/mime_types.rb +++ b/test/dummy/config/initializers/mime_types.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index ef57ce2ac..0c308456b 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -3,6 +3,7 @@ Dummy::Application.routes.draw do get "no-turbolinks", to: "pages#no_turbolinks" resources :pages, only: [:show] + resources :counters, only: %i[create index] resources :server, only: [:show] do collection do get :console_example diff --git a/test/dummy/package.json b/test/dummy/package.json index e2bec6b03..63a49f4c1 100644 --- a/test/dummy/package.json +++ b/test/dummy/package.json @@ -9,6 +9,8 @@ "@babel/preset-react": "^7.17.12", "@babel/preset-typescript": "^7.17.12", "@babel/runtime": "^7.18.3", + "@hotwired/stimulus": "^3.2.2", + "@hotwired/turbo-rails": "^7.3.0", "babel-loader": "^8.2.5", "babel-plugin-macros": "^3.1.0", "compression-webpack-plugin": "^9.2.0", @@ -17,10 +19,10 @@ "css-minimizer-webpack-plugin": "^2.0.0", "mini-css-extract-plugin": "^1.6.2", "pnp-webpack-plugin": "^1.7.0", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react_ujs": "file:.yalc/react_ujs", - "shakapacker": "7.0.2", + "shakapacker": "7.2.0", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.3.3", "webpack": "^5.73.0", diff --git a/test/dummy/yarn.lock b/test/dummy/yarn.lock index 00473501d..f88337521 100644 --- a/test/dummy/yarn.lock +++ b/test/dummy/yarn.lock @@ -1100,6 +1100,24 @@ resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== +"@hotwired/stimulus@^3.2.2": + version "3.2.2" + resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608" + integrity sha512-eGeIqNOQpXoPAIP7tC1+1Yc1yl1xnwYqg+3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A== + +"@hotwired/turbo-rails@^7.3.0": + version "7.3.0" + resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-7.3.0.tgz#422c21752509f3edcd6c7b2725bbe9e157815f51" + integrity sha512-fvhO64vp/a2UVQ3jue9WTc2JisMv9XilIC7ViZmXAREVwiQ2S4UC7Go8f9A1j4Xu7DBI6SbFdqILk5ImqVoqyA== + dependencies: + "@hotwired/turbo" "^7.3.0" + "@rails/actioncable" "^7.0" + +"@hotwired/turbo@^7.3.0": + version "7.3.0" + resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-7.3.0.tgz#2226000fff1aabda9fd9587474565c9929dbf15d" + integrity sha512-Dcu+NaSvHLT7EjrDrkEmH4qET2ZJZ5IcCWmNXxNQTBwlnE5tBZfN6WxZ842n5cHV52DH/AKNirbPBtcEXDLW4g== + "@jest/schemas@^29.6.0": version "29.6.0" resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.0.tgz#0f4cb2c8e3dca80c135507ba5635a4fd755b0040" @@ -1195,6 +1213,11 @@ schema-utils "^3.0.0" source-map "^0.7.3" +"@rails/actioncable@^7.0": + version "7.1.3" + resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.1.3.tgz#4db480347775aeecd4dde2405659eef74a458881" + integrity sha512-ojNvnoZtPN0pYvVFtlO7dyEN9Oml1B6IDM+whGKVak69MMYW99lC2NOWXWeE3bmwEydbP/nn6ERcpfjHVjYQjA== + "@sinclair/typebox@^0.27.8": version "0.27.8" resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" @@ -4062,15 +4085,6 @@ raw-body@2.5.1: iconv-lite "0.4.24" unpipe "1.0.0" -react-dom@^17.0.2: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.2.tgz#ecffb6845e3ad8dbfcdc498f0d0a939736502c23" - integrity sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler "^0.20.2" - react-dom@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-18.2.0.tgz#22aaf38708db2674ed9ada224ca4aa708d821e3d" @@ -4089,14 +4103,6 @@ react-refresh@^0.13.0: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.13.0.tgz#cbd01a4482a177a5da8d44c9755ebb1f26d5a1c1" integrity sha512-XP8A9BT0CpRBD+NYLLeIhld/RqG9+gktUjW1FkE+Vm7OCinbG1SshcK5tb9ls4kzvjZr9mOQc7HYgBngEyPAXg== -react@^17.0.2: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037" - integrity sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - react@^18.2.0: version "18.2.0" resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5" @@ -4104,8 +4110,13 @@ react@^18.2.0: dependencies: loose-envify "^1.1.0" -react_ujs@^2.7.1, "react_ujs@file:.yalc/react_ujs": +react_ujs@^2.7.1: version "2.7.1" + resolved "https://registry.yarnpkg.com/react_ujs/-/react_ujs-2.7.1.tgz#d87cbcb82593fe59d30fc5dbc51800d1571001a8" + integrity sha512-nQ/y/Vn2hZQXjNxFKY4pV5hAQbG3o/8yaRzq3nJAAdk7tMgey/EsMKoDOWlEQxZ+D3J4BtwquW1oCESMiHSHnQ== + +"react_ujs@file:.yalc/react_ujs": + version "3.2.0" dependencies: "@babel/preset-react" "^7.22.5" css-loader "^6.8.1" @@ -4259,14 +4270,6 @@ safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -scheduler@^0.20.2: - version "0.20.2" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.20.2.tgz#4baee39436e34aa93b4874bddcbf0fe8b8b50e91" - integrity sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ== - dependencies: - loose-envify "^1.1.0" - object-assign "^4.1.1" - scheduler@^0.23.0: version "0.23.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.23.0.tgz#ba8041afc3d30eb206a487b6b384002e4e61fdfe" @@ -4414,10 +4417,10 @@ setprototypeof@1.2.0: resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== -shakapacker@7.0.2: - version "7.0.2" - resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-7.0.2.tgz#cd7cb5075fdbf4d06e60d894f9076c8e56643a98" - integrity sha512-TF2GFb0E28fvQpn2L6RdvAHJRZmFMTvpJg93102tCbFywHq3tmTqwD/ijvlD+eMuZ8d1i3AMTnhO+45ayN3dYg== +shakapacker@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-7.2.0.tgz#0b8e03663800d7f2b07e2c93ed3270d4c5cf7306" + integrity sha512-DYqRKjjeeObYXB/OuEUcdy86zyfdMviqO6MmIq8XfXZtLldxsBnUGug2ON3DcKKy5OeCe/wd7Li/pLw1wAKhsw== dependencies: glob "^7.2.0" js-yaml "^4.1.0" diff --git a/test/react/jsx_test.rb b/test/react/jsx_test.rb index c9ed8d43b..25bb14ac8 100644 --- a/test/react/jsx_test.rb +++ b/test/react/jsx_test.rb @@ -22,7 +22,7 @@ STR class NullTransformer - def initialize(_options = {}); end # rubocop:disable-line Style/RedundantInitialize + def initialize(_options = {}); end # rubocop:disable Style/RedundantInitialize def transform(_code) "TRANSFORMED CODE!;\n" diff --git a/test/react/rails/controller_lifecycle_test.rb b/test/react/rails/controller_lifecycle_test.rb index 036901093..4992cde93 100644 --- a/test/react/rails/controller_lifecycle_test.rb +++ b/test/react/rails/controller_lifecycle_test.rb @@ -41,7 +41,7 @@ def teardown get "/pages/1" helper_obj = controller.__react_component_helper - assert(helper_obj.is_a?(DummyHelperImplementation), "It uses the view helper implementation class") + assert_kind_of(DummyHelperImplementation, helper_obj, "It uses the view helper implementation class") end test "it calls setup and teardown methods" do diff --git a/test/react/rails/railtie_test.rb b/test/react/rails/railtie_test.rb index 7b1609c08..8352f0e10 100644 --- a/test/react/rails/railtie_test.rb +++ b/test/react/rails/railtie_test.rb @@ -4,7 +4,7 @@ class RailtieTest < ActionDispatch::IntegrationTest test "reloaders are configured after initializers are loaded" do - @test_file = File.expand_path("../../#{DUMMY_LOCATION}/app/pants/yfronts.js", File.dirname(__FILE__)) + @test_file = File.expand_path("../../dummy/app/pants/yfronts.js", File.dirname(__FILE__)) FileUtils.touch @test_file results = Dummy::Application.reloaders.map(&:updated?) diff --git a/test/react/rails/react_rails_ujs_test.rb b/test/react/rails/react_rails_ujs_test.rb index 698f4a5d5..568b0c0c1 100644 --- a/test/react/rails/react_rails_ujs_test.rb +++ b/test/react/rails/react_rails_ujs_test.rb @@ -10,14 +10,14 @@ class ReactRailsUJSTest < ActionDispatch::IntegrationTest def assert_greeting(page, greeting) assert page.has_content?(greeting), <<~MSG #{page.body} - #{page.driver.browser.manage.logs.get(:browser).inspect} + #{page.driver.browser.logs.get(:browser).inspect} MSG end def refute_greeting(page, greeting) assert page.has_no_content?(greeting), <<~MSG #{page.body} - #{page.driver.browser.manage.logs.get(:browser).inspect} + #{page.driver.browser.logs.get(:browser).inspect} MSG end diff --git a/test/react/rails/realtime_update_test.rb b/test/react/rails/realtime_update_test.rb new file mode 100644 index 000000000..6c7f94e70 --- /dev/null +++ b/test/react/rails/realtime_update_test.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require "test_helper" + +class RealtimeUpdateTest < ActiveSupport::TestCase + ShakapackerHelpers.when_shakapacker_available do + include Capybara::DSL + + def assert_counter_count(page, timer_name, count) + assert page.has_content?("#{timer_name} - #{count}"), <<~MSG + #{page.body} + #{page.driver.browser.logs.get(:browser).inspect} + MSG + end + + setup do + Capybara.current_driver = Capybara.javascript_driver + ShakapackerHelpers.compile + React::ServerRendering.reset_pool + end + + teardown do + ShakapackerHelpers.clear_shakapacker_packs + end + + test "doesn't re-mount the components trees when mountComponents is called" do + visit "/counters" + + assert_counter_count(page, "Counter 1", 0) + page.click_button "Increment Counter 1" + page.click_button "Add counter" + sleep 0.1 + + assert_counter_count(page, "Counter 1", 1) + assert_counter_count(page, "Counter 2", 0) + end + end +end diff --git a/test/react/server_rendering/exec_js_renderer_test.rb b/test/react/server_rendering/exec_js_renderer_test.rb index 887105cc9..ff3b01c5f 100644 --- a/test/react/server_rendering/exec_js_renderer_test.rb +++ b/test/react/server_rendering/exec_js_renderer_test.rb @@ -21,7 +21,7 @@ class ExecJSRendererTest < ActiveSupport::TestCase react_ujs_source = File.read(File.expand_path("../../../lib/assets/javascripts/react_ujs.js", __dir__)) todo_component_source = File.read( File.expand_path( - "../../../#{DUMMY_LOCATION}/app/assets/javascripts/components/PlainJSTodo.js", __FILE__ + "../../dummy/app/assets/javascripts/components/PlainJSTodo.js", __dir__ ) ) code = react_server_source + react_ujs_source + todo_component_source diff --git a/test/react_asset_test.rb b/test/react_asset_test.rb index c832b28a6..6754b10d2 100644 --- a/test/react_asset_test.rb +++ b/test/react_asset_test.rb @@ -13,7 +13,7 @@ class ReactAssetTest < ActionDispatch::IntegrationTest end test "asset pipeline should deliver drop-in react file replacement" do - app_react_file_path = File.expand_path("../#{DUMMY_LOCATION}/vendor/assets/javascripts/react.js", __FILE__) + app_react_file_path = File.expand_path("dummy/vendor/assets/javascripts/react.js", __dir__) react_file_token = "'test_confirmation_token_react_content_non_production';\n" File.write(app_react_file_path, react_file_token) SprocketsHelpers.manually_expire_asset("react.js") diff --git a/test/server_rendered_html_test.rb b/test/server_rendered_html_test.rb index 357be1be6..390ae04b0 100644 --- a/test/server_rendered_html_test.rb +++ b/test/server_rendered_html_test.rb @@ -20,11 +20,11 @@ def wait_to_ensure_asset_pipeline_detects_changes if ShakapackerHelpers.available? file_with_updates = File.expand_path("helper_files/TodoListWithUpdates.js", __dir__) file_without_updates = File.expand_path("helper_files/TodoListWithoutUpdates.js", __dir__) - app_file = File.expand_path("../#{DUMMY_LOCATION}/app/javascript/components/TodoList.js", __FILE__) + app_file = File.expand_path("dummy/app/javascript/components/TodoList.js", __dir__) else file_with_updates = File.expand_path("helper_files/TodoListWithUpdates.js.jsx", __dir__) file_without_updates = File.expand_path("helper_files/TodoListWithoutUpdates.js.jsx", __dir__) - app_file = File.expand_path("../#{DUMMY_LOCATION}/app/assets/javascripts/components/TodoList.js.jsx", __FILE__) + app_file = File.expand_path("dummy/app/assets/javascripts/components/TodoList.js.jsx", __dir__) end FileUtils.cp app_file, file_without_updates @@ -61,13 +61,13 @@ def wait_to_ensure_asset_pipeline_detects_changes end if ShakapackerHelpers.available? - new_file_path = "../#{DUMMY_LOCATION}/app/javascript/components/NewList.js" + new_file_path = "../dummy/app/javascript/components/NewList.js" new_file_contents = <<~JS var React = require("react") module.exports = function() { return "New List" } JS else - new_file_path = "../#{DUMMY_LOCATION}/app/assets/javascripts/components/ZZ_NewComponent.js.jsx" + new_file_path = "../dummy/app/assets/javascripts/components/ZZ_NewComponent.js.jsx" new_file_contents = <<~JS var NewList = function() { return "New List" } JS diff --git a/test/support/sprockets_helpers.rb b/test/support/sprockets_helpers.rb index 10846c472..25b5bb73f 100644 --- a/test/support/sprockets_helpers.rb +++ b/test/support/sprockets_helpers.rb @@ -52,12 +52,12 @@ def precompile_assets Rails.application.assets_manifest = new_manifest end - assets_directory = File.expand_path("../../#{DUMMY_LOCATION}/public/assets", __FILE__) + assets_directory = File.expand_path("../dummy/public/assets", __dir__) raise "Asset precompilation failed" unless Dir.exist?(assets_directory) end def clear_precompiled_assets - assets_directory = File.expand_path("../../#{DUMMY_LOCATION}/public/assets", __FILE__) + assets_directory = File.expand_path("../dummy/public/assets", __dir__) FileUtils.rm_r(assets_directory) ENV.delete("RAILS_GROUPS") end @@ -69,7 +69,7 @@ def invoke_assets_precompile_task # Changing directories is required because: # - assets:precompile runs webpacker:compile when availabled # - webpacker:compile depends on `./bin/webpack`, so `.` must be the app root - Dir.chdir("./test/#{DUMMY_LOCATION}") do + Dir.chdir("./test/dummy") do ENV["RAILS_GROUPS"] = "assets" # required for Rails 3.2 Rake::Task["assets:precompile"].reenable diff --git a/test/support/webpacker_helpers.rb b/test/support/webpacker_helpers.rb index 32ee7694e..b59276a90 100644 --- a/test/support/webpacker_helpers.rb +++ b/test/support/webpacker_helpers.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module ShakapackerHelpers - PACKS_DIRECTORY = File.expand_path("../../#{DUMMY_LOCATION}/public/packs", __FILE__) + PACKS_DIRECTORY = File.expand_path("../dummy/public/packs", __dir__) module_function @@ -19,7 +19,7 @@ def compile return unless available? clear_shakapacker_packs - Dir.chdir("./test/#{DUMMY_LOCATION}") do + Dir.chdir("./test/dummy") do Rake::Task["shakapacker:compile"].reenable Rake::Task["shakapacker:compile"].invoke end @@ -45,7 +45,7 @@ def with_dev_server ENV["NODE_ENV"] = "development" # Start the server in a forked process: - Dir.chdir("test/#{DUMMY_LOCATION}") do + Dir.chdir("test/dummy") do spawn "RAILS_ENV=development ./bin/shakapacker-dev-server" end diff --git a/test/test_helper.rb b/test/test_helper.rb index f40f2d62a..c3793d831 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -5,8 +5,6 @@ SimpleCov.start end -DUMMY_LOCATION = "dummy" - support_path = File.expand_path("support/*.rb", __dir__) Dir.glob(support_path).sort.each do |f| require(f) @@ -15,13 +13,15 @@ # Configure Rails Environment ENV["RAILS_ENV"] = "test" -require File.expand_path("../#{DUMMY_LOCATION}/config/environment.rb", __FILE__) +require File.expand_path("dummy/config/environment.rb", __dir__) require "rails/test_help" require "rails/generators" require "pathname" require "minitest/mock" require "capybara/rails" require "selenium/webdriver" +require "minitest/retry" +Minitest::Retry.use! Dummy::Application.load_tasks ShakapackerHelpers.clear_shakapacker_packs @@ -30,15 +30,15 @@ Capybara.server = :webrick Capybara.register_driver :headless_chrome do |app| - options = Selenium::WebDriver::Chrome::Options.new(args: %w[no-sandbox headless disable-gpu]) + options = Selenium::WebDriver::Chrome::Options.new(args: %w[no-sandbox headless=new disable-gpu]) - Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, timeout: 300) end Capybara.javascript_driver = :headless_chrome Capybara.current_driver = Capybara.javascript_driver -CACHE_PATH = Pathname.new File.expand_path("../#{DUMMY_LOCATION}/tmp/cache", __FILE__) +CACHE_PATH = Pathname.new File.expand_path("dummy/tmp/cache", __dir__) Rails.backtrace_cleaner.remove_silencers!