shakapacker 8.4.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintignore +1 -0
  3. data/.eslintrc.fast.js +40 -0
  4. data/.eslintrc.js +48 -0
  5. data/.github/STATUS.md +1 -0
  6. data/.github/workflows/claude-code-review.yml +54 -0
  7. data/.github/workflows/claude.yml +50 -0
  8. data/.github/workflows/dummy.yml +8 -4
  9. data/.github/workflows/generator.yml +17 -14
  10. data/.github/workflows/node.yml +23 -1
  11. data/.github/workflows/ruby.yml +11 -0
  12. data/.github/workflows/test-bundlers.yml +170 -0
  13. data/.gitignore +17 -0
  14. data/.husky/pre-commit +2 -0
  15. data/.npmignore +56 -0
  16. data/.prettierignore +3 -0
  17. data/.rubocop.yml +1 -0
  18. data/.yalcignore +26 -0
  19. data/CHANGELOG.md +156 -18
  20. data/CLAUDE.md +29 -0
  21. data/CONTRIBUTING.md +138 -20
  22. data/Gemfile.lock +3 -3
  23. data/README.md +130 -5
  24. data/Rakefile +39 -4
  25. data/TODO.md +50 -0
  26. data/TODO_v9.md +87 -0
  27. data/conductor-setup.sh +70 -0
  28. data/conductor.json +7 -0
  29. data/docs/cdn_setup.md +379 -0
  30. data/docs/css-modules-export-mode.md +512 -0
  31. data/docs/deployment.md +10 -1
  32. data/docs/optional-peer-dependencies.md +198 -0
  33. data/docs/peer-dependencies.md +60 -0
  34. data/docs/rspack.md +190 -0
  35. data/docs/rspack_migration_guide.md +202 -0
  36. data/docs/transpiler-migration.md +188 -0
  37. data/docs/transpiler-performance.md +179 -0
  38. data/docs/troubleshooting.md +5 -0
  39. data/docs/typescript-migration.md +378 -0
  40. data/docs/typescript.md +99 -0
  41. data/docs/using_esbuild_loader.md +3 -3
  42. data/docs/using_swc_loader.md +5 -3
  43. data/docs/v6_upgrade.md +10 -0
  44. data/docs/v9_upgrade.md +413 -0
  45. data/lib/install/bin/shakapacker +3 -5
  46. data/lib/install/config/rspack/rspack.config.js +6 -0
  47. data/lib/install/config/rspack/rspack.config.ts +7 -0
  48. data/lib/install/config/shakapacker.yml +12 -2
  49. data/lib/install/config/webpack/webpack.config.ts +7 -0
  50. data/lib/install/package.json +38 -0
  51. data/lib/install/template.rb +194 -44
  52. data/lib/shakapacker/configuration.rb +141 -0
  53. data/lib/shakapacker/dev_server_runner.rb +25 -5
  54. data/lib/shakapacker/doctor.rb +844 -0
  55. data/lib/shakapacker/manifest.rb +4 -2
  56. data/lib/shakapacker/rspack_runner.rb +19 -0
  57. data/lib/shakapacker/runner.rb +144 -4
  58. data/lib/shakapacker/swc_migrator.rb +376 -0
  59. data/lib/shakapacker/utils/manager.rb +2 -0
  60. data/lib/shakapacker/version.rb +1 -1
  61. data/lib/shakapacker/version_checker.rb +1 -1
  62. data/lib/shakapacker/webpack_runner.rb +4 -42
  63. data/lib/shakapacker.rb +2 -1
  64. data/lib/tasks/shakapacker/doctor.rake +8 -0
  65. data/lib/tasks/shakapacker/install.rake +12 -2
  66. data/lib/tasks/shakapacker/migrate_to_swc.rake +13 -0
  67. data/lib/tasks/shakapacker.rake +1 -0
  68. data/package/.npmignore +4 -0
  69. data/package/babel/preset.ts +56 -0
  70. data/package/config.ts +175 -0
  71. data/package/{dev_server.js → dev_server.ts} +8 -5
  72. data/package/env.ts +92 -0
  73. data/package/environments/base.ts +138 -0
  74. data/package/environments/development.ts +90 -0
  75. data/package/environments/production.ts +80 -0
  76. data/package/environments/test.ts +53 -0
  77. data/package/environments/types.ts +90 -0
  78. data/package/esbuild/index.ts +42 -0
  79. data/package/index.d.ts +3 -97
  80. data/package/index.ts +52 -0
  81. data/package/loaders.d.ts +28 -0
  82. data/package/optimization/rspack.ts +36 -0
  83. data/package/optimization/webpack.ts +57 -0
  84. data/package/plugins/rspack.ts +103 -0
  85. data/package/plugins/webpack.ts +62 -0
  86. data/package/rspack/index.ts +64 -0
  87. data/package/rules/{babel.js → babel.ts} +2 -2
  88. data/package/rules/{coffee.js → coffee.ts} +1 -1
  89. data/package/rules/css.ts +3 -0
  90. data/package/rules/{erb.js → erb.ts} +1 -1
  91. data/package/rules/esbuild.ts +10 -0
  92. data/package/rules/file.ts +40 -0
  93. data/package/rules/{jscommon.js → jscommon.ts} +4 -4
  94. data/package/rules/{less.js → less.ts} +4 -4
  95. data/package/rules/raw.ts +25 -0
  96. data/package/rules/rspack.ts +176 -0
  97. data/package/rules/{sass.js → sass.ts} +7 -3
  98. data/package/rules/{stylus.js → stylus.ts} +4 -8
  99. data/package/rules/swc.ts +10 -0
  100. data/package/rules/{index.js → webpack.ts} +1 -1
  101. data/package/swc/index.ts +54 -0
  102. data/package/types/README.md +87 -0
  103. data/package/types/index.ts +60 -0
  104. data/package/types.ts +108 -0
  105. data/package/utils/configPath.ts +6 -0
  106. data/package/utils/debug.ts +49 -0
  107. data/package/utils/defaultConfigPath.ts +4 -0
  108. data/package/utils/errorCodes.ts +219 -0
  109. data/package/utils/errorHelpers.ts +143 -0
  110. data/package/utils/getStyleRule.ts +64 -0
  111. data/package/utils/helpers.ts +85 -0
  112. data/package/utils/{inliningCss.js → inliningCss.ts} +3 -3
  113. data/package/utils/pathValidation.ts +139 -0
  114. data/package/utils/requireOrError.ts +15 -0
  115. data/package/utils/snakeToCamelCase.ts +5 -0
  116. data/package/utils/typeGuards.ts +342 -0
  117. data/package/utils/validateDependencies.ts +61 -0
  118. data/package/webpack-types.d.ts +33 -0
  119. data/package/webpackDevServerConfig.ts +117 -0
  120. data/package.json +134 -9
  121. data/scripts/remove-use-strict.js +45 -0
  122. data/scripts/type-check-no-emit.js +27 -0
  123. data/test/package/config.test.js +3 -0
  124. data/test/package/env.test.js +42 -7
  125. data/test/package/environments/base.test.js +5 -1
  126. data/test/package/rules/babel.test.js +16 -0
  127. data/test/package/rules/esbuild.test.js +1 -1
  128. data/test/package/rules/raw.test.js +40 -7
  129. data/test/package/rules/swc.test.js +1 -1
  130. data/test/package/rules/webpack.test.js +35 -0
  131. data/test/package/staging.test.js +4 -3
  132. data/test/package/transpiler-defaults.test.js +127 -0
  133. data/test/peer-dependencies.sh +85 -0
  134. data/test/scripts/remove-use-strict.test.js +125 -0
  135. data/test/typescript/build.test.js +118 -0
  136. data/test/typescript/environments.test.js +107 -0
  137. data/test/typescript/pathValidation.test.js +142 -0
  138. data/test/typescript/securityValidation.test.js +182 -0
  139. data/tools/README.md +124 -0
  140. data/tools/css-modules-v9-codemod.js +179 -0
  141. data/tsconfig.eslint.json +16 -0
  142. data/tsconfig.json +38 -0
  143. data/yarn.lock +2704 -767
  144. metadata +111 -41
  145. data/package/babel/preset.js +0 -48
  146. data/package/config.js +0 -56
  147. data/package/env.js +0 -48
  148. data/package/environments/base.js +0 -171
  149. data/package/environments/development.js +0 -13
  150. data/package/environments/production.js +0 -88
  151. data/package/environments/test.js +0 -3
  152. data/package/esbuild/index.js +0 -40
  153. data/package/index.js +0 -40
  154. data/package/rules/css.js +0 -3
  155. data/package/rules/esbuild.js +0 -10
  156. data/package/rules/file.js +0 -29
  157. data/package/rules/raw.js +0 -5
  158. data/package/rules/swc.js +0 -10
  159. data/package/swc/index.js +0 -50
  160. data/package/utils/configPath.js +0 -4
  161. data/package/utils/defaultConfigPath.js +0 -2
  162. data/package/utils/getStyleRule.js +0 -40
  163. data/package/utils/helpers.js +0 -62
  164. data/package/utils/snakeToCamelCase.js +0 -5
  165. data/package/webpackDevServerConfig.js +0 -71
  166. data/test/package/rules/index.test.js +0 -16
@@ -0,0 +1,413 @@
1
+ # Shakapacker v9 Upgrade Guide
2
+
3
+ This guide outlines new features, breaking changes, and migration steps for upgrading from Shakapacker v8 to v9.
4
+
5
+ ## New Features
6
+
7
+ ### TypeScript Support
8
+
9
+ Shakapacker v9 includes TypeScript definitions for better IDE support and type safety.
10
+
11
+ - **No breaking changes** - JavaScript configs continue to work
12
+ - **Optional** - Use TypeScript only if you want it
13
+ - **Type safety** - Catch configuration errors at compile-time
14
+ - **IDE support** - Full autocomplete for all options
15
+
16
+ See the [TypeScript Documentation](./typescript.md) for usage examples.
17
+
18
+ ### NODE_ENV Default Behavior Fixed
19
+
20
+ **What changed:** NODE_ENV now intelligently defaults based on RAILS_ENV instead of always defaulting to "production".
21
+
22
+ **New behavior:**
23
+
24
+ - When `RAILS_ENV=production` → `NODE_ENV` defaults to `"production"`
25
+ - When `RAILS_ENV=development` or unset → `NODE_ENV` defaults to `"development"`
26
+ - When `RAILS_ENV` is any other value (test, staging, etc.) → `NODE_ENV` defaults to `"development"`
27
+
28
+ **Benefits:**
29
+
30
+ - **Dev server "just works"** - No need to explicitly set NODE_ENV when running the development server
31
+ - **Correct configuration loaded** - Development server now properly loads the development configuration from shakapacker.yml
32
+ - **Fixes port issues** - Dev server uses the configured port (e.g., 3035) instead of defaulting to 8080
33
+ - **Fixes 404 errors** - Assets load correctly without requiring manual NODE_ENV configuration
34
+
35
+ **No action required** - This change improves the default behavior and requires no migration.
36
+
37
+ **If you previously worked around this bug**, you can now remove these workarounds:
38
+
39
+ - Remove `NODE_ENV=development` from your `.env`, `.env.development`, or `.env.local` files
40
+ - Remove `NODE_ENV=development` from your `docker-compose.yml` or Dockerfile
41
+ - Remove custom scripts that set NODE_ENV before running the dev server
42
+ - Remove `NODE_ENV=development` from your `bin/dev` or Procfile.dev
43
+
44
+ ## Breaking Changes
45
+
46
+ ### 1. CSS Modules Configuration Changed to Named Exports
47
+
48
+ **What changed:** CSS Modules are now configured with `namedExport: true` and `exportLocalsConvention: 'camelCaseOnly'` by default, aligning with Next.js and modern tooling standards.
49
+
50
+ > **Important:** When `namedExport: true` is enabled, css-loader requires `exportLocalsConvention` to be either `'camelCaseOnly'` or `'dashesOnly'`. Using `'camelCase'` will cause a build error: `"exportLocalsConvention" with "camelCase" value is incompatible with "namedExport: true" option`.
51
+
52
+ **Quick Reference: Configuration Options**
53
+
54
+ | Configuration | namedExport | exportLocalsConvention | CSS: `.my-button` | Export Available | Works With |
55
+ | --------------- | ----------- | ---------------------- | ----------------- | --------------------------------- | ----------------- |
56
+ | **v9 Default** | `true` | `'camelCaseOnly'` | `.my-button` | `myButton` only | ✅ Named exports |
57
+ | **Alternative** | `true` | `'dashesOnly'` | `.my-button` | `'my-button'` only | ✅ Named exports |
58
+ | **v8 Style** | `false` | `'camelCase'` | `.my-button` | Both `myButton` AND `'my-button'` | ✅ Default export |
59
+ | **❌ Invalid** | `true` | `'camelCase'` | - | - | ❌ Build Error |
60
+
61
+ **JavaScript Projects:**
62
+
63
+ ```js
64
+ // Before (v8)
65
+ import styles from "./Component.module.css"
66
+ ;<button className={styles.button} />
67
+
68
+ // After (v9)
69
+ import { button } from "./Component.module.css"
70
+ ;<button className={button} />
71
+ ```
72
+
73
+ **TypeScript Projects:**
74
+
75
+ ```typescript
76
+ // Before (v8)
77
+ import styles from './Component.module.css';
78
+ <button className={styles.button} />
79
+
80
+ // After (v9) - namespace import due to TypeScript limitations
81
+ import * as styles from './Component.module.css';
82
+ <button className={styles.button} />
83
+ ```
84
+
85
+ **Migration Options:**
86
+
87
+ 1. **Update your code** (Recommended):
88
+
89
+ - JavaScript: Change to named imports (`import { className }`)
90
+ - TypeScript: Change to namespace imports (`import * as styles`)
91
+ - Kebab-case class names are automatically converted to camelCase
92
+
93
+ 2. **Keep v8 behavior** temporarily:
94
+ - Override the css-loader configuration as shown in [CSS Modules Export Mode documentation](./css-modules-export-mode.md)
95
+ - This gives you time to migrate gradually
96
+
97
+ **Benefits of the change:**
98
+
99
+ - Eliminates webpack/TypeScript warnings
100
+ - Better tree-shaking of unused CSS classes
101
+ - More explicit about which classes are used
102
+ - Aligns with modern JavaScript standards
103
+
104
+ ### 2. Configuration Option Renamed: `webpack_loader` → `javascript_transpiler`
105
+
106
+ **What changed:** The configuration option has been renamed to better reflect its purpose.
107
+
108
+ **Before (v8):**
109
+
110
+ ```yml
111
+ # config/shakapacker.yml
112
+ webpack_loader: "babel"
113
+ ```
114
+
115
+ **After (v9):**
116
+
117
+ ```yml
118
+ # config/shakapacker.yml
119
+ javascript_transpiler: "babel"
120
+ ```
121
+
122
+ **Note:** The old `webpack_loader` option is deprecated but still supported with a warning.
123
+
124
+ ### 3. SWC is Now the Default JavaScript Transpiler
125
+
126
+ **What changed:** SWC replaces Babel as the default JavaScript transpiler. Babel is no longer included in peer dependencies.
127
+
128
+ **Why:** SWC is 20x faster than Babel while maintaining compatibility with most JavaScript and TypeScript code.
129
+
130
+ **Impact on existing projects:**
131
+
132
+ - Your project will continue using Babel if you already have babel packages in package.json
133
+ - To switch to SWC for better performance, see migration options below
134
+
135
+ **Impact on new projects:**
136
+
137
+ - New installations will use SWC by default
138
+ - Babel dependencies won't be installed unless explicitly configured
139
+
140
+ ### Migration Options
141
+
142
+ #### Option 1 (Recommended): Switch to SWC
143
+
144
+ ```yml
145
+ # config/shakapacker.yml
146
+ javascript_transpiler: "swc"
147
+ ```
148
+
149
+ Then install SWC:
150
+
151
+ ```bash
152
+ npm install @swc/core swc-loader
153
+ ```
154
+
155
+ #### Option 2: Keep using Babel
156
+
157
+ ```yml
158
+ # config/shakapacker.yml
159
+ javascript_transpiler: "babel"
160
+ ```
161
+
162
+ No other changes needed - your existing babel packages will continue to work.
163
+
164
+ #### Option 3: Use esbuild
165
+
166
+ ```yml
167
+ # config/shakapacker.yml
168
+ javascript_transpiler: "esbuild"
169
+ ```
170
+
171
+ Then install esbuild:
172
+
173
+ ```bash
174
+ npm install esbuild esbuild-loader
175
+ ```
176
+
177
+ ### 4. Rspack Support Added
178
+
179
+ **New feature:** Shakapacker v9 adds support for Rspack as an alternative bundler to webpack.
180
+
181
+ ```yml
182
+ # config/shakapacker.yml
183
+ assets_bundler: "rspack" # or 'webpack' (default)
184
+ ```
185
+
186
+ ### 5. All Peer Dependencies Now Optional
187
+
188
+ **What changed:** All peer dependencies are now marked as optional via `peerDependenciesMeta`.
189
+
190
+ **Benefits:**
191
+
192
+ - **No installation warnings** - You won't see peer dependency warnings for packages you don't use
193
+ - **Install only what you need** - Using webpack? Don't install rspack. Using SWC? Don't install Babel.
194
+ - **Clear version constraints** - When you do install a package, version compatibility is still enforced
195
+
196
+ **What this means for you:**
197
+
198
+ - **Existing projects:** No changes needed. Your existing dependencies will continue to work.
199
+ - **New projects:** The installer only adds the packages you actually need based on your configuration.
200
+ - **Package manager behavior:** npm, yarn, and pnpm will no longer warn about missing peer dependencies.
201
+
202
+ **Example:** If you're using SWC with webpack, you only need:
203
+
204
+ ```json
205
+ {
206
+ "dependencies": {
207
+ "shakapacker": "^9.0.0",
208
+ "@swc/core": "^1.3.0",
209
+ "swc-loader": "^0.2.0",
210
+ "webpack": "^5.76.0",
211
+ "webpack-cli": "^5.0.0",
212
+ "webpack-dev-server": "^5.0.0"
213
+ }
214
+ }
215
+ ```
216
+
217
+ You won't get warnings about missing Babel, Rspack, or esbuild packages.
218
+
219
+ ## Migration Steps
220
+
221
+ ### Step 1: Update Dependencies
222
+
223
+ ```bash
224
+ npm update shakapacker@^9.0.0
225
+ # or
226
+ yarn upgrade shakapacker@^9.0.0
227
+ ```
228
+
229
+ ### Step 2: Update CSS Module Imports
230
+
231
+ #### For each CSS module import:
232
+
233
+ ```js
234
+ // Find imports like this:
235
+ import styles from "./styles.module.css"
236
+
237
+ // Replace with named imports:
238
+ import { className1, className2 } from "./styles.module.css"
239
+ ```
240
+
241
+ #### Update TypeScript definitions:
242
+
243
+ ```typescript
244
+ // Update your CSS module type definitions
245
+ declare module "*.module.css" {
246
+ // With namedExport: true, css-loader generates individual named exports
247
+ // TypeScript can't know the exact names at compile time, so we declare
248
+ // a module with any number of string exports
249
+ const classes: { readonly [key: string]: string }
250
+ export = classes
251
+ // Note: This allows 'import * as styles' but not 'import styles from'
252
+ // because css-loader with namedExport: true doesn't generate a default export
253
+ }
254
+ ```
255
+
256
+ ### Step 3: Handle Kebab-Case Class Names
257
+
258
+ v9 automatically converts kebab-case to camelCase with `exportLocalsConvention: 'camelCaseOnly'`:
259
+
260
+ ```css
261
+ /* styles.module.css */
262
+ .my-button {
263
+ }
264
+ .primary-color {
265
+ }
266
+ ```
267
+
268
+ ```js
269
+ // v9 default - camelCase conversion
270
+ import { myButton, primaryColor } from "./styles.module.css"
271
+ ```
272
+
273
+ **Alternative: Keep kebab-case names with 'dashesOnly'**
274
+
275
+ If you prefer to keep kebab-case names in JavaScript, you can override the configuration to use `'dashesOnly'`:
276
+
277
+ ```js
278
+ // config/webpack/commonWebpackConfig.js
279
+ modules: {
280
+ namedExport: true,
281
+ exportLocalsConvention: 'dashesOnly' // Keep original kebab-case names
282
+ }
283
+ ```
284
+
285
+ Then use the original kebab-case names in your imports:
286
+
287
+ ```js
288
+ // With dashesOnly configuration
289
+ import { 'my-button': myButton, 'primary-color': primaryColor } from './styles.module.css';
290
+ // or access as properties
291
+ import * as styles from './styles.module.css';
292
+ const buttonClass = styles['my-button'];
293
+ ```
294
+
295
+ **Note:** With `'camelCaseOnly'` (default) or `'dashesOnly'`, only one version is exported. If you need both the original and camelCase versions, you would need to use `'camelCase'` instead, but this requires `namedExport: false` (v8 behavior). See the [CSS Modules Export Mode documentation](./css-modules-export-mode.md) for details on reverting to v8 behavior.
296
+
297
+ ### Step 4: Update Configuration Files
298
+
299
+ If you have `webpack_loader` in your configuration:
300
+
301
+ ```yml
302
+ # config/shakapacker.yml
303
+ # OLD:
304
+ # webpack_loader: 'babel'
305
+
306
+ # NEW:
307
+ javascript_transpiler: "babel"
308
+ ```
309
+
310
+ ### Step 5: Run Tests
311
+
312
+ ```bash
313
+ # Run your test suite
314
+ npm test
315
+
316
+ # Build your application
317
+ bin/shakapacker
318
+
319
+ # Test in development
320
+ bin/shakapacker-dev-server
321
+ ```
322
+
323
+ ## Troubleshooting
324
+
325
+ ### CSS Classes Not Applying
326
+
327
+ - Ensure you're using named imports: `import { className } from '...'`
328
+ - Check camelCase conversion for kebab-case names
329
+ - Clear cache: `rm -rf tmp/cache && bin/shakapacker`
330
+
331
+ ### TypeScript Errors
332
+
333
+ Update your global type definitions as shown in Step 2.
334
+
335
+ ### Build Warnings
336
+
337
+ If you see warnings about CSS module exports, ensure you've updated all imports to use named exports or have properly configured the override.
338
+
339
+ ### Build Error: exportLocalsConvention Incompatible with namedExport
340
+
341
+ If you see this error:
342
+
343
+ ```
344
+ "exportLocalsConvention" with "camelCase" value is incompatible with "namedExport: true" option
345
+ ```
346
+
347
+ This means your webpack configuration has `namedExport: true` with `exportLocalsConvention: 'camelCase'`. The fix is to change to `'camelCaseOnly'` or `'dashesOnly'`:
348
+
349
+ ```js
350
+ // config/webpack/commonWebpackConfig.js or wherever you configure css-loader
351
+ modules: {
352
+ namedExport: true,
353
+ exportLocalsConvention: 'camelCaseOnly' // or 'dashesOnly'
354
+ }
355
+ ```
356
+
357
+ If you want to use `'camelCase'` (which exports both original and camelCase versions), you must set `namedExport: false` and revert to v8 behavior. See the [CSS Modules Export Mode documentation](./css-modules-export-mode.md) for details.
358
+
359
+ ### Unexpected Peer Dependency Warnings After Upgrade
360
+
361
+ If you experience unexpected peer dependency warnings after upgrading to v9, you may need to clear your package manager's cache and reinstall dependencies. This ensures the new optional peer dependency configuration takes effect properly.
362
+
363
+ **For npm:**
364
+
365
+ ```bash
366
+ rm -rf node_modules package-lock.json
367
+ npm install
368
+ ```
369
+
370
+ **For Yarn:**
371
+
372
+ ```bash
373
+ rm -rf node_modules yarn.lock
374
+ yarn install
375
+ ```
376
+
377
+ **For pnpm:**
378
+
379
+ ```bash
380
+ rm -rf node_modules pnpm-lock.yaml
381
+ pnpm install
382
+ ```
383
+
384
+ **For Bun:**
385
+
386
+ ```bash
387
+ rm -rf node_modules bun.lockb
388
+ bun install
389
+ ```
390
+
391
+ **When is this necessary?**
392
+
393
+ - If you see peer dependency warnings for packages you don't use (e.g., warnings about Babel when using SWC)
394
+ - If your package manager cached the old dependency resolution from v8
395
+ - After switching transpilers or bundlers (e.g., from Babel to SWC, or webpack to rspack)
396
+
397
+ **Note:** This is typically only needed once after the v8 → v9 upgrade. Subsequent installs will use the correct dependency resolution.
398
+
399
+ ## Need Help?
400
+
401
+ - See [CSS Modules Export Mode documentation](./css-modules-export-mode.md) for detailed configuration options
402
+ - Check the [CHANGELOG](../CHANGELOG.md) for all changes
403
+ - File issues at [GitHub Issues](https://github.com/shakacode/shakapacker/issues)
404
+
405
+ ## Gradual Migration Strategy
406
+
407
+ If you have a large codebase and need to migrate gradually:
408
+
409
+ 1. Override the CSS configuration to keep v8 behavior (see [documentation](./css-modules-export-mode.md))
410
+ 2. Migrate files incrementally
411
+ 3. Remove the override once migration is complete
412
+
413
+ This allows you to upgrade to v9 immediately while taking time to update your CSS module imports.
@@ -2,12 +2,10 @@
2
2
 
3
3
  ENV["RAILS_ENV"] ||= "development"
4
4
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
5
+ ENV["APP_ROOT"] ||= File.expand_path("..", __dir__)
5
6
 
6
7
  require "bundler/setup"
7
8
  require "shakapacker"
8
- require "shakapacker/webpack_runner"
9
+ require "shakapacker/runner"
9
10
 
10
- APP_ROOT = File.expand_path("..", __dir__)
11
- Dir.chdir(APP_ROOT) do
12
- Shakapacker::WebpackRunner.run(ARGV)
13
- end
11
+ Shakapacker::Runner.run(ARGV)
@@ -0,0 +1,6 @@
1
+ // See the shakacode/shakapacker README and docs directory for advice on customizing your rspackConfig.
2
+ const { generateRspackConfig } = require('shakapacker/rspack')
3
+
4
+ const rspackConfig = generateRspackConfig()
5
+
6
+ module.exports = rspackConfig
@@ -0,0 +1,7 @@
1
+ // See the shakacode/shakapacker README and docs directory for advice on customizing your rspackConfig.
2
+ import { generateRspackConfig } from 'shakapacker/rspack'
3
+ import type { RspackOptions } from '@rspack/core'
4
+
5
+ const rspackConfig: RspackOptions = generateRspackConfig()
6
+
7
+ export default rspackConfig
@@ -29,6 +29,10 @@ default: &default
29
29
  # Location for manifest.json, defaults to {public_output_path}/manifest.json if unset
30
30
  # manifest_path: public/packs/manifest.json
31
31
 
32
+ # Location for private server-side bundles (e.g., for SSR)
33
+ # These bundles are not served publicly, unlike public_output_path
34
+ # private_output_path: ssr-generated
35
+
32
36
  # Additional paths webpack should look up modules
33
37
  # ['app/assets', 'engine/foo/app/assets']
34
38
  additional_paths: []
@@ -36,8 +40,14 @@ default: &default
36
40
  # Reload manifest.json on all requests so we reload latest compiled packs
37
41
  cache_manifest: false
38
42
 
39
- # Select loader to use, available options are 'babel' (default), 'swc' or 'esbuild'
40
- webpack_loader: 'babel'
43
+ # Select JavaScript transpiler to use
44
+ # Available options: 'swc' (default, 20x faster), 'babel', or 'esbuild'
45
+ # Note: When using rspack, swc is used automatically regardless of this setting
46
+ javascript_transpiler: 'swc'
47
+
48
+ # Select assets bundler to use
49
+ # Available options: 'webpack' (default) or 'rspack'
50
+ assets_bundler: 'webpack'
41
51
 
42
52
  # Raises an error if there is a mismatch in the shakapacker gem and npm package being used
43
53
  ensure_consistent_versioning: true
@@ -0,0 +1,7 @@
1
+ // See the shakacode/shakapacker README and docs directory for advice on customizing your webpackConfig.
2
+ import { generateWebpackConfig } from 'shakapacker'
3
+ import type { Configuration } from 'webpack'
4
+
5
+ const webpackConfig: Configuration = generateWebpackConfig()
6
+
7
+ export default webpackConfig
@@ -0,0 +1,38 @@
1
+ {
2
+ "rspack": {
3
+ "@rspack/cli": "^1.0.0",
4
+ "@rspack/core": "^1.0.0",
5
+ "rspack-manifest-plugin": "^5.0.0"
6
+ },
7
+ "webpack": {
8
+ "mini-css-extract-plugin": "^2.0.0",
9
+ "terser-webpack-plugin": "^5.3.1",
10
+ "webpack": "^5.76.0",
11
+ "webpack-assets-manifest": "^5.0.6 || ^6.0.0",
12
+ "webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
13
+ "webpack-dev-server": "^4.15.2 || ^5.2.2",
14
+ "webpack-merge": "^5.8.0 || ^6.0.0",
15
+ "webpack-subresource-integrity": "^5.1.0"
16
+ },
17
+ "common": {
18
+ "compression-webpack-plugin": "^9.0.0 || ^10.0.0|| ^11.0.0",
19
+ "css-loader": "^6.0.0 || ^7.0.0",
20
+ "sass-loader": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
21
+ "style-loader": "^3.0.0 || ^4.0.0"
22
+ },
23
+ "babel": {
24
+ "@babel/core": "^7.17.9",
25
+ "@babel/plugin-transform-runtime": "^7.17.0",
26
+ "@babel/preset-env": "^7.16.11",
27
+ "@babel/runtime": "^7.17.9",
28
+ "babel-loader": "^8.2.4 || ^9.0.0 || ^10.0.0"
29
+ },
30
+ "swc": {
31
+ "@swc/core": "^1.3.0",
32
+ "swc-loader": "^0.2.0"
33
+ },
34
+ "esbuild": {
35
+ "esbuild": "^0.24.0",
36
+ "esbuild-loader": "^4.0.0"
37
+ }
38
+ }