Skip to content

Commit 2d00493

Browse files
justin808claude
andcommitted
Migrate to Shakapacker 9.0.0-beta.8
Updates Shakapacker from beta.7 to beta.8. The main change required was fixing the webpack config to properly detect SCSS rules, as the rule structure changed in beta.8 to include a new oneOf pattern at index 0. Changes: - Update Shakapacker version in Gemfile and package.json - Fix commonWebpackConfig.js to find SCSS rules that have a 'use' array - Add null safety checks for scssRule properties 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 8f7bb45 commit 2d00493

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
66
ruby "3.3.4"
77

88
gem "react_on_rails", "16.1.1"
9-
gem "shakapacker", "9.0.0.beta.7"
9+
gem "shakapacker", "9.0.0.beta.8"
1010

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

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ GEM
390390
websocket (~> 1.0)
391391
semantic_range (3.1.0)
392392
sexp_processor (4.17.1)
393-
shakapacker (9.0.0.beta.7)
393+
shakapacker (9.0.0.beta.8)
394394
activesupport (>= 5.2)
395395
package_json
396396
rack-proxy (>= 0.6.1)
@@ -499,7 +499,7 @@ DEPENDENCIES
499499
scss_lint
500500
sdoc
501501
selenium-webdriver (~> 4)
502-
shakapacker (= 9.0.0.beta.7)
502+
shakapacker (= 9.0.0.beta.8)
503503
spring
504504
spring-commands-rspec
505505
stimulus-rails (~> 1.3)

config/webpack/commonWebpackConfig.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ const ignoreWarningsConfig = {
2424
};
2525

2626
const scssConfigIndex = baseClientWebpackConfig.module.rules.findIndex((config) =>
27-
'.scss'.match(config.test),
27+
'.scss'.match(config.test) && config.use,
2828
);
2929

3030
// Configure sass-loader to use the modern API
3131
const scssRule = baseClientWebpackConfig.module.rules[scssConfigIndex];
32-
const sassLoaderIndex = scssRule.use.findIndex((loader) => {
32+
const sassLoaderIndex = scssRule?.use?.findIndex((loader) => {
3333
if (typeof loader === 'string') {
3434
return loader.includes('sass-loader');
3535
}
3636
return loader.loader && loader.loader.includes('sass-loader');
3737
});
3838

39-
if (sassLoaderIndex !== -1) {
39+
if (sassLoaderIndex !== -1 && sassLoaderIndex !== undefined) {
4040
const sassLoader = scssRule.use[sassLoaderIndex];
4141
if (typeof sassLoader === 'string') {
4242
scssRule.use[sassLoaderIndex] = {
@@ -53,7 +53,7 @@ if (sassLoaderIndex !== -1) {
5353

5454
// Fix css-loader configuration for CSS modules if namedExport is enabled
5555
// When namedExport is true, exportLocalsConvention must be camelCaseOnly or dashesOnly
56-
const cssLoader = scssRule.use.find(loader => {
56+
const cssLoader = scssRule?.use?.find(loader => {
5757
const loaderName = typeof loader === 'string' ? loader : loader?.loader;
5858
return loaderName?.includes('css-loader');
5959
});
@@ -62,7 +62,9 @@ if (cssLoader?.options?.modules?.namedExport) {
6262
cssLoader.options.modules.exportLocalsConvention = 'camelCaseOnly';
6363
}
6464

65-
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
65+
if (scssRule?.use) {
66+
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
67+
}
6668

6769
// Copy the object using merge b/c the baseClientWebpackConfig and commonOptions are mutable globals
6870
const commonWebpackConfig = () => merge({}, baseClientWebpackConfig, commonOptions, ignoreWarningsConfig);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"sass": "^1.58.3",
9494
"sass-loader": "^13.3.2",
9595
"sass-resources-loader": "^2.2.5",
96-
"shakapacker": "9.0.0-beta.7",
96+
"shakapacker": "9.0.0-beta.8",
9797
"stimulus": "^3.0.1",
9898
"style-loader": "^3.3.1",
9999
"tailwindcss": "^3.3.3",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8263,10 +8263,10 @@ setprototypeof@1.2.0:
82638263
resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424"
82648264
integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==
82658265

8266-
shakapacker@9.0.0-beta.7:
8267-
version "9.0.0-beta.7"
8268-
resolved "https://registry.npmjs.org/shakapacker/-/shakapacker-9.0.0-beta.7.tgz#c00b9590b84f365bf0fd4e7b7efdd59104901a00"
8269-
integrity sha512-m4xGyTg9yy4ys+wz44jBdygsxwKDbARBlgYqsyirwowQKWZHqnyb+ucS9yz5cKQHUtHeDlJOhPHKhRsCwhJcDQ==
8266+
shakapacker@9.0.0-beta.8:
8267+
version "9.0.0-beta.8"
8268+
resolved "https://registry.npmjs.org/shakapacker/-/shakapacker-9.0.0-beta.8.tgz#ab951f8ab575d1c178639c2048a296ae27c9a467"
8269+
integrity sha512-NPu5cTB6lL/Bzl8XDl1NfjlljLARWPH9YhjIh1CvXEuSdaNP2qJLSiIr68Bqv3IGHQmqtifgRl1iXQB8pNnAfQ==
82708270
dependencies:
82718271
js-yaml "^4.1.0"
82728272
path-complete-extname "^1.0.0"

0 commit comments

Comments
 (0)