shakapacker 9.1.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 +32 -1
- data/Gemfile.lock +1 -1
- data/README.md +21 -0
- data/bin/export-bundler-config +11 -0
- data/docs/deployment.md +52 -8
- data/docs/releasing.md +197 -0
- data/docs/rspack_migration_guide.md +28 -0
- data/docs/troubleshooting.md +124 -23
- 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 +7 -0
- data/lib/shakapacker/configuration.rb +28 -2
- data/lib/shakapacker/doctor.rb +16 -0
- data/lib/shakapacker/rspack_runner.rb +1 -1
- data/lib/shakapacker/runner.rb +1 -1
- 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/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-lock.json +2 -2
- data/package.json +2 -1
- data/yarn.lock +151 -360
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ac40ff5ddf8db373b1de0efaf805a033d7ba87641d84bde529669761b8e64d2
|
4
|
+
data.tar.gz: 5d0abb49ede8ad2aa37c94e9148e4def579c3eabb8c6e8d94a127796941ed559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5309f5d9beef93aaa0434e0e8ab93118545ecad507ade518ab56a332980d804536e36762670d21245d67d6c60e126367b1ea4edd8e4766daf20c294871ea1263
|
7
|
+
data.tar.gz: 4fb22afab6e203194018a1be9096aac472bffdbc08d58fc7a5b04a23c5e5d8c52084a17830d8ffb5156a6e4798de061f6f671474638616b7ffecd6c6348916f5
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -11,7 +11,38 @@
|
|
11
11
|
|
12
12
|
Changes since the last non-beta release.
|
13
13
|
|
14
|
-
|
14
|
+
## [v9.1.1] - October 9, 2025
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- **New config export utility for debugging webpack/rspack configurations** [PR #647](https://github.com/shakacode/shakapacker/pull/647) by [justin808](https://github.com/justin808).
|
19
|
+
- Adds `bin/export-bundler-config` utility with three modes:
|
20
|
+
- **Doctor mode** (`--doctor`): Exports all configs (dev + prod, client + server) to `shakapacker-config-exports/` directory - best for troubleshooting
|
21
|
+
- **Save mode** (`--save`): Export current environment configs to files
|
22
|
+
- **Stdout mode** (default): View configs in terminal
|
23
|
+
- **Output formats:** YAML (with optional inline documentation), JSON, or Node.js inspect
|
24
|
+
- **Smart features:**
|
25
|
+
- Environment isolation ensures dev/prod configs are truly different
|
26
|
+
- Auto-detects bundler from `shakapacker.yml`
|
27
|
+
- Pretty-prints functions (up to 50 lines)
|
28
|
+
- Validates bundler value and output paths
|
29
|
+
- Sanitizes filenames to prevent path traversal
|
30
|
+
- Helpful `.gitignore` suggestions
|
31
|
+
- **Usage:** `bin/export-bundler-config --doctor` or `bundle exec rake shakapacker:export_bundler_config`
|
32
|
+
- Works seamlessly with `rake shakapacker:switch_bundler` for comparing webpack vs rspack configs
|
33
|
+
- Lays groundwork for future config diff feature (tracked in [#667](https://github.com/shakacode/shakapacker/issues/667))
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
|
37
|
+
- Fixed NoMethodError when custom environment (e.g., staging) is not defined in shakapacker.yml. [PR #669](https://github.com/shakacode/shakapacker/pull/669) by [justin808](https://github.com/justin808).
|
38
|
+
- When deploying to environments like Heroku staging with `RAILS_ENV=staging`, shakapacker would crash with `undefined method 'deep_symbolize_keys' for nil:NilClass`
|
39
|
+
- **Configuration fallback:** Now properly falls back to production environment configuration (appropriate for staging)
|
40
|
+
- **NODE_ENV handling:** `bin/shakapacker` now automatically sets `NODE_ENV=production` for custom environments (staging, etc.)
|
41
|
+
- Previously: `RAILS_ENV=staging` would set `NODE_ENV=development`, breaking webpack optimizations
|
42
|
+
- Now: `RAILS_ENV` in `[development, test]` uses that value for `NODE_ENV`, everything else uses `production`
|
43
|
+
- Logs informational message when falling back to help with debugging
|
44
|
+
- This ensures shakapacker works with any Rails environment even if not explicitly defined in shakapacker.yml
|
45
|
+
- Fixes [#663](https://github.com/shakacode/shakapacker/issues/663)
|
15
46
|
|
16
47
|
## [v9.1.0] - October 8, 2025
|
17
48
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -767,6 +767,27 @@ Please note that if you want opt-in to use esbuild-loader, you can skip [React](
|
|
767
767
|
|
768
768
|
To switch between Babel, SWC, or esbuild, or to configure environment-specific transpiler settings, see the [Transpiler Migration Guide](./docs/transpiler-migration.md).
|
769
769
|
|
770
|
+
### Debugging Configuration
|
771
|
+
|
772
|
+
Shakapacker provides a powerful utility to export and analyze your webpack/rspack configuration:
|
773
|
+
|
774
|
+
```bash
|
775
|
+
# Export all configs for troubleshooting (recommended)
|
776
|
+
bin/export-bundler-config --doctor
|
777
|
+
|
778
|
+
# Or via rake task
|
779
|
+
bundle exec rake shakapacker:export_bundler_config -- --doctor
|
780
|
+
```
|
781
|
+
|
782
|
+
This exports development and production configurations for both client and server bundles to `shakapacker-config-exports/` directory in annotated YAML format. Perfect for:
|
783
|
+
|
784
|
+
- Debugging configuration issues
|
785
|
+
- Comparing webpack vs rspack configs (works with `rake shakapacker:switch_bundler`)
|
786
|
+
- Understanding differences between development and production
|
787
|
+
- Analyzing client vs server bundle configurations
|
788
|
+
|
789
|
+
For more options and usage examples, see the [Troubleshooting Guide](./docs/troubleshooting.md#exporting-webpack--rspack-configuration).
|
790
|
+
|
770
791
|
### Integrations
|
771
792
|
|
772
793
|
Shakapacker out of the box supports JS and static assets (fonts, images etc.) compilation. To enable support for CoffeeScript or TypeScript install relevant packages:
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
// Minimal shim - all logic is in the TypeScript module
|
4
|
+
const { run } = require('shakapacker/configExporter')
|
5
|
+
|
6
|
+
run(process.argv.slice(2))
|
7
|
+
.then((exitCode) => process.exit(exitCode))
|
8
|
+
.catch((error) => {
|
9
|
+
console.error(error.message)
|
10
|
+
process.exit(1)
|
11
|
+
})
|
data/docs/deployment.md
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
Shakapacker hooks up a new `shakapacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`.
|
4
4
|
If you are not using Sprockets `shakapacker:compile` is automatically aliased to `assets:precompile`.
|
5
5
|
|
6
|
-
```
|
7
|
-
|
8
6
|
## Heroku
|
9
7
|
|
10
8
|
In order for your Shakapacker app to run on Heroku, you'll need to do a bit of configuration before hand.
|
@@ -19,13 +17,59 @@ git push heroku master
|
|
19
17
|
|
20
18
|
We're essentially doing the following here:
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
- Creating an app on Heroku
|
21
|
+
- Creating a Postgres database for the app (this is assuming that you're using Heroku Postgres for your app)
|
22
|
+
- Adding the Heroku NodeJS and Ruby buildpacks for your app. This allows the `npm` or `yarn` executables to properly function when compiling your app - as well as Ruby.
|
23
|
+
- Pushing your code to Heroku and kicking off the deployment
|
26
24
|
|
27
25
|
Your production build process is responsible for installing your JavaScript dependencies before `rake assets:precompile`. For example, if you are on Heroku, the `heroku/nodejs` buildpack must run **prior** to the `heroku/ruby` buildpack for precompilation to run successfully.
|
28
26
|
|
27
|
+
### Custom Rails Environments (e.g., staging)
|
28
|
+
|
29
|
+
**Key distinction:**
|
30
|
+
|
31
|
+
- **RAILS_ENV** is used to look up configuration in `config/shakapacker.yml`
|
32
|
+
- **NODE_ENV** is used by your `webpack.config.js` (or `rspack.config.js`) for build optimizations
|
33
|
+
|
34
|
+
**Good news:** As of this version, `bin/shakapacker` automatically sets `NODE_ENV=production` for custom environments like staging:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
# NODE_ENV automatically set to 'production' for staging
|
38
|
+
RAILS_ENV=staging bin/shakapacker
|
39
|
+
|
40
|
+
# Also works with rake task
|
41
|
+
RAILS_ENV=staging bundle exec rails assets:precompile
|
42
|
+
```
|
43
|
+
|
44
|
+
**How it works:**
|
45
|
+
|
46
|
+
- `RAILS_ENV=development` → `NODE_ENV=development`
|
47
|
+
- `RAILS_ENV=test` → `NODE_ENV=test`
|
48
|
+
- `RAILS_ENV=production` → `NODE_ENV=production`
|
49
|
+
- Any other custom env → `NODE_ENV=production`
|
50
|
+
|
51
|
+
**Configuration fallback:**
|
52
|
+
|
53
|
+
You don't need to add custom environments to your `shakapacker.yml`. Shakapacker automatically falls back to production-like defaults:
|
54
|
+
|
55
|
+
1. First, it looks for the environment you're deploying to (e.g., `staging`)
|
56
|
+
2. If not found, it falls back to `production` configuration
|
57
|
+
|
58
|
+
This means staging environments automatically use production settings (compile: false, cache_manifest: true, etc.).
|
59
|
+
|
60
|
+
**Optional: Staging-specific configuration**
|
61
|
+
|
62
|
+
If you want different settings for staging, explicitly add a `staging` section:
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
staging:
|
66
|
+
<<: *default
|
67
|
+
compile: false
|
68
|
+
cache_manifest: true
|
69
|
+
# Staging-specific overrides (e.g., different output path)
|
70
|
+
public_output_path: packs-staging
|
71
|
+
```
|
72
|
+
|
29
73
|
## Nginx
|
30
74
|
|
31
75
|
Shakapacker doesn't serve anything in production. You’re expected to configure your web server to serve files in public/ directly.
|
@@ -117,10 +161,10 @@ namespace :deploy do
|
|
117
161
|
desc "Run rake js install"
|
118
162
|
task :js_install do
|
119
163
|
require "package_json"
|
120
|
-
|
164
|
+
|
121
165
|
# this will use the package manager specified via `packageManager`, or otherwise fallback to `npm`
|
122
166
|
native_js_install_command = PackageJson.read.manager.native_install_command(frozen: true).join(" ")
|
123
|
-
|
167
|
+
|
124
168
|
on roles(:web) do
|
125
169
|
within release_path do
|
126
170
|
execute("cd #{release_path} && #{native_js_install_command}")
|
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
|
@@ -269,6 +269,34 @@ bin/shakapacker --mode production
|
|
269
269
|
3. **Enable Caching:** Rspack has built-in persistent caching
|
270
270
|
4. **Use SWC:** The built-in SWC loader is significantly faster than Babel
|
271
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
|
+
|
272
300
|
## Resources
|
273
301
|
|
274
302
|
- [Rspack Documentation](https://rspack.rs)
|