Skip to content

Commit b729492

Browse files
authored
Update to React on Rails v9 per CHANGELOG (shakacode#416)
See React on Rails Changelog for upgrade instructions.
1 parent 899e618 commit b729492

13 files changed

+134
-99
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ vendor/ruby
2828

2929
# Generated js bundles
3030
/public/webpack/
31+
/public/webpack-test/
3132

3233
# Rubymine/IntelliJ
3334
.idea

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
source "https://rubygems.org"
22
ruby "2.4.1"
33

4-
gem "react_on_rails", "8.0.6.rc.1"
5-
gem "webpacker_lite", "2.1.0"
4+
gem "react_on_rails", "9.0.0.rc.0"
5+
gem "webpacker"
66

77
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
88
gem "listen"
9-
gem "rails", "5.0.3"
9+
gem "rails", "~> 5"
1010

1111
# Note: We're using sqllite3 for development and testing
1212
# gem "sqlite3", group: [:development, :test]

Gemfile.lock

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actioncable (5.0.3)
5-
actionpack (= 5.0.3)
6-
nio4r (>= 1.2, < 3.0)
4+
actioncable (5.1.3)
5+
actionpack (= 5.1.3)
6+
nio4r (~> 2.0)
77
websocket-driver (~> 0.6.1)
8-
actionmailer (5.0.3)
9-
actionpack (= 5.0.3)
10-
actionview (= 5.0.3)
11-
activejob (= 5.0.3)
8+
actionmailer (5.1.3)
9+
actionpack (= 5.1.3)
10+
actionview (= 5.1.3)
11+
activejob (= 5.1.3)
1212
mail (~> 2.5, >= 2.5.4)
1313
rails-dom-testing (~> 2.0)
14-
actionpack (5.0.3)
15-
actionview (= 5.0.3)
16-
activesupport (= 5.0.3)
14+
actionpack (5.1.3)
15+
actionview (= 5.1.3)
16+
activesupport (= 5.1.3)
1717
rack (~> 2.0)
1818
rack-test (~> 0.6.3)
1919
rails-dom-testing (~> 2.0)
2020
rails-html-sanitizer (~> 1.0, >= 1.0.2)
21-
actionview (5.0.3)
22-
activesupport (= 5.0.3)
21+
actionview (5.1.3)
22+
activesupport (= 5.1.3)
2323
builder (~> 3.1)
24-
erubis (~> 2.7.0)
24+
erubi (~> 1.4)
2525
rails-dom-testing (~> 2.0)
2626
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27-
activejob (5.0.3)
28-
activesupport (= 5.0.3)
27+
activejob (5.1.3)
28+
activesupport (= 5.1.3)
2929
globalid (>= 0.3.6)
30-
activemodel (5.0.3)
31-
activesupport (= 5.0.3)
32-
activerecord (5.0.3)
33-
activemodel (= 5.0.3)
34-
activesupport (= 5.0.3)
35-
arel (~> 7.0)
36-
activesupport (5.0.3)
30+
activemodel (5.1.3)
31+
activesupport (= 5.1.3)
32+
activerecord (5.1.3)
33+
activemodel (= 5.1.3)
34+
activesupport (= 5.1.3)
35+
arel (~> 8.0)
36+
activesupport (5.1.3)
3737
concurrent-ruby (~> 1.0, >= 1.0.2)
3838
i18n (~> 0.7)
3939
minitest (~> 5.1)
@@ -42,7 +42,7 @@ GEM
4242
public_suffix (~> 2.0, >= 2.0.2)
4343
archive-zip (0.7.0)
4444
io-like (~> 0.3.0)
45-
arel (7.1.4)
45+
arel (8.0.0)
4646
ast (2.3.0)
4747
autoprefixer-rails (6.7.7.1)
4848
execjs
@@ -95,7 +95,7 @@ GEM
9595
debug_inspector (0.0.2)
9696
diff-lcs (1.3)
9797
docile (1.1.5)
98-
erubis (2.7.0)
98+
erubi (1.6.1)
9999
execjs (2.7.0)
100100
factory_girl (4.8.0)
101101
activesupport (>= 3.0.0)
@@ -135,7 +135,7 @@ GEM
135135
mini_portile2 (2.2.0)
136136
mini_racer (0.1.9)
137137
libv8 (~> 5.3)
138-
minitest (5.10.2)
138+
minitest (5.10.3)
139139
multi_json (1.12.1)
140140
nio4r (2.1.0)
141141
nokogiri (1.8.0)
@@ -169,28 +169,30 @@ GEM
169169
public_suffix (2.0.5)
170170
puma (3.8.2)
171171
rack (2.0.3)
172+
rack-proxy (0.6.2)
173+
rack
172174
rack-test (0.6.3)
173175
rack (>= 1.0)
174-
rails (5.0.3)
175-
actioncable (= 5.0.3)
176-
actionmailer (= 5.0.3)
177-
actionpack (= 5.0.3)
178-
actionview (= 5.0.3)
179-
activejob (= 5.0.3)
180-
activemodel (= 5.0.3)
181-
activerecord (= 5.0.3)
182-
activesupport (= 5.0.3)
183-
bundler (>= 1.3.0, < 2.0)
184-
railties (= 5.0.3)
176+
rails (5.1.3)
177+
actioncable (= 5.1.3)
178+
actionmailer (= 5.1.3)
179+
actionpack (= 5.1.3)
180+
actionview (= 5.1.3)
181+
activejob (= 5.1.3)
182+
activemodel (= 5.1.3)
183+
activerecord (= 5.1.3)
184+
activesupport (= 5.1.3)
185+
bundler (>= 1.3.0)
186+
railties (= 5.1.3)
185187
sprockets-rails (>= 2.0.0)
186188
rails-dom-testing (2.0.3)
187189
activesupport (>= 4.2.0)
188190
nokogiri (>= 1.6)
189191
rails-html-sanitizer (1.0.3)
190192
loofah (~> 2.0)
191-
railties (5.0.3)
192-
actionpack (= 5.0.3)
193-
activesupport (= 5.0.3)
193+
railties (5.1.3)
194+
actionpack (= 5.1.3)
195+
activesupport (= 5.1.3)
194196
method_source
195197
rake (>= 0.8.7)
196198
thor (>= 0.18.1, < 2.0)
@@ -201,7 +203,7 @@ GEM
201203
rb-inotify (0.9.8)
202204
ffi (>= 0.5.0)
203205
rdoc (4.3.0)
204-
react_on_rails (8.0.6.rc.1)
206+
react_on_rails (9.0.0.rc.0)
205207
addressable
206208
connection_pool
207209
execjs (~> 2.5)
@@ -269,7 +271,7 @@ GEM
269271
sprockets (3.7.1)
270272
concurrent-ruby (~> 1.0)
271273
rack (> 1, < 3)
272-
sprockets-rails (3.2.0)
274+
sprockets-rails (3.2.1)
273275
actionpack (>= 4.0)
274276
activesupport (>= 4.0)
275277
sprockets (>= 3.0.0)
@@ -289,9 +291,9 @@ GEM
289291
activemodel (>= 5.0)
290292
bindex (>= 0.4.0)
291293
railties (>= 5.0)
292-
webpacker_lite (2.1.0)
294+
webpacker (3.0.1)
293295
activesupport (>= 4.2)
294-
multi_json (~> 1.2)
296+
rack-proxy (>= 0.6.1)
295297
railties (>= 4.2)
296298
websocket (1.2.4)
297299
websocket-driver (0.6.5)
@@ -332,10 +334,10 @@ DEPENDENCIES
332334
pry-rescue
333335
pry-stack_explorer
334336
puma
335-
rails (= 5.0.3)
337+
rails (~> 5)
336338
rails-html-sanitizer
337339
rainbow
338-
react_on_rails (= 8.0.6.rc.1)
340+
react_on_rails (= 9.0.0.rc.0)
339341
redis
340342
rspec-rails (~> 3.6)
341343
rspec-retry
@@ -349,10 +351,10 @@ DEPENDENCIES
349351
spring-commands-rspec
350352
uglifier
351353
web-console
352-
webpacker_lite (= 2.1.0)
354+
webpacker
353355

354356
RUBY VERSION
355357
ruby 2.4.1p111
356358

357359
BUNDLED WITH
358-
1.15.1
360+
1.15.4

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"react-bootstrap": "^0.31.2",
8484
"react-dom": "^15.6.1",
8585
"react-intl": "^2.3.0",
86-
"react-on-rails": "^8.0.6-rc.1",
86+
"react-on-rails": "^9.0.0-rc.0",
8787
"react-redux": "^5.0.5",
8888
"react-router": "^4.1.2",
8989
"react-router-dom": "^4.1.2",

client/server-rails-hot.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ const { resolve } = require('path');
1111
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
1212

1313
const configPath = resolve('..', 'config');
14-
const { hotReloadingUrl, hotReloadingPort, hotReloadingHostname } = webpackConfigLoader(configPath);
14+
const { output, settings } = webpackConfigLoader(configPath);
15+
16+
const hotReloadingUrl = output.publicPathWithHost;
17+
const hotReloadingPort = settings.dev_server.port;
18+
const hotReloadingHostname = settings.dev_server.host;
1519

1620
const compiler = webpack(webpackConfig);
1721

client/webpack.client.base.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { resolve } = require('path');
88
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
99

1010
const configPath = resolve('..', 'config');
11-
const { manifest } = webpackConfigLoader(configPath);
11+
const { output } = webpackConfigLoader(configPath);
1212

1313
const devBuild = process.env.NODE_ENV !== 'production';
1414

@@ -68,7 +68,7 @@ module.exports = {
6868
},
6969
}),
7070
new ManifestPlugin({
71-
fileName: manifest,
71+
publicPath: output.publicPath,
7272
writeToFileEmit: true
7373
}),
7474
],

client/webpack.client.rails.build.config.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { resolve } = require('path');
1212
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
1313

1414
const configPath = resolve('..', 'config');
15-
const { webpackOutputPath, webpackPublicOutputDir } = webpackConfigLoader(configPath);
15+
const { output } = webpackConfigLoader(configPath);
1616

1717
const devBuild = process.env.NODE_ENV !== 'production';
1818

@@ -34,11 +34,10 @@ module.exports = merge(config, {
3434
},
3535

3636
output: {
37-
filename: '[name]-[hash].js',
38-
39-
// Leading and trailing slashes ARE necessary.
40-
publicPath: `/${webpackPublicOutputDir}/`,
41-
path: webpackOutputPath,
37+
filename: '[name]-[chunkhash].js',
38+
chunkFilename: '[name]-[chunkhash].chunk.js',
39+
publicPath: output.publicPath,
40+
path: output.path,
4241
},
4342

4443
// See webpack.client.base.config for adding modules common to both webpack dev server and rails

client/webpack.client.rails.hot.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const config = require('./webpack.client.base.config');
1313
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
1414

1515
const configPath = resolve('..', 'config');
16-
const { hotReloadingUrl, webpackOutputPath } = webpackConfigLoader(configPath);
16+
const { output } = webpackConfigLoader(configPath);
17+
const hotReloadingUrl = output.publicPathWithHost;
1718

1819
module.exports = merge(config, {
1920
devtool: 'eval-source-map',
@@ -32,8 +33,10 @@ module.exports = merge(config, {
3233
},
3334

3435
output: {
35-
filename: '[name].js',
36-
path: webpackOutputPath,
36+
filename: '[name]-[hash].js',
37+
chunkFilename: '[name]-[chunkhash].chunk.js',
38+
publicPath: output.publicPath,
39+
path: output.path,
3740
},
3841

3942
module: {

client/webpack.server.rails.build.config.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const webpack = require('webpack');
1010
const webpackConfigLoader = require('react-on-rails/webpackConfigLoader');
1111

1212
const configPath = resolve('..', 'config');
13-
const { webpackOutputPath, webpackPublicOutputDir } = webpackConfigLoader(configPath);
13+
const { output } = webpackConfigLoader(configPath);
1414

1515
const devBuild = process.env.NODE_ENV !== 'production';
1616

@@ -29,9 +29,8 @@ module.exports = {
2929
// since it's not cached by the browsers.
3030
filename: 'server-bundle.js',
3131

32-
// Leading and trailing slashes ARE necessary.
33-
publicPath: `/${webpackPublicOutputDir}/`,
34-
path: webpackOutputPath,
32+
publicPath: output.publicPath,
33+
path: output.path,
3534
},
3635
resolve: {
3736
extensions: ['.js', '.jsx'],

client/yarn.lock

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,10 @@ hoist-non-react-statics@^1.0.3, hoist-non-react-statics@^1.2.0:
26802680
version "1.2.0"
26812681
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"
26822682

2683+
hoist-non-react-statics@^2.2.1:
2684+
version "2.3.1"
2685+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.1.tgz#343db84c6018c650778898240135a1420ee22ce0"
2686+
26832687
home-or-tmp@^2.0.0:
26842688
version "2.0.0"
26852689
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
@@ -4680,9 +4684,12 @@ react-intl@^2.3.0:
46804684
intl-relativeformat "^1.3.0"
46814685
invariant "^2.1.1"
46824686

4683-
react-on-rails@^8.0.6-rc.1:
4684-
version "8.0.6-rc.1"
4685-
resolved "https://registry.yarnpkg.com/react-on-rails/-/react-on-rails-8.0.6-rc.1.tgz#6326e2b431351f9a9976bbf6a59b5e5b2fabd91d"
4687+
react-on-rails@^9.0.0-beta.12, react-on-rails@^9.0.0-rc.0:
4688+
version "9.0.0-rc.0"
4689+
resolved "https://registry.yarnpkg.com/react-on-rails/-/react-on-rails-9.0.0-rc.0.tgz#5b62bfe1f5cf99c428b0daa02de492a66c33c58e"
4690+
dependencies:
4691+
react-on-rails "^9.0.0-beta.12"
4692+
react-redux "^5.0.6"
46864693

46874694
react-overlays@^0.7.0:
46884695
version "0.7.0"
@@ -4719,6 +4726,17 @@ react-redux@^5.0.5:
47194726
loose-envify "^1.1.0"
47204727
prop-types "^15.5.10"
47214728

4729+
react-redux@^5.0.6:
4730+
version "5.0.6"
4731+
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.6.tgz#23ed3a4f986359d68b5212eaaa681e60d6574946"
4732+
dependencies:
4733+
hoist-non-react-statics "^2.2.1"
4734+
invariant "^2.0.0"
4735+
lodash "^4.2.0"
4736+
lodash-es "^4.2.0"
4737+
loose-envify "^1.1.0"
4738+
prop-types "^15.5.10"
4739+
47224740
react-router-dom@^4.1.2:
47234741
version "4.1.2"
47244742
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.1.2.tgz#7f8a7ca868d32acadd19ca09543b40d26df8ec37"

config/initializers/react_on_rails.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Shown below are the defaults for configuration
22
ReactOnRails.configure do |config|
3+
config.node_modules_location = "client"
4+
35
# Directory where your generated assets go. All generated assets must go to the same directory.
46
# Configure this in your webpack config files. This relative to your Rails root directory.
57
config.generated_assets_dir = File.join(%w[public webpack], Rails.env)
@@ -17,11 +19,11 @@
1719
# If you are using the ReactOnRails::TestHelper.configure_rspec_to_compile_assets(config)
1820
# with rspec then this controls what npm command is run
1921
# to automatically refresh your webpack assets on every test run.
20-
config.npm_build_test_command = "yarn run build:test"
22+
config.build_test_command = "yarn run build:test"
2123

2224
# This configures the script to run to build the production assets by webpack. Set this to nil
2325
# if you don't want react_on_rails building this file for you.
24-
config.npm_build_production_command = "yarn run build:production"
26+
config.build_production_command = "yarn run build:production"
2527

2628
################################################################################
2729
# CLIENT RENDERING OPTIONS

0 commit comments

Comments
 (0)