shakapacker 9.0.0 → 9.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +77 -11
- data/Gemfile.lock +1 -1
- data/README.md +161 -107
- data/docs/common-upgrades.md +615 -0
- data/docs/rspack_migration_guide.md +92 -17
- data/docs/transpiler-migration.md +21 -0
- data/docs/typescript-migration.md +2 -1
- data/docs/using_swc_loader.md +108 -8
- data/docs/v9_upgrade.md +45 -0
- data/lib/shakapacker/bundler_switcher.rb +322 -0
- data/lib/shakapacker/doctor.rb +49 -4
- data/lib/shakapacker/swc_migrator.rb +14 -6
- data/lib/shakapacker/version.rb +1 -1
- data/lib/tasks/shakapacker/switch_bundler.rake +82 -0
- data/lib/tasks/shakapacker.rake +2 -1
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +30 -0
- data/package/environments/types.ts +22 -14
- data/package/index.ts +12 -9
- data/package/swc/index.ts +5 -3
- data/package/types/README.md +2 -1
- data/package/types/index.ts +1 -0
- data/package/utils/debug.ts +5 -5
- data/package-lock.json +13047 -0
- data/package.json +6 -1
- data/yarn.lock +196 -115
- metadata +7 -2
@@ -0,0 +1,615 @@
|
|
1
|
+
# Common Shakapacker Upgrade Guides
|
2
|
+
|
3
|
+
This document provides step-by-step instructions for the most common upgrade scenarios in Shakapacker projects.
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
- [Migrating Package Managers](#migrating-package-managers)
|
8
|
+
- [Yarn to npm](#yarn-to-npm)
|
9
|
+
- [npm to Yarn](#npm-to-yarn)
|
10
|
+
- [Migrating to pnpm](#migrating-to-pnpm)
|
11
|
+
- [Migrating from Babel to SWC](#migrating-from-babel-to-swc)
|
12
|
+
- [Migrating from Webpack to Rspack](#migrating-from-webpack-to-rspack)
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
## Migrating Package Managers
|
17
|
+
|
18
|
+
### Yarn to npm
|
19
|
+
|
20
|
+
Migrating from Yarn to npm is straightforward as both use similar package management concepts.
|
21
|
+
|
22
|
+
#### 1. Remove Yarn lock file
|
23
|
+
|
24
|
+
```bash
|
25
|
+
rm yarn.lock
|
26
|
+
```
|
27
|
+
|
28
|
+
#### 2. Install dependencies with npm
|
29
|
+
|
30
|
+
```bash
|
31
|
+
npm install
|
32
|
+
```
|
33
|
+
|
34
|
+
This will create a new `package-lock.json` file.
|
35
|
+
|
36
|
+
#### 3. Update scripts (if necessary)
|
37
|
+
|
38
|
+
Review your `package.json` scripts and any deployment scripts that may reference `yarn` commands. Replace them with npm equivalents:
|
39
|
+
|
40
|
+
```json
|
41
|
+
{
|
42
|
+
"scripts": {
|
43
|
+
"build": "shakapacker",
|
44
|
+
"dev": "shakapacker-dev-server"
|
45
|
+
}
|
46
|
+
}
|
47
|
+
```
|
48
|
+
|
49
|
+
#### 4. Update CI/CD pipelines
|
50
|
+
|
51
|
+
If you have CI/CD pipelines, update them to use `npm install` instead of `yarn install`.
|
52
|
+
|
53
|
+
#### 5. Test your build
|
54
|
+
|
55
|
+
```bash
|
56
|
+
npm run build
|
57
|
+
```
|
58
|
+
|
59
|
+
#### Common npm equivalents
|
60
|
+
|
61
|
+
| Yarn Command | npm Equivalent |
|
62
|
+
| -------------------------- | ---------------------------------- |
|
63
|
+
| `yarn` | `npm install` |
|
64
|
+
| `yarn add <package>` | `npm install <package>` |
|
65
|
+
| `yarn add --dev <package>` | `npm install --save-dev <package>` |
|
66
|
+
| `yarn remove <package>` | `npm uninstall <package>` |
|
67
|
+
| `yarn run <script>` | `npm run <script>` |
|
68
|
+
|
69
|
+
### npm to Yarn
|
70
|
+
|
71
|
+
Converting from npm to Yarn is equally straightforward.
|
72
|
+
|
73
|
+
#### 1. Remove npm lock file
|
74
|
+
|
75
|
+
```bash
|
76
|
+
rm package-lock.json
|
77
|
+
```
|
78
|
+
|
79
|
+
#### 2. Install Yarn (if not already installed)
|
80
|
+
|
81
|
+
Use Corepack (recommended for modern Node.js):
|
82
|
+
|
83
|
+
```bash
|
84
|
+
corepack enable
|
85
|
+
corepack prepare yarn@stable --activate
|
86
|
+
```
|
87
|
+
|
88
|
+
Alternative - install globally via npm:
|
89
|
+
|
90
|
+
```bash
|
91
|
+
npm install -g yarn
|
92
|
+
```
|
93
|
+
|
94
|
+
#### 3. Install dependencies with Yarn
|
95
|
+
|
96
|
+
```bash
|
97
|
+
yarn install
|
98
|
+
```
|
99
|
+
|
100
|
+
This will create a new `yarn.lock` file.
|
101
|
+
|
102
|
+
#### 4. Update scripts
|
103
|
+
|
104
|
+
Yarn can run scripts directly without the `run` command:
|
105
|
+
|
106
|
+
```bash
|
107
|
+
# Both work with Yarn
|
108
|
+
yarn build
|
109
|
+
yarn run build
|
110
|
+
```
|
111
|
+
|
112
|
+
#### 5. Test your build
|
113
|
+
|
114
|
+
```bash
|
115
|
+
yarn build
|
116
|
+
```
|
117
|
+
|
118
|
+
### Migrating to pnpm
|
119
|
+
|
120
|
+
[pnpm](https://pnpm.io/) is a fast, disk space-efficient package manager that's gaining popularity.
|
121
|
+
|
122
|
+
#### 1. Install pnpm
|
123
|
+
|
124
|
+
Use Corepack (recommended):
|
125
|
+
|
126
|
+
```bash
|
127
|
+
corepack enable
|
128
|
+
corepack prepare pnpm@latest --activate
|
129
|
+
```
|
130
|
+
|
131
|
+
Alternative - install globally via npm:
|
132
|
+
|
133
|
+
```bash
|
134
|
+
npm install -g pnpm
|
135
|
+
```
|
136
|
+
|
137
|
+
#### 2. Remove existing lock files
|
138
|
+
|
139
|
+
```bash
|
140
|
+
rm yarn.lock package-lock.json
|
141
|
+
```
|
142
|
+
|
143
|
+
#### 3. Install dependencies with pnpm
|
144
|
+
|
145
|
+
```bash
|
146
|
+
pnpm install
|
147
|
+
```
|
148
|
+
|
149
|
+
This creates a `pnpm-lock.yaml` file.
|
150
|
+
|
151
|
+
#### 4. Update scripts (if necessary)
|
152
|
+
|
153
|
+
pnpm uses the same script syntax as npm/Yarn:
|
154
|
+
|
155
|
+
```bash
|
156
|
+
pnpm run build
|
157
|
+
pnpm dev
|
158
|
+
```
|
159
|
+
|
160
|
+
#### 5. Configure pnpm workspace (optional)
|
161
|
+
|
162
|
+
If you have a monorepo setup, create a `pnpm-workspace.yaml`:
|
163
|
+
|
164
|
+
```yaml
|
165
|
+
packages:
|
166
|
+
- "packages/*"
|
167
|
+
```
|
168
|
+
|
169
|
+
#### 6. Test your build
|
170
|
+
|
171
|
+
```bash
|
172
|
+
pnpm run build
|
173
|
+
```
|
174
|
+
|
175
|
+
#### pnpm benefits
|
176
|
+
|
177
|
+
- **Faster installs**: Up to 2x faster than npm/Yarn
|
178
|
+
- **Disk space efficient**: Uses hard links to save disk space
|
179
|
+
- **Strict**: Better at catching dependency issues
|
180
|
+
|
181
|
+
---
|
182
|
+
|
183
|
+
## Migrating from Babel to SWC
|
184
|
+
|
185
|
+
SWC is a Rust-based JavaScript/TypeScript compiler that's significantly faster than Babel (20-70x on multi-core with optimal setup, 5-7.5x in typical single-threaded scenarios). For complete details, see [JavaScript Transpiler Configuration](./transpiler-migration.md).
|
186
|
+
|
187
|
+
### Quick Migration Steps
|
188
|
+
|
189
|
+
#### 1. Install SWC dependencies
|
190
|
+
|
191
|
+
```bash
|
192
|
+
# Using Yarn
|
193
|
+
yarn add --dev @swc/core swc-loader
|
194
|
+
|
195
|
+
# Using npm
|
196
|
+
npm install --save-dev @swc/core swc-loader
|
197
|
+
|
198
|
+
# Using pnpm
|
199
|
+
pnpm add --save-dev @swc/core swc-loader
|
200
|
+
```
|
201
|
+
|
202
|
+
#### 2. Update shakapacker.yml
|
203
|
+
|
204
|
+
```yaml
|
205
|
+
# config/shakapacker.yml
|
206
|
+
default: &default
|
207
|
+
javascript_transpiler: swc
|
208
|
+
```
|
209
|
+
|
210
|
+
#### 3. Run the migration rake task (recommended)
|
211
|
+
|
212
|
+
```bash
|
213
|
+
bundle exec rake shakapacker:migrate_to_swc
|
214
|
+
```
|
215
|
+
|
216
|
+
This will automatically create a `config/swc.config.js` with sensible defaults, including Stimulus compatibility if needed.
|
217
|
+
|
218
|
+
#### 4. Create SWC configuration (if not using rake task)
|
219
|
+
|
220
|
+
If you're configuring manually, create `config/swc.config.js`:
|
221
|
+
|
222
|
+
```javascript
|
223
|
+
// config/swc.config.js
|
224
|
+
// This file is merged with Shakapacker's default SWC configuration
|
225
|
+
// See: https://swc.rs/docs/configuration/compilation
|
226
|
+
|
227
|
+
module.exports = {
|
228
|
+
options: {
|
229
|
+
jsc: {
|
230
|
+
// CRITICAL for Stimulus compatibility: Prevents SWC from mangling class names
|
231
|
+
keepClassNames: true,
|
232
|
+
transform: {
|
233
|
+
react: {
|
234
|
+
runtime: "automatic"
|
235
|
+
}
|
236
|
+
}
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
```
|
241
|
+
|
242
|
+
**Note:** The `options` wrapper is required for proper merging with Shakapacker's defaults. Using `.swcrc` instead will completely override Shakapacker's settings and may cause build failures.
|
243
|
+
|
244
|
+
#### 5. Update React refresh plugin (if using React)
|
245
|
+
|
246
|
+
```bash
|
247
|
+
# For webpack
|
248
|
+
yarn add --dev @pmmmwh/react-refresh-webpack-plugin
|
249
|
+
|
250
|
+
# For rspack
|
251
|
+
yarn add --dev @rspack/plugin-react-refresh
|
252
|
+
```
|
253
|
+
|
254
|
+
#### 6. Test your build
|
255
|
+
|
256
|
+
```bash
|
257
|
+
bin/shakapacker
|
258
|
+
```
|
259
|
+
|
260
|
+
#### 7. Run your test suite
|
261
|
+
|
262
|
+
```bash
|
263
|
+
# Ensure everything works as expected
|
264
|
+
bundle exec rspec
|
265
|
+
```
|
266
|
+
|
267
|
+
### Performance Expectations
|
268
|
+
|
269
|
+
Typical build time improvements when migrating from Babel to SWC (single-threaded transpilation):
|
270
|
+
|
271
|
+
| Project Size | Babel | SWC | Improvement |
|
272
|
+
| ---------------------- | ----- | --- | ----------- |
|
273
|
+
| Small (<100 files) | 5s | 1s | 5x faster |
|
274
|
+
| Medium (100-500 files) | 20s | 3s | 6.7x faster |
|
275
|
+
| Large (500+ files) | 60s | 8s | 7.5x faster |
|
276
|
+
|
277
|
+
**Note:** With multi-core optimization and ideal conditions, SWC can achieve 20-70x improvements over Babel.
|
278
|
+
|
279
|
+
### Common Issues
|
280
|
+
|
281
|
+
#### Issue: Decorators not working
|
282
|
+
|
283
|
+
Add decorator support to `config/swc.config.js`:
|
284
|
+
|
285
|
+
```javascript
|
286
|
+
module.exports = {
|
287
|
+
options: {
|
288
|
+
jsc: {
|
289
|
+
parser: {
|
290
|
+
decorators: true,
|
291
|
+
decoratorsBeforeExport: true
|
292
|
+
}
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
```
|
297
|
+
|
298
|
+
#### Issue: Stimulus controllers not working
|
299
|
+
|
300
|
+
Ensure `keepClassNames: true` is set in `config/swc.config.js`.
|
301
|
+
|
302
|
+
### Rollback
|
303
|
+
|
304
|
+
If you need to revert:
|
305
|
+
|
306
|
+
```yaml
|
307
|
+
# config/shakapacker.yml
|
308
|
+
default: &default
|
309
|
+
javascript_transpiler: babel
|
310
|
+
```
|
311
|
+
|
312
|
+
Then rebuild:
|
313
|
+
|
314
|
+
```bash
|
315
|
+
bin/shakapacker clobber
|
316
|
+
bin/shakapacker compile
|
317
|
+
```
|
318
|
+
|
319
|
+
---
|
320
|
+
|
321
|
+
## Migrating from Webpack to Rspack
|
322
|
+
|
323
|
+
[Rspack](https://rspack.rs/) is a high-performance bundler written in Rust, offering 5-10x faster build times than webpack with excellent webpack compatibility. For complete details, see [Rspack Migration Guide](./rspack_migration_guide.md).
|
324
|
+
|
325
|
+
### Quick Migration Steps
|
326
|
+
|
327
|
+
#### 1. Use the switch bundler rake task (recommended)
|
328
|
+
|
329
|
+
Shakapacker provides a convenient rake task to automate the migration:
|
330
|
+
|
331
|
+
```bash
|
332
|
+
# Switch to rspack with automatic dependency management
|
333
|
+
rails shakapacker:switch_bundler rspack --install-deps
|
334
|
+
|
335
|
+
# Or with rake (note the -- separator)
|
336
|
+
rake shakapacker:switch_bundler rspack -- --install-deps
|
337
|
+
|
338
|
+
# Fast switching without uninstalling webpack (keeps both)
|
339
|
+
rails shakapacker:switch_bundler rspack --install-deps --no-uninstall
|
340
|
+
```
|
341
|
+
|
342
|
+
The task will:
|
343
|
+
|
344
|
+
- Update `config/shakapacker.yml` to use rspack
|
345
|
+
- Install rspack dependencies (with `--install-deps`)
|
346
|
+
- Optionally uninstall webpack dependencies (default) or keep both (with `--no-uninstall`)
|
347
|
+
- Update `javascript_transpiler` to `swc` (recommended for rspack)
|
348
|
+
- Preserve your config file comments and structure
|
349
|
+
|
350
|
+
**Custom dependencies:** You can customize which dependencies are installed:
|
351
|
+
|
352
|
+
```bash
|
353
|
+
rails shakapacker:switch_bundler --init-config
|
354
|
+
```
|
355
|
+
|
356
|
+
#### 2. Manual installation (alternative)
|
357
|
+
|
358
|
+
If you prefer manual control:
|
359
|
+
|
360
|
+
```bash
|
361
|
+
# Install Rspack dependencies
|
362
|
+
# Using Yarn
|
363
|
+
yarn add --dev @rspack/core @rspack/cli
|
364
|
+
|
365
|
+
# Using npm
|
366
|
+
npm install --save-dev @rspack/core @rspack/cli
|
367
|
+
|
368
|
+
# Using pnpm
|
369
|
+
pnpm add --save-dev @rspack/core @rspack/cli
|
370
|
+
|
371
|
+
# Remove webpack dependencies (optional)
|
372
|
+
yarn remove webpack webpack-cli webpack-dev-server
|
373
|
+
# Or: npm uninstall webpack webpack-cli webpack-dev-server
|
374
|
+
# Or: pnpm remove webpack webpack-cli webpack-dev-server
|
375
|
+
```
|
376
|
+
|
377
|
+
Then update `config/shakapacker.yml`:
|
378
|
+
|
379
|
+
```yaml
|
380
|
+
default: &default
|
381
|
+
assets_bundler: rspack
|
382
|
+
javascript_transpiler: swc # Rspack defaults to SWC for best performance
|
383
|
+
```
|
384
|
+
|
385
|
+
#### 3. Create Rspack configuration
|
386
|
+
|
387
|
+
Create `config/rspack/rspack.config.js` based on your webpack config. Start with a minimal configuration:
|
388
|
+
|
389
|
+
```javascript
|
390
|
+
// config/rspack/rspack.config.js
|
391
|
+
const { rspack } = require("@rspack/core")
|
392
|
+
const { merge } = require("webpack-merge")
|
393
|
+
const baseConfig = require("../shakapacker")
|
394
|
+
|
395
|
+
module.exports = merge(baseConfig, {
|
396
|
+
module: {
|
397
|
+
rules: [
|
398
|
+
{
|
399
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
400
|
+
loader: "builtin:swc-loader",
|
401
|
+
options: {
|
402
|
+
jsc: {
|
403
|
+
parser: {
|
404
|
+
syntax: "ecmascript",
|
405
|
+
jsx: true
|
406
|
+
},
|
407
|
+
transform: {
|
408
|
+
react: {
|
409
|
+
runtime: "automatic"
|
410
|
+
}
|
411
|
+
}
|
412
|
+
}
|
413
|
+
}
|
414
|
+
}
|
415
|
+
]
|
416
|
+
}
|
417
|
+
})
|
418
|
+
```
|
419
|
+
|
420
|
+
#### 4. Update TypeScript configuration
|
421
|
+
|
422
|
+
Add `isolatedModules: true` to your `tsconfig.json`:
|
423
|
+
|
424
|
+
```json
|
425
|
+
{
|
426
|
+
"compilerOptions": {
|
427
|
+
"isolatedModules": true
|
428
|
+
}
|
429
|
+
}
|
430
|
+
```
|
431
|
+
|
432
|
+
#### 5. Replace incompatible plugins
|
433
|
+
|
434
|
+
Some webpack plugins need Rspack equivalents:
|
435
|
+
|
436
|
+
| Webpack Plugin | Rspack Alternative |
|
437
|
+
| -------------------------------------- | ----------------------------------- |
|
438
|
+
| `mini-css-extract-plugin` | `rspack.CssExtractRspackPlugin` |
|
439
|
+
| `copy-webpack-plugin` | `rspack.CopyRspackPlugin` |
|
440
|
+
| `terser-webpack-plugin` | `rspack.SwcJsMinimizerRspackPlugin` |
|
441
|
+
| `fork-ts-checker-webpack-plugin` | `ts-checker-rspack-plugin` |
|
442
|
+
| `@pmmmwh/react-refresh-webpack-plugin` | `@rspack/plugin-react-refresh` |
|
443
|
+
|
444
|
+
Example plugin update:
|
445
|
+
|
446
|
+
```javascript
|
447
|
+
// Before (webpack)
|
448
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
449
|
+
plugins: [new MiniCssExtractPlugin()]
|
450
|
+
|
451
|
+
// After (rspack)
|
452
|
+
const { rspack } = require("@rspack/core")
|
453
|
+
plugins: [new rspack.CssExtractRspackPlugin()]
|
454
|
+
```
|
455
|
+
|
456
|
+
#### 6. Update asset handling
|
457
|
+
|
458
|
+
Replace file loaders with asset modules:
|
459
|
+
|
460
|
+
```javascript
|
461
|
+
// Before (webpack with file-loader)
|
462
|
+
{
|
463
|
+
test: /\.(png|jpg|gif)$/,
|
464
|
+
use: ['file-loader']
|
465
|
+
}
|
466
|
+
|
467
|
+
// After (rspack with asset modules)
|
468
|
+
{
|
469
|
+
test: /\.(png|jpg|gif)$/,
|
470
|
+
type: 'asset/resource'
|
471
|
+
}
|
472
|
+
```
|
473
|
+
|
474
|
+
#### 7. Install React refresh plugin (if using React)
|
475
|
+
|
476
|
+
```bash
|
477
|
+
yarn add --dev @rspack/plugin-react-refresh
|
478
|
+
```
|
479
|
+
|
480
|
+
Update your config:
|
481
|
+
|
482
|
+
```javascript
|
483
|
+
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh")
|
484
|
+
const { rspack } = require("@rspack/core")
|
485
|
+
|
486
|
+
module.exports = {
|
487
|
+
plugins: [new ReactRefreshPlugin(), new rspack.HotModuleReplacementPlugin()]
|
488
|
+
}
|
489
|
+
```
|
490
|
+
|
491
|
+
#### 8. Test your build
|
492
|
+
|
493
|
+
```bash
|
494
|
+
# Development build
|
495
|
+
bin/shakapacker
|
496
|
+
|
497
|
+
# Production build
|
498
|
+
bin/shakapacker --mode production
|
499
|
+
```
|
500
|
+
|
501
|
+
#### 9. Update development workflow
|
502
|
+
|
503
|
+
Rspack's dev server works the same way:
|
504
|
+
|
505
|
+
```bash
|
506
|
+
bin/shakapacker-dev-server
|
507
|
+
```
|
508
|
+
|
509
|
+
### Migration Checklist
|
510
|
+
|
511
|
+
- [ ] Install Rspack dependencies
|
512
|
+
- [ ] Update `config/shakapacker.yml`
|
513
|
+
- [ ] Create `config/rspack/rspack.config.js`
|
514
|
+
- [ ] Replace incompatible plugins
|
515
|
+
- [ ] Update TypeScript config (add `isolatedModules: true`)
|
516
|
+
- [ ] Convert file loaders to asset modules
|
517
|
+
- [ ] Test development build
|
518
|
+
- [ ] Test production build
|
519
|
+
- [ ] Run test suite
|
520
|
+
- [ ] Update CI/CD pipelines
|
521
|
+
- [ ] Deploy to staging
|
522
|
+
- [ ] Monitor performance improvements
|
523
|
+
|
524
|
+
### Performance Benefits
|
525
|
+
|
526
|
+
Typical build time improvements when migrating from webpack to Rspack:
|
527
|
+
|
528
|
+
| Build Type | Webpack | Rspack | Improvement |
|
529
|
+
| ---------------- | ------- | ------ | ----------- |
|
530
|
+
| Cold build | 60s | 8s | 7.5x faster |
|
531
|
+
| Hot reload | 3s | 0.5s | 6x faster |
|
532
|
+
| Production build | 120s | 15s | 8x faster |
|
533
|
+
|
534
|
+
**Note:** Actual improvements vary based on project size, configuration, and hardware. Rspack's Rust-based architecture provides consistent 5-10x performance gains across most scenarios.
|
535
|
+
|
536
|
+
### Common Issues
|
537
|
+
|
538
|
+
#### Issue: LimitChunkCountPlugin Error
|
539
|
+
|
540
|
+
```
|
541
|
+
Error: Cannot read properties of undefined (reading 'tap')
|
542
|
+
```
|
543
|
+
|
544
|
+
**Solution:** Remove `webpack.optimize.LimitChunkCountPlugin` and use `splitChunks` configuration instead.
|
545
|
+
|
546
|
+
#### Issue: CSS not extracting
|
547
|
+
|
548
|
+
**Solution:** Use `rspack.CssExtractRspackPlugin` instead of `mini-css-extract-plugin`.
|
549
|
+
|
550
|
+
#### Issue: TypeScript errors
|
551
|
+
|
552
|
+
**Solution:** Ensure `isolatedModules: true` is set in `tsconfig.json`.
|
553
|
+
|
554
|
+
### Rollback
|
555
|
+
|
556
|
+
If you need to revert to webpack:
|
557
|
+
|
558
|
+
```yaml
|
559
|
+
# config/shakapacker.yml
|
560
|
+
default: &default
|
561
|
+
assets_bundler: webpack
|
562
|
+
javascript_transpiler: babel # or swc
|
563
|
+
```
|
564
|
+
|
565
|
+
Then rebuild:
|
566
|
+
|
567
|
+
```bash
|
568
|
+
bin/shakapacker clobber
|
569
|
+
bin/shakapacker compile
|
570
|
+
```
|
571
|
+
|
572
|
+
---
|
573
|
+
|
574
|
+
## Combined Migration Path
|
575
|
+
|
576
|
+
For maximum performance improvements, you can combine multiple migrations:
|
577
|
+
|
578
|
+
### Recommended: Webpack + Babel → Rspack + SWC
|
579
|
+
|
580
|
+
This combination provides the best performance improvement (up to 50-70x faster builds):
|
581
|
+
|
582
|
+
1. **First, migrate to SWC** (while still on webpack)
|
583
|
+
|
584
|
+
- Follow [Migrating from Babel to SWC](#migrating-from-babel-to-swc)
|
585
|
+
- Test thoroughly
|
586
|
+
- This is a smaller change to validate first
|
587
|
+
|
588
|
+
2. **Then, migrate to Rspack**
|
589
|
+
- Follow [Migrating from Webpack to Rspack](#migrating-from-webpack-to-rspack)
|
590
|
+
- Rspack will use your existing SWC configuration
|
591
|
+
- Test thoroughly
|
592
|
+
|
593
|
+
### Alternative: Webpack + Babel → Rspack + SWC (all at once)
|
594
|
+
|
595
|
+
If you're confident, you can do both migrations simultaneously:
|
596
|
+
|
597
|
+
```yaml
|
598
|
+
# config/shakapacker.yml
|
599
|
+
default: &default
|
600
|
+
assets_bundler: rspack
|
601
|
+
javascript_transpiler: swc
|
602
|
+
```
|
603
|
+
|
604
|
+
Follow both migration guides, installing all required dependencies at once.
|
605
|
+
|
606
|
+
---
|
607
|
+
|
608
|
+
## Getting Help
|
609
|
+
|
610
|
+
- [Shakapacker Documentation](../README.md)
|
611
|
+
- [Shakapacker Slack Channel](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE)
|
612
|
+
- [GitHub Issues](https://github.com/shakacode/shakapacker/issues)
|
613
|
+
- [SWC Documentation](https://swc.rs/)
|
614
|
+
- [Rspack Documentation](https://rspack.rs/)
|
615
|
+
- [pnpm Documentation](https://pnpm.io/)
|