shakapacker 9.0.0 → 9.2.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/.gitignore +3 -0
- data/CHANGELOG.md +108 -11
- data/Gemfile.lock +1 -1
- data/README.md +182 -107
- data/bin/export-bundler-config +11 -0
- data/docs/common-upgrades.md +615 -0
- data/docs/deployment.md +52 -8
- data/docs/releasing.md +197 -0
- data/docs/rspack_migration_guide.md +120 -17
- data/docs/transpiler-migration.md +21 -0
- data/docs/troubleshooting.md +124 -23
- data/docs/typescript-migration.md +2 -1
- data/docs/using_swc_loader.md +108 -8
- data/docs/v9_upgrade.md +45 -0
- data/lib/install/bin/export-bundler-config +11 -0
- data/lib/install/bin/shakapacker +1 -1
- data/lib/install/bin/shakapacker-dev-server +1 -1
- data/lib/shakapacker/bundler_switcher.rb +329 -0
- data/lib/shakapacker/configuration.rb +28 -2
- data/lib/shakapacker/doctor.rb +65 -4
- data/lib/shakapacker/rspack_runner.rb +1 -1
- data/lib/shakapacker/runner.rb +1 -1
- data/lib/shakapacker/swc_migrator.rb +14 -6
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/webpack_runner.rb +1 -1
- data/lib/shakapacker.rb +10 -0
- data/lib/tasks/shakapacker/export_bundler_config.rake +72 -0
- data/lib/tasks/shakapacker/switch_bundler.rake +82 -0
- data/lib/tasks/shakapacker.rake +2 -1
- data/package/configExporter/cli.ts +683 -0
- data/package/configExporter/configDocs.ts +102 -0
- data/package/configExporter/fileWriter.ts +92 -0
- data/package/configExporter/index.ts +5 -0
- data/package/configExporter/types.ts +36 -0
- data/package/configExporter/yamlSerializer.ts +266 -0
- 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 +7 -1
- data/yarn.lock +261 -389
- metadata +17 -2
data/docs/releasing.md
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Releasing Shakapacker
|
|
2
|
+
|
|
3
|
+
This guide is for Shakapacker maintainers who need to publish a new release.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. **Install required tools:**
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle install # Installs gem-release
|
|
11
|
+
yarn global add release-it # Installs release-it for npm publishing
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. **Ensure you have publishing access:**
|
|
15
|
+
|
|
16
|
+
- npm: You must be a collaborator on the [shakapacker npm package](https://www.npmjs.com/package/shakapacker)
|
|
17
|
+
- RubyGems: You must be an owner of the [shakapacker gem](https://rubygems.org/gems/shakapacker)
|
|
18
|
+
|
|
19
|
+
3. **Enable 2FA on both platforms:**
|
|
20
|
+
- npm: 2FA is required for publishing
|
|
21
|
+
- RubyGems: 2FA is required for publishing
|
|
22
|
+
|
|
23
|
+
## Release Process
|
|
24
|
+
|
|
25
|
+
### 1. Prepare the Release
|
|
26
|
+
|
|
27
|
+
Before running the release task:
|
|
28
|
+
|
|
29
|
+
1. Ensure all desired changes are merged to `main` branch
|
|
30
|
+
2. Update `CHANGELOG.md` with the new version and release notes
|
|
31
|
+
3. Commit the CHANGELOG changes
|
|
32
|
+
4. Ensure your working directory is clean (`git status` shows no uncommitted changes)
|
|
33
|
+
|
|
34
|
+
### 2. Run the Release Task
|
|
35
|
+
|
|
36
|
+
The automated release task handles the entire release process:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# For a specific version (e.g., 9.1.0)
|
|
40
|
+
rake create_release[9.1.0]
|
|
41
|
+
|
|
42
|
+
# For a beta release (note: use period, not dash)
|
|
43
|
+
rake create_release[9.2.0.beta.1] # Creates npm package 9.2.0-beta.1
|
|
44
|
+
|
|
45
|
+
# For a patch version bump (auto-increments)
|
|
46
|
+
rake create_release
|
|
47
|
+
|
|
48
|
+
# Dry run to test without publishing
|
|
49
|
+
rake create_release[9.1.0,true]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. What the Release Task Does
|
|
53
|
+
|
|
54
|
+
The `create_release` task automatically:
|
|
55
|
+
|
|
56
|
+
1. **Pulls latest changes** from the repository
|
|
57
|
+
2. **Bumps version numbers** in:
|
|
58
|
+
- `lib/shakapacker/version.rb` (Ruby gem version)
|
|
59
|
+
- `package.json` (npm package version - converted from Ruby format)
|
|
60
|
+
3. **Publishes to npm:**
|
|
61
|
+
- Prompts for npm OTP (2FA code)
|
|
62
|
+
- Creates git tag
|
|
63
|
+
- Pushes to GitHub
|
|
64
|
+
4. **Publishes to RubyGems:**
|
|
65
|
+
- Prompts for RubyGems OTP (2FA code)
|
|
66
|
+
5. **Updates spec/dummy lockfiles:**
|
|
67
|
+
- Runs `bundle install` to update `Gemfile.lock`
|
|
68
|
+
- Runs `npm install` to update `package-lock.json` (yarn.lock may also be updated for multi-package-manager compatibility testing)
|
|
69
|
+
6. **Commits and pushes lockfile changes** automatically
|
|
70
|
+
|
|
71
|
+
### 4. Version Format
|
|
72
|
+
|
|
73
|
+
**Important:** Use Ruby gem version format (no dashes):
|
|
74
|
+
|
|
75
|
+
- ✅ Correct: `9.1.0`, `9.2.0.beta.1`, `9.0.0.rc.2`
|
|
76
|
+
- ❌ Wrong: `9.1.0-beta.1`, `9.0.0-rc.2`
|
|
77
|
+
|
|
78
|
+
The task automatically converts Ruby gem format to npm semver format:
|
|
79
|
+
|
|
80
|
+
- Ruby: `9.2.0.beta.1` → npm: `9.2.0-beta.1`
|
|
81
|
+
- Ruby: `9.0.0.rc.2` → npm: `9.0.0-rc.2`
|
|
82
|
+
|
|
83
|
+
**Examples:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Regular release
|
|
87
|
+
rake create_release[9.1.0] # Gem: 9.1.0, npm: 9.1.0
|
|
88
|
+
|
|
89
|
+
# Beta release
|
|
90
|
+
rake create_release[9.2.0.beta.1] # Gem: 9.2.0.beta.1, npm: 9.2.0-beta.1
|
|
91
|
+
|
|
92
|
+
# Release candidate
|
|
93
|
+
rake create_release[10.0.0.rc.1] # Gem: 10.0.0.rc.1, npm: 10.0.0-rc.1
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 5. During the Release
|
|
97
|
+
|
|
98
|
+
1. When prompted for **npm OTP**, enter your 2FA code from your authenticator app
|
|
99
|
+
2. Accept defaults for release-it options
|
|
100
|
+
3. When prompted for **RubyGems OTP**, enter your 2FA code
|
|
101
|
+
4. The script will automatically commit and push lockfile updates
|
|
102
|
+
|
|
103
|
+
### 6. After Release
|
|
104
|
+
|
|
105
|
+
1. Verify the release on:
|
|
106
|
+
|
|
107
|
+
- [npm](https://www.npmjs.com/package/shakapacker)
|
|
108
|
+
- [RubyGems](https://rubygems.org/gems/shakapacker)
|
|
109
|
+
- [GitHub releases](https://github.com/shakacode/shakapacker/releases)
|
|
110
|
+
|
|
111
|
+
2. Check that the lockfile commit was pushed:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git log --oneline -5
|
|
115
|
+
# Should see "Update spec/dummy lockfiles after release"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
3. Announce the release (if appropriate):
|
|
119
|
+
- Post in relevant Slack/Discord channels
|
|
120
|
+
- Tweet about major releases
|
|
121
|
+
- Update documentation if needed
|
|
122
|
+
|
|
123
|
+
## Troubleshooting
|
|
124
|
+
|
|
125
|
+
### Uncommitted Changes After Release
|
|
126
|
+
|
|
127
|
+
If you see uncommitted changes to lockfiles after a release, this means:
|
|
128
|
+
|
|
129
|
+
1. The release was successful but the lockfile commit step may have failed
|
|
130
|
+
2. **Solution:** Manually commit these files:
|
|
131
|
+
```bash
|
|
132
|
+
git add spec/dummy/Gemfile.lock spec/dummy/package-lock.json spec/dummy/yarn.lock
|
|
133
|
+
git commit -m 'Update spec/dummy lockfiles after release'
|
|
134
|
+
git push
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Failed npm or RubyGems Publish
|
|
138
|
+
|
|
139
|
+
If publishing fails partway through:
|
|
140
|
+
|
|
141
|
+
1. Check which step failed (npm or RubyGems)
|
|
142
|
+
2. If npm failed: Fix the issue and manually run `npm publish`
|
|
143
|
+
3. If RubyGems failed: Fix the issue and manually run `gem release`
|
|
144
|
+
4. Then manually update and commit spec/dummy lockfiles
|
|
145
|
+
|
|
146
|
+
### Wrong Version Format
|
|
147
|
+
|
|
148
|
+
If you accidentally use npm format (with dashes):
|
|
149
|
+
|
|
150
|
+
1. The gem will be created with an invalid version
|
|
151
|
+
2. **Solution:** Don't push the changes, reset your branch:
|
|
152
|
+
```bash
|
|
153
|
+
git reset --hard HEAD
|
|
154
|
+
```
|
|
155
|
+
3. Re-run with correct Ruby gem format
|
|
156
|
+
|
|
157
|
+
## Manual Release Steps
|
|
158
|
+
|
|
159
|
+
If you need to release manually (not recommended):
|
|
160
|
+
|
|
161
|
+
1. **Bump version:**
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
gem bump --version 9.1.0
|
|
165
|
+
bundle install
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
2. **Publish to npm:**
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
release-it 9.1.0 --npm.publish
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
3. **Publish to RubyGems:**
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
gem release
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
4. **Update lockfiles:**
|
|
181
|
+
```bash
|
|
182
|
+
cd spec/dummy
|
|
183
|
+
bundle install
|
|
184
|
+
npm install
|
|
185
|
+
cd ../..
|
|
186
|
+
git add spec/dummy/Gemfile.lock spec/dummy/package-lock.json spec/dummy/yarn.lock
|
|
187
|
+
git commit -m 'Update spec/dummy lockfiles after release'
|
|
188
|
+
git push
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Questions?
|
|
192
|
+
|
|
193
|
+
If you encounter issues not covered here, please:
|
|
194
|
+
|
|
195
|
+
1. Check the [CONTRIBUTING.md](../CONTRIBUTING.md) guide
|
|
196
|
+
2. Ask in the maintainers channel
|
|
197
|
+
3. Update this documentation for future releases
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
# Rspack Migration Guide for Shakapacker
|
|
2
2
|
|
|
3
|
+
> 💡 **Quick Start**: For a step-by-step migration guide from Webpack to Rspack, see [Common Upgrades Guide - Webpack to Rspack](./common-upgrades.md#migrating-from-webpack-to-rspack).
|
|
4
|
+
|
|
3
5
|
## Overview
|
|
6
|
+
|
|
4
7
|
This guide documents the differences between webpack and Rspack configurations in Shakapacker, and provides migration guidance for users switching to Rspack.
|
|
5
8
|
|
|
6
9
|
## Key Differences from Webpack
|
|
7
10
|
|
|
8
11
|
### 1. Built-in Loaders
|
|
12
|
+
|
|
9
13
|
Rspack provides built-in loaders for better performance:
|
|
10
14
|
|
|
11
15
|
**JavaScript/TypeScript:**
|
|
16
|
+
|
|
12
17
|
- Use `builtin:swc-loader` instead of `babel-loader` or `ts-loader`
|
|
13
18
|
- 20x faster than Babel on single thread, 70x on multiple cores
|
|
14
19
|
- Configuration example:
|
|
20
|
+
|
|
15
21
|
```javascript
|
|
16
22
|
{
|
|
17
23
|
test: /\.(js|jsx|ts|tsx)$/,
|
|
@@ -36,28 +42,34 @@ Rspack provides built-in loaders for better performance:
|
|
|
36
42
|
### 2. Plugin Replacements
|
|
37
43
|
|
|
38
44
|
#### Built-in Rspack Alternatives
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
45
|
+
|
|
46
|
+
| Webpack Plugin | Rspack Alternative | Status |
|
|
47
|
+
| ------------------------------ | ------------------------------------------ | ----------- |
|
|
48
|
+
| `copy-webpack-plugin` | `rspack.CopyRspackPlugin` | ✅ Built-in |
|
|
49
|
+
| `mini-css-extract-plugin` | `rspack.CssExtractRspackPlugin` | ✅ Built-in |
|
|
50
|
+
| `terser-webpack-plugin` | `rspack.SwcJsMinimizerRspackPlugin` | ✅ Built-in |
|
|
44
51
|
| `css-minimizer-webpack-plugin` | `rspack.LightningCssMinimizerRspackPlugin` | ✅ Built-in |
|
|
45
52
|
|
|
46
53
|
#### Community Alternatives
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
|
54
|
+
|
|
55
|
+
| Webpack Plugin | Rspack Alternative | Package |
|
|
56
|
+
| -------------------------------------- | ------------------------------ | --------------------------------------- |
|
|
57
|
+
| `fork-ts-checker-webpack-plugin` | `ts-checker-rspack-plugin` | `npm i -D ts-checker-rspack-plugin` |
|
|
50
58
|
| `@pmmmwh/react-refresh-webpack-plugin` | `@rspack/plugin-react-refresh` | `npm i -D @rspack/plugin-react-refresh` |
|
|
51
|
-
| `eslint-webpack-plugin`
|
|
59
|
+
| `eslint-webpack-plugin` | `eslint-rspack-plugin` | `npm i -D eslint-rspack-plugin` |
|
|
52
60
|
|
|
53
61
|
#### Incompatible Plugins
|
|
62
|
+
|
|
54
63
|
The following webpack plugins are NOT compatible with Rspack:
|
|
64
|
+
|
|
55
65
|
- `webpack.optimize.LimitChunkCountPlugin` - Use `optimization.splitChunks` configuration instead
|
|
56
66
|
- `webpack-manifest-plugin` - Use `rspack-manifest-plugin` instead
|
|
57
67
|
- Git revision plugins - Use alternative approaches
|
|
58
68
|
|
|
59
69
|
### 3. Asset Module Types
|
|
70
|
+
|
|
60
71
|
Replace file loaders with asset modules:
|
|
72
|
+
|
|
61
73
|
- `file-loader` → `type: 'asset/resource'`
|
|
62
74
|
- `url-loader` → `type: 'asset/inline'`
|
|
63
75
|
- `raw-loader` → `type: 'asset/source'`
|
|
@@ -65,7 +77,9 @@ Replace file loaders with asset modules:
|
|
|
65
77
|
### 4. Configuration Differences
|
|
66
78
|
|
|
67
79
|
#### TypeScript Configuration
|
|
80
|
+
|
|
68
81
|
**Required:** Add `isolatedModules: true` to your `tsconfig.json`:
|
|
82
|
+
|
|
69
83
|
```json
|
|
70
84
|
{
|
|
71
85
|
"compilerOptions": {
|
|
@@ -75,22 +89,22 @@ Replace file loaders with asset modules:
|
|
|
75
89
|
```
|
|
76
90
|
|
|
77
91
|
#### React Fast Refresh
|
|
92
|
+
|
|
78
93
|
```javascript
|
|
79
94
|
// Development configuration
|
|
80
|
-
const ReactRefreshPlugin = require(
|
|
95
|
+
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh")
|
|
81
96
|
|
|
82
97
|
module.exports = {
|
|
83
|
-
plugins: [
|
|
84
|
-
|
|
85
|
-
new rspack.HotModuleReplacementPlugin()
|
|
86
|
-
]
|
|
87
|
-
};
|
|
98
|
+
plugins: [new ReactRefreshPlugin(), new rspack.HotModuleReplacementPlugin()]
|
|
99
|
+
}
|
|
88
100
|
```
|
|
89
101
|
|
|
90
102
|
### 5. Optimization Differences
|
|
91
103
|
|
|
92
104
|
#### Code Splitting
|
|
105
|
+
|
|
93
106
|
Rspack's `splitChunks` configuration is similar to webpack but with some differences:
|
|
107
|
+
|
|
94
108
|
```javascript
|
|
95
109
|
optimization: {
|
|
96
110
|
splitChunks: {
|
|
@@ -107,6 +121,7 @@ optimization: {
|
|
|
107
121
|
```
|
|
108
122
|
|
|
109
123
|
#### Minimization
|
|
124
|
+
|
|
110
125
|
```javascript
|
|
111
126
|
optimization: {
|
|
112
127
|
minimize: true,
|
|
@@ -118,7 +133,9 @@ optimization: {
|
|
|
118
133
|
```
|
|
119
134
|
|
|
120
135
|
### 6. Development Server
|
|
136
|
+
|
|
121
137
|
Rspack uses its own dev server with some configuration differences:
|
|
138
|
+
|
|
122
139
|
```javascript
|
|
123
140
|
devServer: {
|
|
124
141
|
// Rspack-specific: Force writing assets to disk
|
|
@@ -130,7 +147,55 @@ devServer: {
|
|
|
130
147
|
|
|
131
148
|
## Migration Checklist
|
|
132
149
|
|
|
150
|
+
### Quick Start: Using the Switch Bundler Task
|
|
151
|
+
|
|
152
|
+
Shakapacker provides a convenient rake task to switch between webpack and rspack:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Switch to rspack with automatic dependency management
|
|
156
|
+
rails shakapacker:switch_bundler rspack --install-deps
|
|
157
|
+
# or with rake (note the -- separator)
|
|
158
|
+
rake shakapacker:switch_bundler rspack -- --install-deps
|
|
159
|
+
|
|
160
|
+
# Fast switching without uninstalling old bundler (keeps both)
|
|
161
|
+
rails shakapacker:switch_bundler webpack --install-deps --no-uninstall
|
|
162
|
+
rake shakapacker:switch_bundler rspack -- --install-deps --no-uninstall
|
|
163
|
+
|
|
164
|
+
# Switch to rspack manually (you manage dependencies yourself)
|
|
165
|
+
rails shakapacker:switch_bundler rspack
|
|
166
|
+
rake shakapacker:switch_bundler rspack
|
|
167
|
+
|
|
168
|
+
# Switch back to webpack if needed
|
|
169
|
+
rails shakapacker:switch_bundler webpack --install-deps
|
|
170
|
+
rake shakapacker:switch_bundler webpack -- --install-deps
|
|
171
|
+
|
|
172
|
+
# Show help
|
|
173
|
+
rails shakapacker:switch_bundler --help
|
|
174
|
+
rake shakapacker:switch_bundler -- --help
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Note:** When using `rake`, you must use `--` to separate rake options from task arguments.
|
|
178
|
+
|
|
179
|
+
The task will:
|
|
180
|
+
|
|
181
|
+
- Update `config/shakapacker.yml` to switch the bundler
|
|
182
|
+
- Optionally install/uninstall npm dependencies with `--install-deps`
|
|
183
|
+
- Use `--no-uninstall` to skip uninstalling the old bundler's packages (faster switching, keeps both bundlers installed)
|
|
184
|
+
- Update `javascript_transpiler` to `swc` when switching to rspack (recommended)
|
|
185
|
+
- Preserve your config file comments and structure
|
|
186
|
+
|
|
187
|
+
**Custom Dependencies:** You can customize which dependencies are installed by creating a `.shakapacker-switch-bundler-dependencies.yml` file:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
rails shakapacker:switch_bundler --init-config
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Manual Migration Steps
|
|
194
|
+
|
|
195
|
+
If you prefer to migrate manually or need more control:
|
|
196
|
+
|
|
133
197
|
### Step 1: Update Dependencies
|
|
198
|
+
|
|
134
199
|
```bash
|
|
135
200
|
# Remove webpack dependencies
|
|
136
201
|
npm uninstall webpack webpack-cli webpack-dev-server
|
|
@@ -140,27 +205,33 @@ npm install --save-dev @rspack/core @rspack/cli
|
|
|
140
205
|
```
|
|
141
206
|
|
|
142
207
|
### Step 2: Update Configuration Files
|
|
208
|
+
|
|
143
209
|
1. Create `config/rspack/rspack.config.js` based on your webpack config
|
|
144
210
|
2. Update `config/shakapacker.yml`:
|
|
211
|
+
|
|
145
212
|
```yaml
|
|
146
|
-
assets_bundler:
|
|
213
|
+
assets_bundler: "rspack"
|
|
147
214
|
```
|
|
148
215
|
|
|
149
216
|
### Step 3: Replace Loaders
|
|
217
|
+
|
|
150
218
|
- Replace `babel-loader` with `builtin:swc-loader`
|
|
151
219
|
- Remove `file-loader`, `url-loader`, `raw-loader` - use asset modules
|
|
152
220
|
- Update CSS loaders to use Rspack's built-in support
|
|
153
221
|
|
|
154
222
|
### Step 4: Update Plugins
|
|
223
|
+
|
|
155
224
|
- Replace plugins with Rspack alternatives (see table above)
|
|
156
225
|
- Remove incompatible plugins
|
|
157
226
|
- Add Rspack-specific plugins as needed
|
|
158
227
|
|
|
159
228
|
### Step 5: TypeScript Setup
|
|
229
|
+
|
|
160
230
|
1. Add `isolatedModules: true` to `tsconfig.json`
|
|
161
231
|
2. Optional: Add `ts-checker-rspack-plugin` for type checking
|
|
162
232
|
|
|
163
233
|
### Step 6: Test Your Build
|
|
234
|
+
|
|
164
235
|
```bash
|
|
165
236
|
# Development build
|
|
166
237
|
bin/shakapacker
|
|
@@ -172,18 +243,22 @@ bin/shakapacker --mode production
|
|
|
172
243
|
## Common Issues and Solutions
|
|
173
244
|
|
|
174
245
|
### Issue: LimitChunkCountPlugin Error
|
|
246
|
+
|
|
175
247
|
**Error:** `Cannot read properties of undefined (reading 'tap')`
|
|
176
248
|
**Solution:** Remove `webpack.optimize.LimitChunkCountPlugin` and use `splitChunks` configuration instead.
|
|
177
249
|
|
|
178
250
|
### Issue: Missing Loaders
|
|
251
|
+
|
|
179
252
|
**Error:** Module parse errors
|
|
180
253
|
**Solution:** Check console logs for skipped loaders and install missing dependencies.
|
|
181
254
|
|
|
182
255
|
### Issue: CSS Extraction
|
|
256
|
+
|
|
183
257
|
**Error:** CSS not being extracted properly
|
|
184
258
|
**Solution:** Use `rspack.CssExtractRspackPlugin` instead of `mini-css-extract-plugin`.
|
|
185
259
|
|
|
186
260
|
### Issue: TypeScript Errors
|
|
261
|
+
|
|
187
262
|
**Error:** TypeScript compilation errors
|
|
188
263
|
**Solution:** Ensure `isolatedModules: true` is set in `tsconfig.json`.
|
|
189
264
|
|
|
@@ -194,9 +269,37 @@ bin/shakapacker --mode production
|
|
|
194
269
|
3. **Enable Caching:** Rspack has built-in persistent caching
|
|
195
270
|
4. **Use SWC:** The built-in SWC loader is significantly faster than Babel
|
|
196
271
|
|
|
272
|
+
## Debugging Configuration
|
|
273
|
+
|
|
274
|
+
To compare your webpack and rspack configurations during migration:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Export webpack configs before switching
|
|
278
|
+
bin/export-bundler-config --doctor
|
|
279
|
+
|
|
280
|
+
# Switch to rspack
|
|
281
|
+
rails shakapacker:switch_bundler rspack --install-deps
|
|
282
|
+
|
|
283
|
+
# Export rspack configs to compare
|
|
284
|
+
bin/export-bundler-config --doctor
|
|
285
|
+
|
|
286
|
+
# Compare the files in shakapacker-config-exports/
|
|
287
|
+
diff shakapacker-config-exports/webpack-production-client.yaml \
|
|
288
|
+
shakapacker-config-exports/rspack-production-client.yaml
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The config export utility creates annotated YAML files that make it easy to:
|
|
292
|
+
|
|
293
|
+
- Verify plugin replacements are correct
|
|
294
|
+
- Compare loader configurations
|
|
295
|
+
- Identify missing or different options
|
|
296
|
+
- Debug configuration issues
|
|
297
|
+
|
|
298
|
+
See the [Troubleshooting Guide](./troubleshooting.md#exporting-webpack--rspack-configuration) for more details.
|
|
299
|
+
|
|
197
300
|
## Resources
|
|
198
301
|
|
|
199
302
|
- [Rspack Documentation](https://rspack.rs)
|
|
200
303
|
- [Rspack Examples](https://github.com/rspack-contrib/rspack-examples)
|
|
201
304
|
- [Awesome Rspack](https://github.com/rspack-contrib/awesome-rspack)
|
|
202
|
-
- [Migration Guide](https://rspack.rs/guide/migration/webpack)
|
|
305
|
+
- [Migration Guide](https://rspack.rs/guide/migration/webpack)
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# JavaScript Transpiler Configuration
|
|
2
2
|
|
|
3
|
+
> 💡 **Quick Start**: For a concise guide to migrating from Babel to SWC, see [Common Upgrades Guide - Babel to SWC](./common-upgrades.md#migrating-from-babel-to-swc).
|
|
4
|
+
|
|
3
5
|
## Default Transpilers
|
|
4
6
|
|
|
5
7
|
Shakapacker uses different default JavaScript transpilers based on the bundler:
|
|
@@ -108,12 +110,31 @@ Typical build time improvements when migrating from Babel to SWC:
|
|
|
108
110
|
- [ ] Back up your current configuration
|
|
109
111
|
- [ ] Install SWC dependencies
|
|
110
112
|
- [ ] Update `shakapacker.yml`
|
|
113
|
+
- [ ] If using Stimulus, ensure `keepClassNames: true` is set in `config/swc.config.js` (automatically included in v9.1.0+)
|
|
111
114
|
- [ ] Test your build locally
|
|
112
115
|
- [ ] Run your test suite
|
|
113
116
|
- [ ] Check browser compatibility
|
|
114
117
|
- [ ] Deploy to staging environment
|
|
115
118
|
- [ ] Monitor for any runtime issues
|
|
116
119
|
|
|
120
|
+
#### Stimulus Compatibility
|
|
121
|
+
|
|
122
|
+
If you're using [Stimulus](https://stimulus.hotwired.dev/), you must configure SWC to preserve class names. See the [Using SWC with Stimulus](using_swc_loader.md#using-swc-with-stimulus) section for detailed instructions.
|
|
123
|
+
|
|
124
|
+
**Quick summary:** Add `keepClassNames: true` to your `config/swc.config.js`:
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
module.exports = {
|
|
128
|
+
options: {
|
|
129
|
+
jsc: {
|
|
130
|
+
keepClassNames: true // Required for Stimulus
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Starting with Shakapacker v9.1.0, running `rake shakapacker:migrate_to_swc` automatically creates a configuration with this setting.
|
|
137
|
+
|
|
117
138
|
### Rollback Plan
|
|
118
139
|
|
|
119
140
|
If you encounter issues, rolling back is simple:
|