shakapacker 9.0.0.beta.9 → 9.0.0.beta.11
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 +98 -16
- data/Gemfile.lock +1 -1
- data/docs/transpiler-migration.md +33 -36
- data/docs/v9_upgrade.md +80 -26
- data/lib/shakapacker/doctor.rb +10 -11
- data/lib/shakapacker/swc_migrator.rb +64 -38
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker.rb +1 -1
- data/package/env.ts +25 -13
- data/package.json +1 -1
- data/test/package/config.test.js +3 -0
- data/test/package/env.test.js +42 -7
- data/test/package/environments/base.test.js +4 -0
- data/test/package/staging.test.js +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e0621d94ac8535638e4678fba06be1449ec6c5705dfd94877866344f9b4784f
|
|
4
|
+
data.tar.gz: 7727840c175b5b5a710e6f74d5f69b0ad6bbd4a810ec180b38218f2ab435f062
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 126010b0c2bcf735ff324f38a4bddc93435540f543b17c233112535696bfcb0f8005aef1a55563a7cf1526ac5fa4248c9dd6c7e3d04fd17d44348d7b5e9e3f34
|
|
7
|
+
data.tar.gz: cd8fa6305ed923e30421ef5e427118bfe2d6fcdd3a592c673af5e25340ac047aa34e3fa30b6fe66dfde0e6054b16cf03d48b6d2701b4830cf5164360331052f7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
- For the changelog of versions prior to v6, see the [5.x stable branch of rails/webpacker](https://github.com/rails/webpacker/tree/5-x-stable).
|
|
2
|
+
- **Please see the [v9 Upgrade Guide](./docs/v9_upgrade.md) for upgrading to version 9 and accounting for breaking changes.**
|
|
3
|
+
- Please see the [v8 Upgrade Guide](./docs/v8_upgrade.md) for upgrading to version 8 and accounting for breaking changes.
|
|
4
|
+
- Please see the [v7 Upgrade Guide](./docs/v7_upgrade.md) for upgrading to new spelling in version 7.
|
|
5
|
+
- Please see the [v6 Upgrade Guide](./docs/v6_upgrade.md) to go from versions prior to v6.
|
|
6
|
+
- [ShakaCode](https://www.shakacode.com) offers support for upgrading from Webpacker or using Shakapacker. If interested, contact Justin Gordon, [justin@shakacode.com](mailto:justin@shakacode.com).
|
|
7
7
|
|
|
8
8
|
# Versions
|
|
9
|
+
|
|
9
10
|
## [Unreleased]
|
|
11
|
+
|
|
10
12
|
Changes since the last non-beta release.
|
|
11
13
|
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
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.
|
|
17
|
+
|
|
12
18
|
## [v9.0.0-beta.8] - October 3, 2025
|
|
13
19
|
|
|
14
20
|
See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/docs/v9_upgrade.md) for detailed migration instructions.
|
|
@@ -16,22 +22,24 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
16
22
|
### ⚠️ Breaking Changes
|
|
17
23
|
|
|
18
24
|
1. **SWC is now the default JavaScript transpiler instead of Babel** ([PR 603](https://github.com/shakacode/shakapacker/pull/603) by [justin808](https://github.com/justin808))
|
|
25
|
+
|
|
19
26
|
- Babel dependencies are no longer included as peer dependencies
|
|
20
27
|
- Improves compilation speed by 20x
|
|
21
28
|
- **Migration for existing projects:**
|
|
22
29
|
- **Option 1 (Recommended):** Switch to SWC - Run `rake shakapacker:migrate:to_swc` or manually:
|
|
23
30
|
```yaml
|
|
24
31
|
# config/shakapacker.yml
|
|
25
|
-
javascript_transpiler:
|
|
32
|
+
javascript_transpiler: "swc"
|
|
26
33
|
```
|
|
27
34
|
Then install: `npm install @swc/core swc-loader`
|
|
28
35
|
- **Option 2:** Keep using Babel:
|
|
29
36
|
```yaml
|
|
30
37
|
# config/shakapacker.yml
|
|
31
|
-
javascript_transpiler:
|
|
38
|
+
javascript_transpiler: "babel"
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
2. **CSS Modules now use named exports by default**
|
|
42
|
+
|
|
35
43
|
- **JavaScript:** Use named imports: `import { className } from './styles.module.css'`
|
|
36
44
|
- **TypeScript:** Use namespace imports: `import * as styles from './styles.module.css'`
|
|
37
45
|
- To keep the old behavior with default imports, see [CSS Modules Export Mode documentation](./docs/css-modules-export-mode.md) for configuration instructions
|
|
@@ -41,6 +49,7 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
41
49
|
- Old `webpack_loader` option deprecated but still supported with warning
|
|
42
50
|
|
|
43
51
|
### Added
|
|
52
|
+
|
|
44
53
|
- **Rspack support** as an alternative assets bundler to webpack
|
|
45
54
|
- Configure `assets_bundler: 'rspack'` in `shakapacker.yml`
|
|
46
55
|
- Faster Rust-based bundling with webpack-compatible APIs
|
|
@@ -56,6 +65,7 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
56
65
|
- **`rake shakapacker:migrate:to_swc`** migration helper to assist with switching from Babel to SWC
|
|
57
66
|
|
|
58
67
|
### Security
|
|
68
|
+
|
|
59
69
|
- **Path Validation Utilities** ([PR 614](https://github.com/shakacode/shakapacker/pull/614) by [justin808](https://github.com/justin808))
|
|
60
70
|
- Added validation to prevent directory traversal attacks
|
|
61
71
|
- Implemented environment variable sanitization to prevent injection
|
|
@@ -64,19 +74,22 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
64
74
|
- Path traversal security checks now run regardless of validation mode
|
|
65
75
|
|
|
66
76
|
### Fixed
|
|
77
|
+
|
|
67
78
|
- Fixed private_output_path configuration edge cases ([PR 604](https://github.com/shakacode/shakapacker/pull/604))
|
|
68
79
|
- Updated webpack-dev-server to secure versions (^4.15.2 || ^5.2.2) ([PR 585](https://github.com/shakacode/shakapacker/pull/585))
|
|
69
80
|
|
|
70
81
|
## [v8.4.0] - September 8, 2024
|
|
71
82
|
|
|
72
83
|
### Added
|
|
84
|
+
|
|
73
85
|
- Support for subresource integrity. [PR 570](https://github.com/shakacode/shakapacker/pull/570) by [panagiotisplytas](https://github.com/panagiotisplytas).
|
|
74
86
|
|
|
75
87
|
### Fixed
|
|
76
|
-
- Install the latest major version of peer dependencies [PR 576](https://github.com/shakacode/shakapacker/pull/576) by [G-Rath](https://github.com/g-rath).
|
|
77
88
|
|
|
89
|
+
- Install the latest major version of peer dependencies [PR 576](https://github.com/shakacode/shakapacker/pull/576) by [G-Rath](https://github.com/g-rath).
|
|
78
90
|
|
|
79
91
|
## [v8.3.0] - April 28, 2024
|
|
92
|
+
|
|
80
93
|
### Added
|
|
81
94
|
|
|
82
95
|
- Allow `webpack-assets-manifest` v6. [PR 562](https://github.com/shakacode/shakapacker/pull/562) by [tagliala](https://github.com/tagliala), [shoeyn](https://github.com/shoeyn).
|
|
@@ -91,6 +104,7 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
91
104
|
- More precise types for `devServer` and `rules` in the configuration. [PR 555](https://github.com/shakacode/shakapacker/pull/555) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
|
|
92
105
|
|
|
93
106
|
## [v8.2.0] - March 12, 2025
|
|
107
|
+
|
|
94
108
|
### Added
|
|
95
109
|
|
|
96
110
|
- Support for `async` attribute in `javascript_pack_tag`, `append_javascript_pack_tag`, and `prepend_javascript_pack_tag`. [PR 554](https://github.com/shakacode/shakapacker/pull/554) by [AbanoubGhadban](https://github.com/abanoubghadban).
|
|
@@ -103,21 +117,25 @@ See the [v9 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
103
117
|
- Allow `webpack-cli` v6. [PR 533](https://github.com/shakacode/shakapacker/pull/533) by [tagliala](https://github.com/tagliala).
|
|
104
118
|
|
|
105
119
|
### Changed
|
|
120
|
+
|
|
106
121
|
- Changed internal `require`s to `require_relative` to make code less dependent on the load path. [PR 516](https://github.com/shakacode/shakapacker/pull/516) by [tagliala](https://github.com/tagliala).
|
|
107
122
|
- Allow configuring webpack from a Typescript file (`config/webpack/webpack.config.ts`). [PR 524](https://github.com/shakacode/shakapacker/pull/524) by [jdelStrother](https://github.com/jdelStrother).
|
|
108
123
|
|
|
109
124
|
### Fixed
|
|
125
|
+
|
|
110
126
|
- Fix error when rails environment is required from outside the rails root directory [PR 520](https://github.com/shakacode/shakapacker/pull/520)
|
|
111
127
|
|
|
112
128
|
## [v8.0.2] - August 28, 2024
|
|
113
129
|
|
|
114
130
|
### Fixed
|
|
131
|
+
|
|
115
132
|
- Fix wrong instruction in esbuild loader documentation [PR 504](https://github.com/shakacode/shakapacker/pull/504) by [adriangohjw](https://github.com/adriangohjw).
|
|
116
133
|
- Add logic to sass rule conditional on sass-loader version [PR 508](https://github.com/shakacode/shakapacker/pull/508) by [Judahmeek](https://github.com/Judahmeek).
|
|
117
134
|
|
|
118
135
|
## [v8.0.1] - July 10, 2024
|
|
119
136
|
|
|
120
137
|
### Changed
|
|
138
|
+
|
|
121
139
|
- Update outdated GitHub Actions to use Node.js 20.0 versions instead [PR 497](https://github.com/shakacode/shakapacker/pull/497) by [adriangohjw](https://github.com/adriangohjw).
|
|
122
140
|
- Allow `webpack-merge` v6 to be used [PR 502](https://github.com/shakacode/shakapacker/pull/502) by [G-Rath](https://github.com/g-rath).
|
|
123
141
|
|
|
@@ -178,71 +196,89 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
178
196
|
|
|
179
197
|
- Remove `isArray` utility (just use `Array.isArray` directly) and renamed a few files [PR 454](https://github.com/shakacode/shakapacker/pull/454) by [G-Rath](https://github.com/g-rath).
|
|
180
198
|
|
|
181
|
-
- Make JavaScript test helper utilities internal (`chdirTestApp`, `chdirCwd`, `resetEnv`)
|
|
199
|
+
- Make JavaScript test helper utilities internal (`chdirTestApp`, `chdirCwd`, `resetEnv`) [PR 458](https://github.com/shakacode/shakapacker/pull/458) by [G-Rath](https://github.com/g-rath).
|
|
182
200
|
|
|
183
201
|
## [v7.2.3] - March 23, 2024
|
|
184
202
|
|
|
185
203
|
### Added
|
|
204
|
+
|
|
186
205
|
- Emit warnings instead of errors when compilation is success but stderr is not empty. [PR 416](https://github.com/shakacode/shakapacker/pull/416) by [n-rodriguez](https://github.com/n-rodriguez).
|
|
187
206
|
- Allow `webpack-dev-server` v5. [PR 418](https://github.com/shakacode/shakapacker/pull/418) by [G-Rath](https://github.com/g-rath)
|
|
188
207
|
|
|
189
208
|
### Removed
|
|
209
|
+
|
|
190
210
|
- Removes dependency on `glob` library. [PR 435](https://github.com/shakacode/shakapacker/pull/435) by [tomdracz](https://github.com/tomdracz).
|
|
191
211
|
|
|
192
212
|
### Fixed
|
|
213
|
+
|
|
193
214
|
- Uses config file passed in `SHAKAPACKER_CONFIG` consistently.[PR 448](https://github.com/shakacode/shakapacker/pull/448) by [tomdracz](https://github.com/tomdracz).
|
|
194
215
|
|
|
195
|
-
|
|
216
|
+
Previously this could have been ignored in few code branches, especially when checking for available environments.
|
|
196
217
|
|
|
197
218
|
## [v7.2.2] - January 19, 2024
|
|
198
219
|
|
|
199
220
|
### Added
|
|
221
|
+
|
|
200
222
|
- Allow `compression-webpack-plugin` v11. [PR 406](https://github.com/shakacode/shakapacker/pull/406) by [tagliala](https://github.com/tagliala).
|
|
201
223
|
|
|
202
224
|
## [v7.2.1] - December 30, 2023
|
|
203
225
|
|
|
204
226
|
### Fixed
|
|
227
|
+
|
|
205
228
|
- Show deprecation message for `relative_url_root` only if it is set. [PR 400](https://github.com/shakacode/shakapacker/pull/400) by [ahangarha](https://github.com/ahangarha).
|
|
206
229
|
|
|
207
230
|
## [v7.2.0] - December 28, 2023
|
|
208
231
|
|
|
209
232
|
### Added
|
|
233
|
+
|
|
210
234
|
- Experimental support for other JS package managers using `package_json` gem [PR 349](https://github.com/shakacode/shakapacker/pull/349) by [G-Rath](https://github.com/g-rath).
|
|
211
235
|
- Support `hmr: only` configuration [PR 378](https://github.com/shakacode/shakapacker/pull/378) by [SimenB](https://github.com/SimenB).
|
|
212
236
|
- Use `config/shakapacker.yml` as the secondary source for `asset_host` and `relative_url_root` configurations [PR 376](https://github.com/shakacode/shakapacker/pull/376) by [ahangarha](https://github.com/ahangarha).
|
|
213
237
|
|
|
214
238
|
### Fixed
|
|
239
|
+
|
|
215
240
|
- Recommend `server` option instead of the deprecated `https` option when `--https` is provided [PR 380](https://github.com/shakacode/shakapacker/pull/380) by [G-Rath](https://github.com/g-rath)
|
|
216
241
|
- Recompile assets on asset host change [PR 364](https://github.com/shakacode/shakapacker/pull/364) by [ahangarha](https://github.com/ahangarha).
|
|
217
242
|
- Add deprecation warning for `https` option in `shakapacker.yml` (use `server: 'https'` instead) [PR 382](https://github.com/shakacode/shakapacker/pull/382) by [G-Rath](https://github.com/g-rath).
|
|
218
243
|
- Disable Hot Module Replacement in `webpack-dev-server` when `hmr: false` [PR 392](https://github.com/shakacode/shakapacker/pull/392) by [thedanbob](https://github.com/thedanbob).
|
|
219
244
|
|
|
220
245
|
### Deprecated
|
|
246
|
+
|
|
221
247
|
- The usage of `relative_url_root` is deprecated in Shakapacker and will be removed in v8. [PR 376](https://github.com/shakacode/shakapacker/pull/376) by [ahangarha](https://github.com/ahangarha).
|
|
222
248
|
|
|
223
249
|
## [v7.1.0] - September 30, 2023
|
|
224
250
|
|
|
225
251
|
### Added
|
|
252
|
+
|
|
226
253
|
- Support passing custom webpack config directly to `generateWebpackConfig` for merging [PR 343](https://github.com/shakacode/shakapacker/pull/343) by [G-Rath](https://github.com/g-rath).
|
|
227
254
|
|
|
228
255
|
### Fixed
|
|
256
|
+
|
|
229
257
|
- Use `NODE_OPTIONS` to enable Node-specific debugging flags [PR 350](https://github.com/shakacode/shakapacker/pull/350).
|
|
230
258
|
- Add the boilerplate `application.js` into `packs/` [PR 363](https://github.com/shakacode/shakapacker/pull/363).
|
|
231
259
|
|
|
232
260
|
## [v7.0.3] - July 7, 2023
|
|
261
|
+
|
|
233
262
|
### Fixed
|
|
263
|
+
|
|
234
264
|
- Fixed commands execution for projects with space in the absolute path [PR 322](https://github.com/shakacode/shakapacker/pull/322) by [kukicola](https://github.com/kukicola).
|
|
235
265
|
|
|
236
266
|
## [v7.0.2] - July 3, 2023
|
|
267
|
+
|
|
237
268
|
### Fixed
|
|
269
|
+
|
|
238
270
|
- Fixed creation of assets:precompile if it is missing [PR 325](https://github.com/shakacode/shakapacker/pull/325) by [ahangarha](https://github.com/ahangarha).
|
|
239
271
|
|
|
240
272
|
## [v7.0.1] - June 27, 2023
|
|
273
|
+
|
|
241
274
|
### Fixed
|
|
275
|
+
|
|
242
276
|
- Fixed the condition for showing warning for setting `useContentHash` to `false` in the production environment. [PR 320](https://github.com/shakacode/shakapacker/pull/320) by [ahangarha](https://github.com/ahangarha).
|
|
243
277
|
|
|
244
278
|
## [v7.0.0] - June 23, 2023
|
|
279
|
+
|
|
245
280
|
### Breaking changes
|
|
281
|
+
|
|
246
282
|
- Removes defaults passed to `@babel/preset-typescript`. [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
|
|
247
283
|
|
|
248
284
|
`@babel/preset-typescript` has been initialised in default configuration with `{ allExtensions: true, isTSX: true }` - meaning every file in the codebase was treated as TSX leading to potential issues. This has been removed and returns to sensible default of the preset which is to figure out the file type from the extensions. This change might affect generated output however so it is marked as breaking.
|
|
@@ -252,18 +288,21 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
252
288
|
The `webpackConfig` property in the `shakapacker` module has been updated to be a function instead of a global mutable webpack configuration. This function now returns an immutable webpack configuration object, which ensures that any modifications made to it will not affect any other usage of the webpack configuration. If a project still requires the old mutable object, it can be accessed by replacing `webpackConfig` with `globalMutableWebpackConfig`. Check [v7-upgrade](https://github.com/shakacode/shakapacker/blob/main/docs/v7_upgrade.md) documentation for more detail.
|
|
253
289
|
|
|
254
290
|
### Added
|
|
291
|
+
|
|
255
292
|
- Set CSS modules mode depending on file type. [PR 261](https://github.com/shakacode/shakapacker/pull/261) by [talyuk](https://github.com/talyuk).
|
|
256
293
|
- All standard webpack entries with the camelCase format are now supported in `shakapacker.yml` in snake_case format. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha).
|
|
257
294
|
- The `shakapacker:install` rake task now has an option to force overriding files using `FORCE=true` environment variable [PR311](https://github.com/shakacode/shakapacker/pull/311) by [ahangarha](https://github.com/ahangarha).
|
|
258
295
|
- Allow configuration of use of contentHash for specific environment [PR 234](https://github.com/shakacode/shakapacker/pull/234) by [justin808](https://github/justin808).
|
|
259
296
|
|
|
260
297
|
### Changed
|
|
298
|
+
|
|
261
299
|
- Rename Webpacker to Shakapacker in the entire project including config files, binstubs, environment variables, etc. with a high degree of backward compatibility.
|
|
262
300
|
|
|
263
301
|
This change might be breaking for certain setups and edge cases. More information: [v7 Upgrade Guide](./docs/v7_upgrade.md) [PR157](https://github.com/shakacode/shakapacker/pull/157) by [ahangarha](https://github.com/ahangarha)
|
|
264
302
|
|
|
265
303
|
- Set `source_entry_path` to `packs` and `nested_entries` to `true` in`shakapacker.yml` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
|
|
266
304
|
- Dev server configuration is modified to follow [webpack recommended configurations](https://webpack.js.org/configuration/dev-server/) for dev server. [PR276](https://github.com/shakacode/shakapacker/pull/276) by [ahangarha](https://github.com/ahangarha):
|
|
305
|
+
|
|
267
306
|
- Deprecated `https` entry is removed from the default configuration file, allowing to set `server` or `https` as per the project requirements. For more detail, check webpack documentation. The `https` entry can be effective only if there is no `server` entry in the config file.
|
|
268
307
|
- `allowed_hosts` is now set to `auto` instead of `all` by default.
|
|
269
308
|
|
|
@@ -274,6 +313,7 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
274
313
|
Going forward, the top level directory of static files will be retained so this will necessitate the update of file name references in asset helpers. In the example above, the file sourced from `app/javascript/images/image.png` will be now output to `static/images/image.png` and needs to be referenced as `image_pack_tag("images/image.jpg")` or `image_pack_tag("static/images/image.jpg")`.
|
|
275
314
|
|
|
276
315
|
### Fixed
|
|
316
|
+
|
|
277
317
|
- Move compilation lock file into the working directory. [PR 272](https://github.com/shakacode/shakapacker/pull/272) by [tomdracz](https://github.com/tomdracz).
|
|
278
318
|
- Process `source_entry_path` with values starting with `/` as a relative path to `source_path` [PR 284](https://github.com/shakacode/shakapacker/pull/284) by [ahangarha](https://github.com/ahangarha).
|
|
279
319
|
- Removes defaults passed to `@babel/preset-typescript` to make it possible to have projects with mix of JS and TS code [PR 273](https://github.com/shakacode/shakapacker/pull/273) by [tomdracz](https://github.com/tomdracz).
|
|
@@ -282,16 +322,22 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
282
322
|
|
|
283
323
|
- Fixed RC version detection during installation. [PR312](https://github.com/shakacode/shakapacker/pull/312) by [ahangarha](https://github.com/ahangarha)
|
|
284
324
|
- Fix addition of webpack-dev-server to devDependencies during installation. [PR310](https://github.com/shakacode/shakapacker/pull/310) by [ahangarha](https://github.com/ahangarha)
|
|
325
|
+
|
|
285
326
|
### Removed
|
|
327
|
+
|
|
286
328
|
- Remove redundant enhancement for precompile task to run `yarn install` [PR 270](https://github.com/shakacode/shakapacker/pull/270) by [ahangarha](https://github.com/ahangarha).
|
|
287
329
|
- Remove deprecated `check_yarn_integrity` from `Shakapacker::Configuration` [PR SP288](https://github.com/shakacode/shakapacker/pull/288) by [ahangarha](https://github.com/ahangarha).
|
|
288
330
|
|
|
289
331
|
## [v6.6.0] - March 7, 2023
|
|
332
|
+
|
|
290
333
|
### Improved
|
|
334
|
+
|
|
291
335
|
- Allow configuration of webpacker.yml through env variable. [PR 254](https://github.com/shakacode/shakapacker/pull/254) by [alecslupu](https://github.com/alecslupu).
|
|
292
336
|
|
|
293
337
|
## [v6.5.6] - February 11, 2023
|
|
338
|
+
|
|
294
339
|
### Fixed
|
|
340
|
+
|
|
295
341
|
- Fixed failing to update `bin/setup` file due to different formats of the file in different versions of Rails. [PR 229](https://github.com/shakacode/shakapacker/pull/229) by [ahangarha](https://github.com/ahangarha).
|
|
296
342
|
|
|
297
343
|
- Upgrade several JS dependencies to fix security issues. [PR 243](https://github.com/shakacode/shakapacker/pull/243) by [ahangarha](https://github.com/ahangarha).
|
|
@@ -305,27 +351,33 @@ See the [v8 Upgrade Guide](https://github.com/shakacode/shakapacker/blob/main/do
|
|
|
305
351
|
## [v6.5.5] - December 28, 2022
|
|
306
352
|
|
|
307
353
|
### Improved
|
|
354
|
+
|
|
308
355
|
- Describe keys different from `webpack-dev-server` in generated `webpacker.yml`. [PR 194](https://github.com/shakacode/shakapacker/pull/194) by [alexeyr](https://github.com/alexeyr).
|
|
309
356
|
- Allow webpack-cli v5 [PR 216](https://github.com/shakacode/shakapacker/pull/216) by [tagliala](https://github.com/tagliala).
|
|
310
357
|
- Allow babel-loader v9 [PR 215](https://github.com/shakacode/shakapacker/pull/215) by [tagliala](https://github.com/tagliala).
|
|
311
358
|
|
|
312
359
|
## [v6.5.4] - November 4, 2022
|
|
360
|
+
|
|
313
361
|
### Fixed
|
|
362
|
+
|
|
314
363
|
- Fixed regression caused by 6.5.3. PR #192 introduce extra split() call. [PR 202](https://github.com/shakacode/shakapacker/pull/202) by [Eric-Guo](https://github.com/Eric-Guo).
|
|
315
364
|
|
|
316
365
|
## [v6.5.3] - November 1, 2022
|
|
317
366
|
|
|
318
367
|
### Improved
|
|
368
|
+
|
|
319
369
|
- Set RAILS_ENV and BUNDLE_GEMFILE env values before requiring `bundler/setup`, `webpacker`, and `webpacker/webpack_runner`. [PR 190](https://github.com/shakacode/shakapacker/pull/190) by [betmenslido](https://github.com/betmenslido).
|
|
320
370
|
- The `mini-css-extract-plugin` may cause various warnings indicating CSS order conflicts when using a [File-System-based automated bundle generation feature](https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation/).
|
|
321
|
-
CSS order warnings can be disabled in projects where CSS ordering has been mitigated by consistent use of scoping or naming conventions. Added `css_extract_ignore_order_warnings` flag to webpacker configuration to disable the order warnings by [pulkitkkr](https://github.com/shakacode/shakapacker/pull/185) in [PR 192](https://github.com/shakacode/shakapacker/pull/192).
|
|
371
|
+
CSS order warnings can be disabled in projects where CSS ordering has been mitigated by consistent use of scoping or naming conventions. Added `css_extract_ignore_order_warnings` flag to webpacker configuration to disable the order warnings by [pulkitkkr](https://github.com/shakacode/shakapacker/pull/185) in [PR 192](https://github.com/shakacode/shakapacker/pull/192).
|
|
322
372
|
|
|
323
373
|
## [v6.5.2] - September 8, 2022
|
|
324
374
|
|
|
325
375
|
### Upgrade
|
|
376
|
+
|
|
326
377
|
Remove the setting of the NODE_ENV in your `bin/webpacker` and `bin/webpacker-dev-server` files per [PR 185](https://github.com/shakacode/shakapacker/pull/185).
|
|
327
378
|
|
|
328
379
|
### Fixed
|
|
380
|
+
|
|
329
381
|
- Changed NODE_ENV defaults to the following and moved from binstubs to the runner. [PR 185](https://github.com/shakacode/shakapacker/pull/185) by [mage1711](https://github.com/mage1711).
|
|
330
382
|
|
|
331
383
|
```
|
|
@@ -335,23 +387,30 @@ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "develop
|
|
|
335
387
|
## [v6.5.1] - August 15, 2022
|
|
336
388
|
|
|
337
389
|
### Improved
|
|
390
|
+
|
|
338
391
|
- Resolve exact npm package version from lockfiles for constraint checking. [PR 170](https://github.com/shakacode/shakapacker/pull/170) by [G-Rath](https://github.com/G-Rath).
|
|
339
392
|
|
|
340
393
|
### Fixed
|
|
394
|
+
|
|
341
395
|
- `append_javascript_pack_tag` and `append_stylesheet_pack_tag` helpers return `nil` to prevent rendering the queue into view when using `<%= … %>` ERB syntax. [PR 167](https://github.com/shakacode/shakapacker/pull/167) by [ur5us](https://github.com/ur5us). While `<%=` should not be used, it's OK to return nil in case it's misused.
|
|
342
396
|
- Fixed non-runnable test due to wrong code nesting. [PR 173](https://github.com/shakacode/shakapacker/pull/173) by [ur5us](https://github.com/ur5us).
|
|
343
397
|
- Fixed default configurations not working for custom Rails environments [PR 168](https://github.com/shakacode/shakapacker/pull/168) by [ur5us](https://github.com/ur5us).
|
|
344
398
|
- Added accessor method for `nested_entries` configuration. [PR 176](https://github.com/shakacode/shakapacker/pull/176) by [pulkitkkr](https://github.com/pulkitkkr).
|
|
345
399
|
|
|
346
400
|
## [v6.5.0] - July 4, 2022
|
|
401
|
+
|
|
347
402
|
### Added
|
|
403
|
+
|
|
348
404
|
- `append_stylesheet_pack_tag` helper. It helps in configuring stylesheet pack names from the view for a route or partials. It is also required for filesystem-based automated Component Registry API on React on Rails gem. [PR 144](https://github.com/shakacode/shakapacker/pull/144) by [pulkitkkr](https://github.com/pulkitkkr).
|
|
349
405
|
|
|
350
406
|
### Improved
|
|
407
|
+
|
|
351
408
|
- Make sure at most one compilation runs at a time [PR 139](https://github.com/shakacode/shakapacker/pull/139) by [artemave](https://github.com/artemave)
|
|
352
409
|
|
|
353
410
|
## [v6.4.1] - June 5, 2022
|
|
411
|
+
|
|
354
412
|
### Fixed
|
|
413
|
+
|
|
355
414
|
- Restores automatic installation of yarn packages removed in [#131](https://github.com/shakacode/shakapacker/pull/131), with added deprecation notice. [PR 140](https://github.com/shakacode/shakapacker/pull/140) by [tomdracz](https://github.com/tomdracz).
|
|
356
415
|
|
|
357
416
|
This will be again removed in Shakapacker v7 so you need to ensure you are installing yarn packages explicitly before the asset compilation, rather than relying on this behaviour through `asset:precompile` task (e.g. Capistrano deployment).
|
|
@@ -359,13 +418,17 @@ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "develop
|
|
|
359
418
|
- Disable Spring being used by `rails-erb-loader`. [PR 141](https://github.com/shakacode/shakapacker/pull/141) by [tomdracz](https://github.com/tomdracz).
|
|
360
419
|
|
|
361
420
|
## [v6.4.0] - June 2, 2022
|
|
421
|
+
|
|
362
422
|
### Fixed
|
|
423
|
+
|
|
363
424
|
- Fixed [Issue 123: Rails 7.0.3 - Webpacker configuration file not found when running rails webpacker:install (shakapacker v6.3)](https://github.com/shakacode/shakapacker/issues/123) in [PR 136: Don't enhance precompile if no config #136](https://github.com/shakacode/shakapacker/pull/136) by [justin808](https://github.com/justin808).
|
|
364
425
|
|
|
365
426
|
### Added
|
|
427
|
+
|
|
366
428
|
- Configuration boolean option `nested_entries` to use nested entries. This was the default prior to v6.0. Because entries maybe generated, it's useful to allow a `generated` subdirectory. [PR 121](https://github.com/shakacode/shakapacker/pull/121) by [justin808](https://github.com/justin808).
|
|
367
429
|
|
|
368
430
|
### Improved
|
|
431
|
+
|
|
369
432
|
- Allow v10 of `compression-webpack-plugin` as a peer dependency. [PR 117](https://github.com/shakacode/shakapacker/pull/117) by [aried3r](https://github.com/aried3r).
|
|
370
433
|
|
|
371
434
|
- [Remove assets:precompile task enhancement #131](https://github.com/shakacode/shakapacker/pull/131) by [James Herdman](https://github.com/jherdman): Removed the `yarn:install` Rake task, and no longer enhance `assets:precompile` with said task. These tasks were used to ensure required NPM packages were installed before asset precompilation. Going forward you will need to ensure these packages are already installed yourself. Should you wish to restore this behaviour you'll need to [reimplement the task](https://github.com/shakacode/shakapacker/blob/bee661422f2c902aa8ac9cf8fa1f7ccb8142c914/lib/tasks/yarn.rake) in your own application.
|
|
@@ -373,9 +436,11 @@ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "develop
|
|
|
373
436
|
## [v6.3.0] - May 19, 2022
|
|
374
437
|
|
|
375
438
|
### Improved
|
|
439
|
+
|
|
376
440
|
- Add ability to configure usage of either last modified timestamp and digest strategies when checking asset freshness. [PR 112](https://github.com/shakacode/shakapacker/pull/112) by [tomdracz](https://github.com/tomdracz).
|
|
377
441
|
|
|
378
442
|
### Fixed
|
|
443
|
+
|
|
379
444
|
- On Windows CSS urls no longer contain backslashes resulting in 404 errors. [PR 115](https://github.com/shakacode/shakapacker/pull/115) by [daniel-rikowski](https://github.com/daniel-rikowski).
|
|
380
445
|
|
|
381
446
|
## [v6.3.0-rc.1] - April 24, 2022
|
|
@@ -383,6 +448,7 @@ ENV["NODE_ENV"] ||= (ENV["RAILS_ENV"] == "production") ? "production" : "develop
|
|
|
383
448
|
Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions/6.3.0.pre.rc.1) and [NPM is 6.3.0-rc.1](https://www.npmjs.com/package/shakapacker/v/6.3.0-rc.1).
|
|
384
449
|
|
|
385
450
|
### Changed
|
|
451
|
+
|
|
386
452
|
- Remove Loose mode from the default @babel-preset/env configuration. [PR 107](https://github.com/shakacode/shakapacker/pull/107) by [Jeremy Liberman](https://github.com/MrLeebo).
|
|
387
453
|
|
|
388
454
|
Loose mode compiles the bundle down to be compatible with ES5, but saves space by skipping over behaviors that are considered edge cases. Loose mode can affect how your code runs in a variety of ways, but in newer versions of Babel it's better to use [Compiler Assumptions](https://babeljs.io/docs/en/assumptions) to have finer-grained control over which edge cases you're choosing to ignore.
|
|
@@ -390,10 +456,12 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
390
456
|
This change may increase the file size of your bundles, and may change some behavior in your app if your code touches upon one of the edge cases where Loose mode differs from native JavaScript. There are notes in the linked PR about how to turn Loose mode back on if you need to, but consider migrating to Compiler Assumptions when you can. If you have already customized your babel config, this change probably won't affect you.
|
|
391
457
|
|
|
392
458
|
### Added
|
|
459
|
+
|
|
393
460
|
- Adds `webpacker_precompile` setting to `webpacker.yml` to allow controlling precompile behaviour, similar to existing `ENV["WEBPACKER_PRECOMPILE"]` variable. [PR 102](https://github.com/shakacode/shakapacker/pull/102) by [Judahmeek](https://github.com/Judahmeek).
|
|
394
461
|
- Adds `append_javascript_pack_tag` helper. Allows for easier usage and coordination of multiple javascript packs. [PR 94](https://github.com/shakacode/shakapacker/pull/94) by [tomdracz](https://github.com/tomdracz).
|
|
395
462
|
|
|
396
463
|
### Improved
|
|
464
|
+
|
|
397
465
|
- Use last modified timestamps rather than file digest to determine compiler freshness. [PR 97](https://github.com/shakacode/shakapacker/pull/97) by [tomdracz](https://github.com/tomdracz).
|
|
398
466
|
|
|
399
467
|
Rather than calculating SHA digest of all the files in the paths watched by the compiler, we are now comparing the modified time of the `manifest.json` file versus the latest modified timestamp of files and directories in watched paths. Unlike calculating digest, which only looked at the files, the new calculation also considers directory timestamps, including the parent ones (i.e. `config.source_path` folder timestamp will be checked together will timestamps of all files and directories inside of it).
|
|
@@ -404,18 +472,22 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
404
472
|
- Add `webpack-dev-server` as `peerDependency` to make its usage clear. [PR 109](https://github.com/shakacode/shakapacker/pull/109) by [tomdracz](https://github.com/tomdracz).
|
|
405
473
|
|
|
406
474
|
## [v6.2.1] - April 15, 2022
|
|
475
|
+
|
|
407
476
|
### Fixed
|
|
477
|
+
|
|
408
478
|
- Put back config.public_manifest_path, removed in 6.2.0 in PR 78. [PR 104](https://github.com/shakacode/shakapacker/pull/104) by [justin808](https://github.com/justin808).
|
|
409
479
|
|
|
410
480
|
## [v6.2.0] - March 22, 2022
|
|
411
481
|
|
|
412
482
|
### Added
|
|
483
|
+
|
|
413
484
|
- Make manifest_path configurable, to keep manifest.json private if desired. [PR 78](https://github.com/shakacode/shakapacker/pull/78) by [jdelStrother](https://github.com/jdelStrother).
|
|
414
485
|
- Rewrite webpack module rules as regular expressions. Allows for easy iteration during config customization. [PR 60](https://github.com/shakacode/shakapacker/pull/60) by [blnoonan](https://github.com/blnoonan).
|
|
415
486
|
- Initialization check to ensure shakapacker gem and NPM package version are consistent. Opt-in behaviour enabled by setting `ensure_consistent_versioning` configuration variable. [PR 51](https://github.com/shakacode/shakapacker/pull/51) by [tomdracz](https://github.com/tomdracz).
|
|
416
487
|
- Add `dev_server.inline_css: bool` config option to allow for opting out of style-loader and into mini-css-extract-plugin for CSS HMR in development. [PR 69](https://github.com/shakacode/shakapacker/pull/69) by [cheald](https://github.com/cheald).
|
|
417
488
|
|
|
418
489
|
### Improved
|
|
490
|
+
|
|
419
491
|
- Increase default connect timeout for dev server connections, establishing connections more reliably for busy machines. [PR 74](https://github.com/shakacode/shakapacker/pull/74) by [stevecrozz](https://github.com/stevecrozz).
|
|
420
492
|
- Allow multiple invocations of stylesheet_pack_tag (eg for a regular stylesheet & a print stylesheet). [PR 82](https://github.com/shakacode/shakapacker/pull/82) by [jdelStrother](https://github.com/jdelStrother).
|
|
421
493
|
- Tweak swc config for parity with Babel. [PR 79](https://github.com/shakacode/shakapacker/pull/79) by [dleavitt](https://github.com/dleavitt).
|
|
@@ -423,31 +495,39 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
423
495
|
## [v6.1.1] - February 6, 2022
|
|
424
496
|
|
|
425
497
|
### Added
|
|
498
|
+
|
|
426
499
|
- Support for esbuild-loader. [PR 53](https://github.com/shakacode/shakapacker/pull/53) by [tomdracz](https://github.com/tomdracz).
|
|
427
500
|
|
|
428
501
|
## [v6.1.0] - February 4, 2022
|
|
502
|
+
|
|
429
503
|
### Added
|
|
504
|
+
|
|
430
505
|
- Support for SWC loader. [PR 29](https://github.com/shakacode/shakapacker/pull/29) by [tomdracz](https://github.com/tomdracz).
|
|
431
506
|
|
|
432
507
|
### Fixed
|
|
508
|
+
|
|
433
509
|
- Static asset subdirectories are retained after compilation, matching Webpacker v5 behaviour. [PR 47](https://github.com/shakacode/shakapacker/pull/47) by [tomdracz](https://github.com/tomdracz). Fixes issues [rails/webpacker#2956](https://github.com/rails/webpacker/issues/2956) which broke in [rails/webpacker#2802](https://github.com/rails/webpacker/pull/2802).
|
|
434
510
|
|
|
435
511
|
## [v6.0.2] - January 25, 2022
|
|
512
|
+
|
|
436
513
|
### Improved
|
|
514
|
+
|
|
437
515
|
- Fix incorrect command name in warning. [PR 33](https://github.com/shakacode/shakapacker/pull/33) by [tricknotes](https://github.com/tricknotes).
|
|
438
516
|
|
|
439
517
|
## [v6.0.1] - January 24, 2022
|
|
518
|
+
|
|
440
519
|
### Improved
|
|
520
|
+
|
|
441
521
|
- PR #21 removed pnp-webpack-plugin as a dev dependency but did not remove it from the peer dependency list. [PR 30](https://github.com/shakacode/shakapacker/pull/30) by [t27duck](https://github.com/t27duck).
|
|
442
522
|
|
|
443
523
|
## [v6.0.0 changes from v6.0.0.rc.6] - January 22, 2022
|
|
444
524
|
|
|
445
525
|
### Improved
|
|
526
|
+
|
|
446
527
|
- Raise on multiple invocations of javascript_pack_tag and stylesheet_pack_tag helpers. [PR 19](https://github.com/shakacode/shakapacker/pull/19) by [tomdracz](https://github.com/tomdracz).
|
|
447
528
|
- Remove automatic addition of node_modules into rails asset load path. [PR 20](https://github.com/shakacode/shakapacker/pull/20) by [tomdracz](https://github.com/tomdracz).
|
|
448
529
|
- Remove pnp-webpack-plugin. [PR 21](https://github.com/shakacode/shakapacker/pull/21) by [tomdracz](https://github.com/tomdracz).
|
|
449
530
|
|
|
450
|
-
|
|
451
531
|
### Merged from rails/webpacker
|
|
452
532
|
|
|
453
533
|
- Make watched_files_digest thread safe. [rails/webpacker #3233](https://github.com/rails/webpacker/pull/3233)
|
|
@@ -455,18 +535,18 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
455
535
|
- Switch to peer dependencies. [rails/webpacker #3234](https://github.com/rails/webpacker/pull/3234)
|
|
456
536
|
|
|
457
537
|
### Upgrading from rails/webpacker 6.0.0.rc.6
|
|
538
|
+
|
|
458
539
|
- Single default configuration file of `config/webpack/webpack.config.js`. Previously, the config file was set
|
|
459
540
|
to `config/webpack/#{NODE_ENV}.js`.
|
|
460
541
|
- Changed all package.json dependencies to peerDependencies, so upgrading requires adding the dependencies, per the [UPGRADE GUIDE](./docs/v6_upgrade.md).
|
|
461
542
|
|
|
462
543
|
## [v6.0.0.rc.6 changes from v5.4] - Forked January 16, 2022
|
|
463
544
|
|
|
464
|
-
|
|
465
545
|
- `node_modules` will no longer be babel transformed compiled by default. This primarily fixes [rails issue #35501](https://github.com/rails/rails/issues/35501) as well as [numerous other webpacker issues](https://github.com/rails/webpacker/issues/2131#issuecomment-581618497). The disabled loader can still be required explicitly via:
|
|
466
546
|
|
|
467
547
|
```js
|
|
468
|
-
const nodeModules = require(
|
|
469
|
-
environment.loaders.append(
|
|
548
|
+
const nodeModules = require("@rails/webpacker/rules/node_modules.js")
|
|
549
|
+
environment.loaders.append("nodeModules", nodeModules)
|
|
470
550
|
```
|
|
471
551
|
|
|
472
552
|
- If you have added `environment.loaders.delete('nodeModules')` to your `environment.js`, this must be removed or you will receive an error (`Item nodeModules not found`).
|
|
@@ -479,12 +559,14 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
|
479
559
|
- Deprecated configuration option `watched_paths`. Use `additional_paths` instead in `webpacker.yml`.
|
|
480
560
|
|
|
481
561
|
### Breaking changes
|
|
562
|
+
|
|
482
563
|
- Renamed `/bin/webpack` to `/bin/webpacker` and `/bin/webpack-dev-server` to `bin/webpacker-dev-server` to avoid confusion with underlying webpack executables.
|
|
483
564
|
- Removed integration installers
|
|
484
565
|
- Splitchunks enabled by default
|
|
485
566
|
- CSS extraction enabled by default, except when devServer is configured and running
|
|
486
567
|
|
|
487
568
|
## v5.4.3 and prior changes from rails/webpacker
|
|
569
|
+
|
|
488
570
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
|
489
571
|
|
|
490
572
|
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v9.0.0-beta.8...main
|
data/Gemfile.lock
CHANGED
|
@@ -22,10 +22,10 @@ Set the transpiler in your `config/shakapacker.yml`:
|
|
|
22
22
|
default: &default
|
|
23
23
|
# For webpack users (babel is default, no change needed)
|
|
24
24
|
javascript_transpiler: babel
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
# To opt-in to SWC for better performance
|
|
27
27
|
javascript_transpiler: swc
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
# For rspack users (swc is default, no change needed)
|
|
30
30
|
assets_bundler: rspack
|
|
31
31
|
javascript_transpiler: swc
|
|
@@ -53,30 +53,26 @@ default: &default
|
|
|
53
53
|
|
|
54
54
|
#### 3. Create SWC configuration (optional)
|
|
55
55
|
|
|
56
|
-
If you need custom transpilation settings, create
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"react": {
|
|
69
|
-
"runtime": "automatic"
|
|
56
|
+
If you need custom transpilation settings, create `config/swc.config.js`:
|
|
57
|
+
|
|
58
|
+
```javascript
|
|
59
|
+
// config/swc.config.js
|
|
60
|
+
// This file is merged with Shakapacker's default SWC configuration
|
|
61
|
+
// See: https://swc.rs/docs/configuration/compilation
|
|
62
|
+
|
|
63
|
+
module.exports = {
|
|
64
|
+
jsc: {
|
|
65
|
+
transform: {
|
|
66
|
+
react: {
|
|
67
|
+
runtime: "automatic"
|
|
70
68
|
}
|
|
71
|
-
}
|
|
72
|
-
"target": "es2015"
|
|
73
|
-
},
|
|
74
|
-
"module": {
|
|
75
|
-
"type": "es6"
|
|
69
|
+
}
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
72
|
```
|
|
79
73
|
|
|
74
|
+
**Important:** Use `config/swc.config.js` instead of `.swcrc`. The `.swcrc` file completely overrides Shakapacker's default SWC settings and can cause build failures. `config/swc.config.js` properly merges with Shakapacker's defaults.
|
|
75
|
+
|
|
80
76
|
#### 4. Update React configuration (if using React)
|
|
81
77
|
|
|
82
78
|
For React projects, ensure you have the correct refresh plugin:
|
|
@@ -93,11 +89,11 @@ yarn add --dev @rspack/plugin-react-refresh
|
|
|
93
89
|
|
|
94
90
|
Typical build time improvements when migrating from Babel to SWC:
|
|
95
91
|
|
|
96
|
-
| Project Size
|
|
97
|
-
|
|
98
|
-
| Small (<100 files)
|
|
99
|
-
| Medium (100-500 files) | 20s
|
|
100
|
-
| Large (500+ files)
|
|
92
|
+
| Project Size | Babel | SWC | Improvement |
|
|
93
|
+
| ---------------------- | ----- | --- | ----------- |
|
|
94
|
+
| Small (<100 files) | 5s | 1s | 5x faster |
|
|
95
|
+
| Medium (100-500 files) | 20s | 3s | 6.7x faster |
|
|
96
|
+
| Large (500+ files) | 60s | 8s | 7.5x faster |
|
|
101
97
|
|
|
102
98
|
### Compatibility Notes
|
|
103
99
|
|
|
@@ -125,7 +121,7 @@ If you encounter issues, rolling back is simple:
|
|
|
125
121
|
```yaml
|
|
126
122
|
# config/shakapacker.yml
|
|
127
123
|
default: &default
|
|
128
|
-
javascript_transpiler: babel
|
|
124
|
+
javascript_transpiler: babel # Revert to babel
|
|
129
125
|
```
|
|
130
126
|
|
|
131
127
|
Then rebuild your application:
|
|
@@ -165,20 +161,21 @@ yarn add --dev @swc/core swc-loader
|
|
|
165
161
|
# Webpack
|
|
166
162
|
yarn add --dev @pmmmwh/react-refresh-webpack-plugin
|
|
167
163
|
|
|
168
|
-
# Rspack
|
|
164
|
+
# Rspack
|
|
169
165
|
yarn add --dev @rspack/plugin-react-refresh
|
|
170
166
|
```
|
|
171
167
|
|
|
172
168
|
### Issue: Decorators not working
|
|
173
169
|
|
|
174
|
-
**Solution**: Enable decorator support in
|
|
170
|
+
**Solution**: Enable decorator support in `config/swc.config.js`:
|
|
175
171
|
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
172
|
+
```javascript
|
|
173
|
+
// config/swc.config.js
|
|
174
|
+
module.exports = {
|
|
175
|
+
jsc: {
|
|
176
|
+
parser: {
|
|
177
|
+
decorators: true,
|
|
178
|
+
decoratorsBeforeExport: true
|
|
182
179
|
}
|
|
183
180
|
}
|
|
184
181
|
}
|
|
@@ -188,4 +185,4 @@ yarn add --dev @rspack/plugin-react-refresh
|
|
|
188
185
|
|
|
189
186
|
- [SWC Documentation](https://swc.rs/docs/getting-started)
|
|
190
187
|
- [Babel to SWC Migration Guide](https://swc.rs/docs/migrating-from-babel)
|
|
191
|
-
- [Rspack Configuration](https://www.rspack.dev/config/index)
|
|
188
|
+
- [Rspack Configuration](https://www.rspack.dev/config/index)
|