Skip to content

Commit a863bb9

Browse files
justin808claude
andcommitted
Update to Shakapacker 9.0.0.beta.7 with CSS modules fix
- Update shakapacker gem to 9.0.0.beta.7 - Update shakapacker npm package to 9.0.0-beta.7 - Fix css-loader configuration for CSS modules compatibility - Beta.7 enables namedExport by default, which requires exportLocalsConvention to be 'camelCaseOnly' or 'dashesOnly' - Added configuration to automatically set exportLocalsConvention when namedExport is enabled This resolves the CI build error: "The modules.namedExport option requires the modules.exportLocalsConvention option to be camelCaseOnly or dashesOnly" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ce2ad19 commit a863bb9

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
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.4"
9+
gem "shakapacker", "9.0.0.beta.7"
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.4)
393+
shakapacker (9.0.0.beta.7)
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.4)
502+
shakapacker (= 9.0.0.beta.7)
503503
spring
504504
spring-commands-rspec
505505
stimulus-rails (~> 1.3)

config/webpack/commonWebpackConfig.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,25 @@ if (sassLoaderIndex !== -1) {
5454
}
5555
}
5656

57+
// Fix css-loader configuration for CSS modules
58+
// When namedExport is true, exportLocalsConvention must be camelCaseOnly or dashesOnly
59+
const cssLoaderIndex = scssRule.use.findIndex((loader) => {
60+
if (typeof loader === 'string') {
61+
return loader.includes('css-loader');
62+
}
63+
return loader.loader && loader.loader.includes('css-loader');
64+
});
65+
66+
if (cssLoaderIndex !== -1) {
67+
const cssLoader = scssRule.use[cssLoaderIndex];
68+
if (typeof cssLoader === 'object' && cssLoader.options && cssLoader.options.modules) {
69+
// If namedExport is enabled, ensure exportLocalsConvention is properly set
70+
if (cssLoader.options.modules.namedExport) {
71+
cssLoader.options.modules.exportLocalsConvention = 'camelCaseOnly';
72+
}
73+
}
74+
}
75+
5776
baseClientWebpackConfig.module.rules[scssConfigIndex].use.push(sassLoaderConfig);
5877

5978
// Copy the object using merge b/c the baseClientWebpackConfig and commonOptions are mutable globals

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.4",
96+
"shakapacker": "9.0.0-beta.7",
9797
"stimulus": "^3.0.1",
9898
"style-loader": "^3.3.1",
9999
"tailwindcss": "^3.3.3",

yarn.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8263,13 +8263,14 @@ 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.4:
8267-
version "9.0.0-beta.4"
8268-
resolved "https://registry.npmjs.org/shakapacker/-/shakapacker-9.0.0-beta.4.tgz#10b4caf90bf7cb65febc9cb1b3345154f1e2945c"
8269-
integrity sha512-sO4s4umQrhXCUVZPOmuq6yVdOc8psrDboQTXDVkSI32YA7AmDgFTUMOxYBkiZdSgQb2zhgUrpQQ8XTDAC2J3lg==
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==
82708270
dependencies:
82718271
js-yaml "^4.1.0"
82728272
path-complete-extname "^1.0.0"
8273+
webpack-merge "^5.8.0"
82738274

82748275
shallow-clone@^3.0.0:
82758276
version "3.0.1"
@@ -9204,7 +9205,7 @@ webpack-dev-server@^4.11.1:
92049205
webpack-dev-middleware "^5.3.4"
92059206
ws "^8.13.0"
92069207

9207-
webpack-merge@5, webpack-merge@^5.7.3:
9208+
webpack-merge@5, webpack-merge@^5.7.3, webpack-merge@^5.8.0:
92089209
version "5.10.0"
92099210
resolved "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177"
92109211
integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==

0 commit comments

Comments
 (0)