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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +108 -11
  4. data/Gemfile.lock +1 -1
  5. data/README.md +182 -107
  6. data/bin/export-bundler-config +11 -0
  7. data/docs/common-upgrades.md +615 -0
  8. data/docs/deployment.md +52 -8
  9. data/docs/releasing.md +197 -0
  10. data/docs/rspack_migration_guide.md +120 -17
  11. data/docs/transpiler-migration.md +21 -0
  12. data/docs/troubleshooting.md +124 -23
  13. data/docs/typescript-migration.md +2 -1
  14. data/docs/using_swc_loader.md +108 -8
  15. data/docs/v9_upgrade.md +45 -0
  16. data/lib/install/bin/export-bundler-config +11 -0
  17. data/lib/install/bin/shakapacker +1 -1
  18. data/lib/install/bin/shakapacker-dev-server +1 -1
  19. data/lib/shakapacker/bundler_switcher.rb +329 -0
  20. data/lib/shakapacker/configuration.rb +28 -2
  21. data/lib/shakapacker/doctor.rb +65 -4
  22. data/lib/shakapacker/rspack_runner.rb +1 -1
  23. data/lib/shakapacker/runner.rb +1 -1
  24. data/lib/shakapacker/swc_migrator.rb +14 -6
  25. data/lib/shakapacker/version.rb +1 -1
  26. data/lib/shakapacker/webpack_runner.rb +1 -1
  27. data/lib/shakapacker.rb +10 -0
  28. data/lib/tasks/shakapacker/export_bundler_config.rake +72 -0
  29. data/lib/tasks/shakapacker/switch_bundler.rake +82 -0
  30. data/lib/tasks/shakapacker.rake +2 -1
  31. data/package/configExporter/cli.ts +683 -0
  32. data/package/configExporter/configDocs.ts +102 -0
  33. data/package/configExporter/fileWriter.ts +92 -0
  34. data/package/configExporter/index.ts +5 -0
  35. data/package/configExporter/types.ts +36 -0
  36. data/package/configExporter/yamlSerializer.ts +266 -0
  37. data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +30 -0
  38. data/package/environments/types.ts +22 -14
  39. data/package/index.ts +12 -9
  40. data/package/swc/index.ts +5 -3
  41. data/package/types/README.md +2 -1
  42. data/package/types/index.ts +1 -0
  43. data/package/utils/debug.ts +5 -5
  44. data/package-lock.json +13047 -0
  45. data/package.json +7 -1
  46. data/yarn.lock +261 -389
  47. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4cfe1097512ba4c08cc57b061192f0bb0ad8d5d41a508a5f978068d447eae8c
4
- data.tar.gz: 9dfe66dc0d435f1b045bb51455869fb7da0008055e9d062673b666722a360221
3
+ metadata.gz: 5ac40ff5ddf8db373b1de0efaf805a033d7ba87641d84bde529669761b8e64d2
4
+ data.tar.gz: 5d0abb49ede8ad2aa37c94e9148e4def579c3eabb8c6e8d94a127796941ed559
5
5
  SHA512:
6
- metadata.gz: f09b82882e96e0867be91135dda3eff2d77b629571d4ff7fde8b2a6c4748cb9749ce9e6a80c47ec117b083ef79734d23b99ddb971950f941c328b52877277ccb
7
- data.tar.gz: c19b394a110cd6beebe23715af218fbc932d5052498911ea51824a790c917a4d7fbd76ed92b3144d5d605e886a648b6d05c27b179dacc097fee5936446a1ce65
6
+ metadata.gz: 5309f5d9beef93aaa0434e0e8ab93118545ecad507ade518ab56a332980d804536e36762670d21245d67d6c60e126367b1ea4edd8e4766daf20c294871ea1263
7
+ data.tar.gz: 4fb22afab6e203194018a1be9096aac472bffdbc08d58fc7a5b04a23c5e5d8c52084a17830d8ffb5156a6e4798de061f6f671474638616b7ffecd6c6348916f5
data/.gitignore CHANGED
@@ -16,6 +16,9 @@ gemfiles/*.lock
16
16
  .yalc
17
17
  yalc.lock
18
18
 
19
+ # Config exporter output directory
20
+ shakapacker-config-exports/
21
+
19
22
  # TypeScript generated files
20
23
  package/**/*.d.ts
21
24
  package/**/*.d.ts.map
data/CHANGELOG.md CHANGED
@@ -11,11 +11,105 @@
11
11
 
12
12
  Changes since the last non-beta release.
13
13
 
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)
46
+
47
+ ## [v9.1.0] - October 8, 2025
48
+
49
+ **⚠️ IMPORTANT:** This release includes a breaking change for SWC users. Please see the [v9 Upgrade Guide - SWC Loose Mode Breaking Change](./docs/v9_upgrade.md#swc-loose-mode-breaking-change-v910) for migration details.
50
+
51
+ ### ⚠️ Breaking Changes
52
+
53
+ - **SWC default configuration now uses `loose: false` for spec-compliant transforms** ([#658](https://github.com/shakacode/shakapacker/pull/658))
54
+ - Previously, Shakapacker set `loose: true` by default in SWC configuration, which caused:
55
+ - Silent failures with Stimulus controllers
56
+ - Incorrect behavior with spread operators on iterables (e.g., `[...new Set()]`)
57
+ - Deviation from both SWC and Babel upstream defaults
58
+ - Now defaults to `loose: false`, matching SWC's default and fixing compatibility with Stimulus
59
+ - This aligns with the previous fix to Babel configuration in [PR #107](https://github.com/shakacode/shakapacker/pull/107)
60
+ - **Migration:** Most projects need no changes as the new default provides spec-compliant behavior. Projects with Stimulus will benefit from this fix. See [v9 Upgrade Guide - SWC Loose Mode](./docs/v9_upgrade.md#swc-loose-mode-breaking-change-v910) for details
61
+ - If you must restore the old behavior (not recommended), add to `config/swc.config.js`:
62
+ ```javascript
63
+ module.exports = {
64
+ options: {
65
+ jsc: {
66
+ // Only use this if you have code that requires loose transforms.
67
+ // This provides slightly faster build performance but may cause runtime bugs.
68
+ loose: true // Restore v9.0.0 behavior
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Added
75
+
76
+ - **New `shakapacker:switch_bundler` rake task** for easy switching between webpack and rspack
77
+ - Automatically updates `config/shakapacker.yml` to switch bundler configuration
78
+ - Optional `--install-deps` flag to automatically manage dependencies
79
+ - `--no-uninstall` flag for faster switching by keeping both bundlers installed
80
+ - **Supports all package managers**: Auto-detects and uses npm, yarn, pnpm, or bun
81
+ - Shows clear list of packages being added/removed during dependency management
82
+ - Support for custom dependency configuration via `.shakapacker-switch-bundler-dependencies.yml`
83
+ - Includes SWC dependencies (`@swc/core`, `swc-loader`) in default webpack setup
84
+ - Preserves config file structure and comments during updates
85
+ - Updates `javascript_transpiler` to `swc` when switching to rspack (recommended)
86
+ - Ruby 2.7+ compatible YAML loading with proper alias/anchor support
87
+ - Secure command execution (prevents shell injection)
88
+ - Usage: `rails shakapacker:switch_bundler [webpack|rspack] [--install-deps] [--no-uninstall]`
89
+ - See rake task help: `rails shakapacker:switch_bundler --help`
90
+ - **Stimulus compatibility built into SWC migration** ([#658](https://github.com/shakacode/shakapacker/pull/658))
91
+ - `rake shakapacker:migrate_to_swc` now creates `config/swc.config.js` with `keepClassNames: true`
92
+ - Prevents SWC from mangling class names, which breaks Stimulus controller discovery
93
+ - Includes React Fast Refresh configuration by default
94
+ - **Comprehensive Stimulus documentation** for SWC users ([#658](https://github.com/shakacode/shakapacker/pull/658))
95
+ - Added "Using SWC with Stimulus" section to [docs/using_swc_loader.md](./docs/using_swc_loader.md#using-swc-with-stimulus)
96
+ - Documents symptoms of missing configuration (silent failures)
97
+ - Explains common errors like `env` and `jsc.target` conflicts
98
+ - Added Stimulus compatibility checklist to migration guide
99
+ - **Enhanced `rake shakapacker:doctor` for SWC configuration validation** ([#658](https://github.com/shakacode/shakapacker/pull/658))
100
+ - Detects `loose: true` in config and warns about potential issues
101
+ - Detects missing `keepClassNames: true` when Stimulus is installed
102
+ - Detects conflicting `jsc.target` and `env` configuration
103
+ - Provides actionable warnings with links to documentation
104
+
14
105
  ### Fixed
15
106
 
16
- - Fixed NODE_ENV defaulting to production breaking dev server ([Issue 631](https://github.com/shakacode/shakapacker/issues/631)). NODE_ENV now defaults to development unless RAILS_ENV is explicitly set to production. This ensures the dev server works out of the box without requiring NODE_ENV to be set, and fixes incorrect port and 404 asset errors.
107
+ - Fixed `rake shakapacker:migrate_to_swc` to correctly set `javascript_transpiler: "swc"` instead of unused `swc: true` flag ([#659](https://github.com/shakacode/shakapacker/pull/659))
108
+ - The migration now properly configures SWC as the transpiler
109
+ - Users who previously ran the migration should update their `config/shakapacker.yml` to use `javascript_transpiler: "swc"` instead of `swc: true`
110
+ - Restore `RspackPlugin` type as an alias to `RspackPluginInstance` for backward compatibility. The type is now deprecated in favor of `RspackPluginInstance`. [#650](https://github.com/shakacode/shakapacker/issues/650)
17
111
 
18
- ## [v9.0.0-beta.8] - October 3, 2025
112
+ ## [v9.0.0] - October 5, 2025
19
113
 
20
114
  See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/docs/v9_upgrade.md) for detailed migration instructions.
21
115
 
@@ -26,7 +120,7 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
26
120
  - Babel dependencies are no longer included as peer dependencies
27
121
  - Improves compilation speed by 20x
28
122
  - **Migration for existing projects:**
29
- - **Option 1 (Recommended):** Switch to SWC - Run `rake shakapacker:migrate:to_swc` or manually:
123
+ - **Option 1 (Recommended):** Switch to SWC - Run `rake shakapacker:migrate_to_swc` or manually:
30
124
  ```yaml
31
125
  # config/shakapacker.yml
32
126
  javascript_transpiler: "swc"
@@ -38,7 +132,7 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
38
132
  javascript_transpiler: "babel"
39
133
  ```
40
134
 
41
- 2. **CSS Modules now use named exports by default**
135
+ 2. **CSS Modules now use named exports by default** ([PR 599](https://github.com/shakacode/shakapacker/pull/599))
42
136
 
43
137
  - **JavaScript:** Use named imports: `import { className } from './styles.module.css'`
44
138
  - **TypeScript:** Use namespace imports: `import * as styles from './styles.module.css'`
@@ -50,19 +144,20 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
50
144
 
51
145
  ### Added
52
146
 
53
- - **Rspack support** as an alternative assets bundler to webpack
147
+ - **Rspack support** as an alternative assets bundler to webpack ([PR 589](https://github.com/shakacode/shakapacker/pull/589), [PR 590](https://github.com/shakacode/shakapacker/pull/590))
54
148
  - Configure `assets_bundler: 'rspack'` in `shakapacker.yml`
55
149
  - Faster Rust-based bundling with webpack-compatible APIs
56
150
  - Built-in SWC loader and CSS extraction
57
151
  - Automatic bundler detection in `bin/shakapacker`
58
- - **TypeScript type definitions** for improved IDE support and autocomplete
152
+ - **TypeScript type definitions** for improved IDE support and autocomplete ([PR 602](https://github.com/shakacode/shakapacker/pull/602))
59
153
  - Types available via `import type { WebpackConfig, RspackConfig, EnvironmentConfig } from "shakapacker/types"`
154
+ - Installer automatically creates TypeScript config files when `tsconfig.json` is detected ([PR 633](https://github.com/shakacode/shakapacker/pull/633))
60
155
  - See [TypeScript Documentation](./docs/typescript.md) for migration and usage instructions
61
- - **Optional peer dependencies** - All peer dependencies now marked as optional, preventing installation warnings while maintaining version compatibility tracking
156
+ - **Optional peer dependencies** - All peer dependencies now marked as optional, preventing installation warnings while maintaining version compatibility tracking ([PR 603](https://github.com/shakacode/shakapacker/pull/603))
62
157
  - **Private output path** for server-side rendering bundles ([PR 592](https://github.com/shakacode/shakapacker/pull/592))
63
158
  - Configure `private_output_path` for private server bundles separate from public assets
64
- - **`rake shakapacker:doctor` diagnostic command** to check for configuration issues and missing dependencies
65
- - **`rake shakapacker:migrate:to_swc`** migration helper to assist with switching from Babel to SWC
159
+ - **`rake shakapacker:doctor` diagnostic command** to check for configuration issues and missing dependencies ([PR 609](https://github.com/shakacode/shakapacker/pull/609))
160
+ - **`rake shakapacker:migrate_to_swc`** migration helper to assist with switching from Babel to SWC ([PR 613](https://github.com/shakacode/shakapacker/pull/613), [PR 635](https://github.com/shakacode/shakapacker/pull/635))
66
161
 
67
162
  ### Security
68
163
 
@@ -75,6 +170,8 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
75
170
 
76
171
  ### Fixed
77
172
 
173
+ - Fixed NODE_ENV defaulting to production breaking dev server ([PR 632](https://github.com/shakacode/shakapacker/pull/632)). NODE_ENV now defaults to development unless RAILS_ENV is explicitly set to production. This ensures the dev server works out of the box without requiring NODE_ENV to be set.
174
+ - Fixed SWC migration to use `config/swc.config.js` instead of `.swcrc` ([PR 635](https://github.com/shakacode/shakapacker/pull/635)). The `.swcrc` file bypasses webpack-merge and overrides Shakapacker's defaults, while `config/swc.config.js` properly merges with defaults.
78
175
  - Fixed private_output_path configuration edge cases ([PR 604](https://github.com/shakacode/shakapacker/pull/604))
79
176
  - Updated webpack-dev-server to secure versions (^4.15.2 || ^5.2.2) ([PR 585](https://github.com/shakacode/shakapacker/pull/585))
80
177
 
@@ -569,8 +666,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
569
666
 
570
667
  See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
571
668
 
572
- [Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0-beta.8...main
573
- [v9.0.0-beta.8]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0-beta.8
669
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0...main
670
+ [v9.0.0]: https://github.com/shakacode/shakapacker/compare/v8.4.0...v9.0.0
574
671
  [v8.4.0]: https://github.com/shakacode/shakapacker/compare/v8.3.0...v8.4.0
575
672
  [v8.3.0]: https://github.com/shakacode/shakapacker/compare/v8.2.0...v8.3.0
576
673
  [v8.2.0]: https://github.com/shakacode/shakapacker/compare/v8.1.0...v8.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (9.0.0)
4
+ shakapacker (9.2.0)
5
5
  activesupport (>= 5.2)
6
6
  package_json
7
7
  rack-proxy (>= 0.6.1)