Skip to content

Commit dca37ba

Browse files
authored
Upgrade to shakapacker 7 (#527)
* Upgrade to Shakapacker 7.0.0.rc.0 * Use shakapacker binstubs * Rename to shakapacker.yml and some of its entries * Rename spelling in other parts of the project * Update webpackConfig with new Shakapacker interface * Upgrade Shakapacker to 7.0.0.rc.1 * Upgrade shakapacker to 7.0.0
1 parent 7c3bcf8 commit dca37ba

17 files changed

+56
-60
lines changed

Diff for: .github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ jobs:
6565
- name: Build i18n libraries
6666
run: bundle exec rake react_on_rails:locale
6767

68-
- name: Build webpacker chunks
69-
run: NODE_ENV=development bundle exec bin/webpacker
68+
- name: Build shakapacker chunks
69+
run: NODE_ENV=development bundle exec bin/shakapacker
7070

7171
- name: Run tests with xvfb
7272
uses: GabrielBB/xvfb-action@v1

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ruby "3.1.2"
77

88
gem "cpl", "~> 0.3.3"
99
gem "react_on_rails", "13.2.0"
10-
gem "shakapacker", "6.5.5"
10+
gem "shakapacker", "7.0.0"
1111

1212
# Bundle edge Rails instead: gem "rails", github: "rails/rails"
1313
gem "listen"

Diff for: Gemfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ GEM
332332
websocket (~> 1.0)
333333
semantic_range (3.0.0)
334334
sexp_processor (4.16.1)
335-
shakapacker (6.5.5)
335+
shakapacker (7.0.0)
336336
activesupport (>= 5.2)
337337
rack-proxy (>= 0.6.1)
338338
railties (>= 5.2)
@@ -432,7 +432,7 @@ DEPENDENCIES
432432
scss_lint
433433
sdoc
434434
selenium-webdriver (~> 4)
435-
shakapacker (= 6.5.5)
435+
shakapacker (= 7.0.0)
436436
spring
437437
spring-commands-rspec
438438
uglifier

Diff for: Procfile.dev

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# You can run these commands in separate shells
33
redis: redis-server
44
rails: bundle exec rails s -p 3000
5-
wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/webpacker-dev-server
6-
wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/webpacker --watch
5+
wp-client: HMR=true RAILS_ENV=development NODE_ENV=development bin/shakapacker-dev-server
6+
wp-server: bundle exec rake react_on_rails:locale && HMR=true SERVER_BUNDLE_ONLY=yes bin/shakapacker --watch

Diff for: Procfile.dev-static

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ redis: redis-server
66
# When making frequent changes to client side assets, you will prefer building webpack assets
77
# upon saving rather than when you refresh your browser page.
88
# Note, if using React on Rails localization you will need to run
9-
# `bundle exec rake react_on_rails:locale` before you run bin/webpacker
10-
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/webpacker -w'
9+
# `bundle exec rake react_on_rails:locale` before you run bin/shakapacker
10+
webpack: sh -c 'bundle exec rake react_on_rails:locale && rm -rf public/packs/* || true && bin/shakapacker -w'

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ line in the `rails_helper.rb` file. If you are using this project as an example
173173
174174
## Webpack
175175
176-
_Converted to use @rails/webpacker webpack configuration_.
176+
_Converted to use Shakapacker webpack configuration_.
177177
178178
179179
### Additional Resources

Diff for: bin/shakapacker

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
3+
ENV["RAILS_ENV"] ||= "development"
4+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
5+
6+
require "bundler/setup"
7+
require "shakapacker"
8+
require "shakapacker/webpack_runner"
9+
10+
APP_ROOT = File.expand_path("..", __dir__)
11+
Dir.chdir(APP_ROOT) do
12+
Shakapacker::WebpackRunner.run(ARGV)
13+
end

Diff for: bin/shakapacker-dev-server

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
3+
ENV["RAILS_ENV"] ||= "development"
4+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
5+
6+
require "bundler/setup"
7+
require "shakapacker"
8+
require "shakapacker/dev_server_runner"
9+
10+
APP_ROOT = File.expand_path("..", __dir__)
11+
Dir.chdir(APP_ROOT) do
12+
Shakapacker::DevServerRunner.run(ARGV)
13+
end

Diff for: bin/webpacker

-15
This file was deleted.

Diff for: bin/webpacker-dev-server

-18
This file was deleted.

Diff for: config/initializers/react_on_rails.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# Define the files for we need to check for webpack compilation when running tests
66
config.webpack_generated_files = %w[client-bundle.js server-bundle.js]
77

8-
config.build_test_command = "RAILS_ENV=test bin/webpacker"
9-
config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/webpacker"
8+
config.build_test_command = "RAILS_ENV=test bin/shakapacker"
9+
config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker"
1010

1111
# This is the file used for server rendering of React when using `(prerender: true)`
1212
# If you are never using server rendering, you may set this to "".

Diff for: config/webpacker.yml renamed to config/shakapacker.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# Note: You must restart bin/webpacker-dev-server for changes to take effect
1+
# Note: You must restart bin/shakapacker-dev-server for changes to take effect
22

33
default: &default
44
source_path: client/app
55
source_entry_path: packs
66
public_root_path: public
77
public_output_path: packs
8-
cache_path: tmp/webpacker
8+
cache_path: tmp/shakapacker
99
webpack_compile_output: true
1010

1111
# Additional paths webpack should lookup modules
@@ -16,11 +16,11 @@ default: &default
1616
cache_manifest: false
1717

1818
# Use the config.build_production_command in config/initializers/react_on_rails.rb
19-
webpacker_precompile: false
19+
shakapacker_precompile: false
2020

2121
development:
2222
<<: *default
23-
# This is false since we're running `bin/webpacker -w` in Procfile.dev-setic
23+
# This is false since we're running `bin/shakapacker -w` in Procfile.dev-setic
2424
compile: false
2525

2626
# Reference: https://webpack.js.org/configuration/dev-server/

Diff for: config/webpack/DEBUGGING.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
# https://github.com/rails/webpacker/pull/2018
44

55
To debug:
6-
bin/webpacker --debug-webpakcer
6+
```sh
7+
bin/shakapacker --debug-shakapacker
8+
```
79

810
And put a debugger statement in the file you're editing.
911

1012
Here's how to configure the customizations:
1113

12-
[Webpack Customization](https://github.com/rails/webpacker/blob/master/docs/webpack.md)
14+
[Webpack Configuration](https://github.com/shakacode/shakapacker#webpack-configuration)

Diff for: config/webpack/commonWebpackConfig.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/commonWebpackConfig.js
33

44
// Common configuration applying to client and server configuration
5-
const { webpackConfig: baseClientWebpackConfig, merge } = require('shakapacker');
5+
const { generateWebpackConfig, merge } = require('shakapacker');
66

7+
const baseClientWebpackConfig = generateWebpackConfig();
78
const commonOptions = {
89
resolve: {
910
extensions: ['.css', '.ts', '.tsx'],

Diff for: config/webpack/server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const webpack = require('webpack');
55

66
const environment = require('./environment');
77

8-
// React Server Side Rendering webpacker config
8+
// React Server Side Rendering shakapacker config
99
// Builds a Node compatible file that React on Rails can load, never served to the client.
1010

1111
environment.plugins.insert(

Diff for: package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"lint": " yarn lint:eslint --fix && yarn lint:prettier --w",
2323
"test": "yarn build:test && yarn lint",
2424
"test:client": "cd client && yarn test",
25-
"build:test": "rm -rf public/webpack/test && RAILS_ENV=test NODE_ENV=test bin/webpacker",
26-
"build:dev": "rm -rf public/webpack/development && RAILS_ENV=development NODE_ENV=development bin/webpacker",
25+
"build:test": "rm -rf public/webpack/test && RAILS_ENV=test NODE_ENV=test bin/shakapacker",
26+
"build:dev": "rm -rf public/webpack/development && RAILS_ENV=development NODE_ENV=development bin/shakapacker",
2727
"build:clean": "rm -rf public/webpack || true"
2828
},
2929
"dependencies": {
@@ -80,7 +80,7 @@
8080
"sass": "^1.58.3",
8181
"sass-loader": "^12.6.0",
8282
"sass-resources-loader": "^2.2.5",
83-
"shakapacker": "6.5.5",
83+
"shakapacker": "7.0.0",
8484
"style-loader": "^3.3.1",
8585
"terser-webpack-plugin": "5",
8686
"turbolinks": "^5.2.0",

Diff for: yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -8861,10 +8861,10 @@ sha.js@^2.4.0, sha.js@^2.4.8:
88618861
inherits "^2.0.1"
88628862
safe-buffer "^5.0.1"
88638863

8864-
shakapacker@6.5.5:
8865-
version "6.5.5"
8866-
resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-6.5.5.tgz#34c027b3d3b34b8241a946d4af256df81c0c04f7"
8867-
integrity sha512-KsDhjihjmkJVpdnuDvHj70RzRjreXcnMQtePp+TkHzi4sXO8gwt0btoTNrwuLrgxOfac7UQadDFYFGzJwoPz5w==
8864+
shakapacker@7.0.0:
8865+
version "7.0.0"
8866+
resolved "https://registry.yarnpkg.com/shakapacker/-/shakapacker-7.0.0.tgz#788c96e86eb78e44ee84c3cc03b7c091e4621fc3"
8867+
integrity sha512-yL5lbCdgtI8nUxZHarL7X5aB40r069wAunHwb59Hgw1gPg6/nMuYo7ofNTGXg11v1eunwAdjx8EfYnk4XwX27Q==
88688868
dependencies:
88698869
glob "^7.2.0"
88708870
js-yaml "^4.1.0"

0 commit comments

Comments
 (0)