Skip to content

Commit 8c491af

Browse files
authored
SSR Fixes and better tests for v3.0.0 (#1274)
* Fully support Shakapacker, including tests & SSR
1 parent 0b1600a commit 8c491af

File tree

221 files changed

+5420
-16832
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+5420
-16832
lines changed

.github/workflows/ruby.yml

+44-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
77

88
name: Ruby
9-
109
on: [push]
1110
jobs:
1211
check_react_and_ujs:
@@ -17,12 +16,28 @@ jobs:
1716
runs-on: ubuntu-latest
1817
steps:
1918
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
- name: Save root node_modules to cache
21+
uses: actions/cache@v3
22+
with:
23+
path: node_modules
24+
key: package-node-modules-cache-${{ hashFiles('yarn.lock') }}
25+
- name: Save react-builds/node_modules to cache
26+
uses: actions/cache@v3
27+
with:
28+
path: react-builds/node_modules
29+
key: dummy-app-node-modules-cache-${{ hashFiles('react-builds/yarn.lock') }}
2030
- uses: ruby/setup-ruby@v1
2131
with:
2232
bundler: 2.4.9
2333
ruby-version: ${{ matrix.ruby }}
24-
- uses: actions/setup-node@v3
25-
- run: bundle install
34+
- name: Save dummy app ruby gems to cache
35+
uses: actions/cache@v3
36+
with:
37+
path: vendor/bundle
38+
key: root-gem-cache-${{ hashFiles('Gemfile.lock') }}
39+
- name: Install Ruby Gems
40+
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=vendor/bundle || bundle _2.4.9_ install --path=vendor/bundle --jobs=4 --retry=3
2641
- run: yarn
2742
- run: bundle exec rake react:update
2843
- run: bundle exec rake ujs:update
@@ -35,13 +50,12 @@ jobs:
3550
matrix:
3651
ruby: [2.7]
3752
gemfile:
38-
# These have webpacker:
39-
- rails_5.2_no_sprockets
40-
- rails_5.2_no_sprockets_webpacker_3
41-
- rails_5.2_no_sprockets_webpacker_4
42-
# These don't have webpacker:
43-
- rails_5.2_sprockets_3
44-
- rails_5.2_sprockets_4
53+
# These have shakapacker:
54+
- no_sprockets
55+
- no_sprockets_shakapacker
56+
# These don't have shakapacker:
57+
- sprockets_3
58+
- sprockets_4
4559
runs-on: ubuntu-latest
4660
env:
4761
# $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
@@ -52,13 +66,30 @@ jobs:
5266
steps:
5367
- uses: actions/checkout@v3
5468
- uses: actions/setup-node@v3
69+
- run: npm -g install yalc
70+
- run: yalc publish
71+
- name: Save root node_modules to cache
72+
uses: actions/cache@v3
73+
with:
74+
path: node_modules
75+
key: package-node-modules-cache-${{ hashFiles('yarn.lock') }}
76+
- name: Save test/dummy/node_modules to cache
77+
uses: actions/cache@v3
78+
with:
79+
path: test/dummy/node_modules
80+
key: dummy-app-node-modules-cache-${{ hashFiles('test/dummy/yarn.lock') }}
5581
- uses: ruby/setup-ruby@v1
5682
with:
5783
bundler: 2.4.9
5884
ruby-version: ${{ matrix.ruby }}
59-
# TODO: Impalement caching
60-
# bundler-cache: true
61-
- run: bundle install
85+
- name: Save dummy app ruby gems to cache
86+
uses: actions/cache@v3
87+
with:
88+
path: test/dummy/vendor/bundle
89+
key: dummy-app-gem-cache-${{ hashFiles('${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile.lock') }}
90+
- name: Install Ruby Gems for dummy app
91+
run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=test/dummy/vendor/bundle || bundle _2.4.9_ install --path=test/dummy/vendor/bundle --jobs=4 --retry=3
92+
- run: cd test/dummy && yalc add react_ujs && yarn
6293
- run: bundle exec rake test
6394
env:
6495
NODE_OPTIONS: --openssl-legacy-provider

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ test/*/public/packs
77
**/node_modules
88
react-builds/build
99
coverage/
10+
**/.yalc/**
11+
yalc.lock
12+
/vendor/bundle
13+
.bundle/config

Appraisals

+11-20
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
1-
appraise 'rails-5.2-sprockets_4' do
2-
gem 'rails', '~> 5.2.x'
1+
appraise 'sprockets_4' do
2+
gem 'rails', '~> 7.0.x'
33
gem 'sprockets', '~> 4.0.x'
4+
gem 'sprockets-rails'
45
gem 'turbolinks', '~> 5'
56
gem 'mini_racer', :platforms => :mri
6-
gem 'therubyrhino', :platforms => :jruby
77
end
88

9-
appraise 'rails-5.2-sprockets_3' do
10-
gem 'rails', '~> 5.2.x'
9+
appraise 'sprockets_3' do
10+
gem 'rails', '~> 7.0.x'
1111
gem 'sprockets', '~> 3.5'
12+
gem 'sprockets-rails'
1213
gem 'turbolinks', '~> 5'
1314
gem 'mini_racer', :platforms => :mri
14-
gem 'therubyrhino', :platforms => :jruby
1515
end
1616

17-
appraise 'rails-5.2_no_sprockets_webpacker_3' do
18-
gem 'rails', '~> 5.2.x'
19-
gem 'webpacker', '~> 3.0'
20-
gem 'mini_racer', :platforms => :mri
21-
gem 'therubyrhino', :platforms => :jruby
22-
end
23-
24-
appraise 'rails-5.2_no_sprockets_webpacker_4' do
25-
gem 'rails', '~> 5.2.x'
26-
gem 'webpacker', '~> 4.0'
27-
gem 'mini_racer', :platforms => :mri
28-
gem 'therubyrhino', :platforms => :jruby
17+
appraise 'no_sprockets_shakapacker' do
18+
gem 'rails', '~> 7.0.x'
19+
gem 'shakapacker', '6.6.0'
2920
end
3021

31-
appraise 'rails-5.2-no_sprockets' do
22+
appraise 'no_sprockets' do
3223
# Appraisal adds `turbolinks` to this gemfile because it is
3324
# present in `./Gemfile`.
3425
# But it causes this gemfile to break, so it must be removed
3526
# from `./gemfiles/rails_5_no_sprockets.gemfile` manually.
36-
gem 'rails', '~> 5.2.x'
27+
gem 'rails', '~> 7.0.x'
3728
end

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Changes since last non-beta release.
99

1010
_Please add entries here for your pull requests that are not yet released._
1111

12+
### Breaking Changes
13+
- Remove support & testing for Webpacker 3/4.
14+
- Add support & testing for Shakapacker v6
15+
- Requires separate compilations for server & client bundles (see [Webpack config](https://github.com/reactjs/react-rails/blob/judahmeek/workingCI/test/dummy/config/webpack))
16+
- Replaces WebpackManifestContainer, which searched for assets in the webpack manifest, with SeparateServerBundleContainer, which expects a single server bundle file & does not use the webpack manifest at all.
17+
- All in one PR! #1274
18+
1219
## [2.7.1] - 2023-05-19
1320

1421
#### Bug Fixes

Gemfile.lock

+3-76
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,19 @@ PATH
1111
GEM
1212
remote: http://rubygems.org/
1313
specs:
14-
actioncable (6.0.2.1)
15-
actionpack (= 6.0.2.1)
16-
nio4r (~> 2.0)
17-
websocket-driver (>= 0.6.1)
18-
actionmailbox (6.0.2.1)
19-
actionpack (= 6.0.2.1)
20-
activejob (= 6.0.2.1)
21-
activerecord (= 6.0.2.1)
22-
activestorage (= 6.0.2.1)
23-
activesupport (= 6.0.2.1)
24-
mail (>= 2.7.1)
25-
actionmailer (6.0.2.1)
26-
actionpack (= 6.0.2.1)
27-
actionview (= 6.0.2.1)
28-
activejob (= 6.0.2.1)
29-
mail (~> 2.5, >= 2.5.4)
30-
rails-dom-testing (~> 2.0)
3114
actionpack (6.0.2.1)
3215
actionview (= 6.0.2.1)
3316
activesupport (= 6.0.2.1)
3417
rack (~> 2.0, >= 2.0.8)
3518
rack-test (>= 0.6.3)
3619
rails-dom-testing (~> 2.0)
3720
rails-html-sanitizer (~> 1.0, >= 1.2.0)
38-
actiontext (6.0.2.1)
39-
actionpack (= 6.0.2.1)
40-
activerecord (= 6.0.2.1)
41-
activestorage (= 6.0.2.1)
42-
activesupport (= 6.0.2.1)
43-
nokogiri (>= 1.8.5)
4421
actionview (6.0.2.1)
4522
activesupport (= 6.0.2.1)
4623
builder (~> 3.1)
4724
erubi (~> 1.4)
4825
rails-dom-testing (~> 2.0)
4926
rails-html-sanitizer (~> 1.1, >= 1.2.0)
50-
activejob (6.0.2.1)
51-
activesupport (= 6.0.2.1)
52-
globalid (>= 0.3.6)
53-
activemodel (6.0.2.1)
54-
activesupport (= 6.0.2.1)
55-
activerecord (6.0.2.1)
56-
activemodel (= 6.0.2.1)
57-
activesupport (= 6.0.2.1)
58-
activestorage (6.0.2.1)
59-
actionpack (= 6.0.2.1)
60-
activejob (= 6.0.2.1)
61-
activerecord (= 6.0.2.1)
62-
marcel (~> 0.3.1)
6327
activesupport (6.0.2.1)
6428
concurrent-ruby (~> 1.0, >= 1.0.2)
6529
i18n (>= 0.7, < 2)
@@ -110,8 +74,6 @@ GEM
11074
ffi (1.15.5)
11175
formatador (1.1.0)
11276
gem-release (2.2.2)
113-
globalid (1.0.1)
114-
activesupport (>= 5.0)
11577
guard (2.18.0)
11678
formatador (>= 0.2.4)
11779
listen (>= 2.7, < 4.0)
@@ -138,23 +100,17 @@ GEM
138100
crass (~> 1.0.2)
139101
nokogiri (>= 1.5.9)
140102
lumberjack (1.2.8)
141-
mail (2.7.1)
142-
mini_mime (>= 0.1.1)
143-
marcel (0.3.3)
144-
mimemagic (~> 0.3.2)
145103
matrix (0.4.2)
146104
method_source (1.0.0)
147-
mimemagic (0.3.10)
148-
nokogiri (~> 1)
149-
rake
150105
mini_mime (1.0.2)
151106
mini_portile2 (2.8.1)
152107
minitest (5.17.0)
153108
nenv (0.3.0)
154-
nio4r (2.5.2)
155109
nokogiri (1.14.3)
156110
mini_portile2 (~> 2.8.0)
157111
racc (~> 1.4)
112+
nokogiri (1.14.3-x86_64-linux)
113+
racc (~> 1.4)
158114
notiffany (0.1.3)
159115
nenv (~> 0.1)
160116
shellany (~> 0.0)
@@ -169,21 +125,6 @@ GEM
169125
rack (2.2.6.4)
170126
rack-test (2.0.2)
171127
rack (>= 1.3)
172-
rails (6.0.2.1)
173-
actioncable (= 6.0.2.1)
174-
actionmailbox (= 6.0.2.1)
175-
actionmailer (= 6.0.2.1)
176-
actionpack (= 6.0.2.1)
177-
actiontext (= 6.0.2.1)
178-
actionview (= 6.0.2.1)
179-
activejob (= 6.0.2.1)
180-
activemodel (= 6.0.2.1)
181-
activerecord (= 6.0.2.1)
182-
activestorage (= 6.0.2.1)
183-
activesupport (= 6.0.2.1)
184-
bundler (>= 1.3.0)
185-
railties (= 6.0.2.1)
186-
sprockets-rails (>= 2.0.0)
187128
rails-dom-testing (2.0.3)
188129
activesupport (>= 4.2.0)
189130
nokogiri (>= 1.6)
@@ -212,35 +153,23 @@ GEM
212153
json (>= 1.8, < 3)
213154
simplecov-html (~> 0.10.0)
214155
simplecov-html (0.10.2)
215-
sprockets (4.0.0)
216-
concurrent-ruby (~> 1.0)
217-
rack (> 1, < 3)
218-
sprockets-rails (3.2.1)
219-
actionpack (>= 4.0)
220-
activesupport (>= 4.0)
221-
sprockets (>= 3.0.0)
222156
test-unit (2.5.5)
223157
thor (1.2.1)
224158
thread_safe (0.3.6)
225159
tilt (2.1.0)
226-
turbolinks (5.2.1)
227-
turbolinks-source (~> 5.2)
228-
turbolinks-source (5.2.0)
229160
tzinfo (1.2.10)
230161
thread_safe (~> 0.1)
231162
webdrivers (5.2.0)
232163
nokogiri (~> 1.6)
233164
rubyzip (>= 1.3.0)
234165
selenium-webdriver (~> 4.0)
235-
websocket-driver (0.7.1)
236-
websocket-extensions (>= 0.1.0)
237-
websocket-extensions (0.1.5)
238166
xpath (3.2.0)
239167
nokogiri (~> 1.8)
240168
zeitwerk (2.6.6)
241169

242170
PLATFORMS
243171
ruby
172+
x86_64-linux
244173

245174
DEPENDENCIES
246175
appraisal
@@ -255,11 +184,9 @@ DEPENDENCIES
255184
jbuilder
256185
listen (~> 3.0.0)
257186
pry-byebug
258-
rails (>= 3.2)
259187
react-rails!
260188
selenium-webdriver
261189
test-unit (~> 2.5)
262-
turbolinks
263190
webdrivers
264191

265192
BUNDLED WITH

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Ruby](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml/badge.svg)](https://github.com/reactjs/react-rails/actions/workflows/ruby.yml)
66

77
## News
8-
v2.7.1 is released. Please try it out and report any issues. We'll try to address any critical issues ASAP. We're going shortly release 3.0 which improves support for SSR, but it's a breaking change because it requires updating dependencies, such as going from `webpacker` to `shakapacker`.
8+
v2.7.1 is released. Please try it out and report any issues. We'll try to address any critical issues ASAP. We're going shortly release 3.0, which fully support Shakapacker v6, including SSR.
99

1010
## Summary
1111
React-Rails is a flexible tool to use [React](http://facebook.github.io/react/) with Rails. The benefits:

Rakefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ task default: :test
8585

8686
task :test_setup do
8787
load 'webdrivers/Rakefile'
88-
Dir.chdir('./test/dummy_sprockets') do
89-
`yarn install`
90-
end
91-
Dir.chdir('./test/dummy_webpacker3') do
88+
Dir.chdir('./test/dummy') do
9289
`yarn install`
9390
end
9491
end

gemfiles/.bundle/config

-2
This file was deleted.

gemfiles/rails_5.2_no_sprockets.gemfile renamed to gemfiles/no_sprockets.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
source "http://rubygems.org"
44

5-
gem "rails", "~> 5.2.x"
5+
gem "rails", "~> 7.0.x"
66

77
gemspec path: "../"

0 commit comments

Comments
 (0)