shakapacker 9.0.0.beta.9 → 9.0.0.beta.10
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/v9_upgrade.md +80 -26
- 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: 1157b2b32dc1e415593d4b3386abcdc6dc0e8d5b8863d34ca418c4e3333ca9f1
|
4
|
+
data.tar.gz: 83787074dfb2bce32284997b1312262e28b086ebc7e5bfcd11b647859268b842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 888e0bbb28ede4eeea180a4a60885a49c073a6aec63f1f84db15c130624b7d8b79f903a66af640e996ddb7985ce022c781c6113dc1f274d4b6f60f59f6851733
|
7
|
+
data.tar.gz: 432465adefccd3610b99ec23b6551e89a9cc39e658b475f70664af1791587f574f2b4bcb2c833aa1dad7bc11ad06c9dff52f5892b3b914c5629a58f327e90d92
|
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
data/docs/v9_upgrade.md
CHANGED
@@ -9,12 +9,38 @@ This guide outlines new features, breaking changes, and migration steps for upgr
|
|
9
9
|
Shakapacker v9 includes TypeScript definitions for better IDE support and type safety.
|
10
10
|
|
11
11
|
- **No breaking changes** - JavaScript configs continue to work
|
12
|
-
- **Optional** - Use TypeScript only if you want it
|
12
|
+
- **Optional** - Use TypeScript only if you want it
|
13
13
|
- **Type safety** - Catch configuration errors at compile-time
|
14
14
|
- **IDE support** - Full autocomplete for all options
|
15
15
|
|
16
16
|
See the [TypeScript Documentation](./typescript.md) for usage examples.
|
17
17
|
|
18
|
+
### NODE_ENV Default Behavior Fixed
|
19
|
+
|
20
|
+
**What changed:** NODE_ENV now intelligently defaults based on RAILS_ENV instead of always defaulting to "production".
|
21
|
+
|
22
|
+
**New behavior:**
|
23
|
+
|
24
|
+
- When `RAILS_ENV=production` → `NODE_ENV` defaults to `"production"`
|
25
|
+
- When `RAILS_ENV=development` or unset → `NODE_ENV` defaults to `"development"`
|
26
|
+
- When `RAILS_ENV` is any other value (test, staging, etc.) → `NODE_ENV` defaults to `"development"`
|
27
|
+
|
28
|
+
**Benefits:**
|
29
|
+
|
30
|
+
- **Dev server "just works"** - No need to explicitly set NODE_ENV when running the development server
|
31
|
+
- **Correct configuration loaded** - Development server now properly loads the development configuration from shakapacker.yml
|
32
|
+
- **Fixes port issues** - Dev server uses the configured port (e.g., 3035) instead of defaulting to 8080
|
33
|
+
- **Fixes 404 errors** - Assets load correctly without requiring manual NODE_ENV configuration
|
34
|
+
|
35
|
+
**No action required** - This change improves the default behavior and requires no migration.
|
36
|
+
|
37
|
+
**If you previously worked around this bug**, you can now remove these workarounds:
|
38
|
+
|
39
|
+
- Remove `NODE_ENV=development` from your `.env`, `.env.development`, or `.env.local` files
|
40
|
+
- Remove `NODE_ENV=development` from your `docker-compose.yml` or Dockerfile
|
41
|
+
- Remove custom scripts that set NODE_ENV before running the dev server
|
42
|
+
- Remove `NODE_ENV=development` from your `bin/dev` or Procfile.dev
|
43
|
+
|
18
44
|
## Breaking Changes
|
19
45
|
|
20
46
|
### 1. CSS Modules Configuration Changed to Named Exports
|
@@ -25,25 +51,27 @@ See the [TypeScript Documentation](./typescript.md) for usage examples.
|
|
25
51
|
|
26
52
|
**Quick Reference: Configuration Options**
|
27
53
|
|
28
|
-
| Configuration
|
29
|
-
|
30
|
-
| **v9 Default**
|
31
|
-
| **Alternative** | `true`
|
32
|
-
| **v8 Style**
|
33
|
-
| **❌ Invalid**
|
54
|
+
| Configuration | namedExport | exportLocalsConvention | CSS: `.my-button` | Export Available | Works With |
|
55
|
+
| --------------- | ----------- | ---------------------- | ----------------- | --------------------------------- | ----------------- |
|
56
|
+
| **v9 Default** | `true` | `'camelCaseOnly'` | `.my-button` | `myButton` only | ✅ Named exports |
|
57
|
+
| **Alternative** | `true` | `'dashesOnly'` | `.my-button` | `'my-button'` only | ✅ Named exports |
|
58
|
+
| **v8 Style** | `false` | `'camelCase'` | `.my-button` | Both `myButton` AND `'my-button'` | ✅ Default export |
|
59
|
+
| **❌ Invalid** | `true` | `'camelCase'` | - | - | ❌ Build Error |
|
34
60
|
|
35
61
|
**JavaScript Projects:**
|
62
|
+
|
36
63
|
```js
|
37
64
|
// Before (v8)
|
38
|
-
import styles from
|
39
|
-
|
65
|
+
import styles from "./Component.module.css"
|
66
|
+
;<button className={styles.button} />
|
40
67
|
|
41
68
|
// After (v9)
|
42
|
-
import { button } from
|
43
|
-
|
69
|
+
import { button } from "./Component.module.css"
|
70
|
+
;<button className={button} />
|
44
71
|
```
|
45
72
|
|
46
73
|
**TypeScript Projects:**
|
74
|
+
|
47
75
|
```typescript
|
48
76
|
// Before (v8)
|
49
77
|
import styles from './Component.module.css';
|
@@ -57,6 +85,7 @@ import * as styles from './Component.module.css';
|
|
57
85
|
**Migration Options:**
|
58
86
|
|
59
87
|
1. **Update your code** (Recommended):
|
88
|
+
|
60
89
|
- JavaScript: Change to named imports (`import { className }`)
|
61
90
|
- TypeScript: Change to namespace imports (`import * as styles`)
|
62
91
|
- Kebab-case class names are automatically converted to camelCase
|
@@ -66,6 +95,7 @@ import * as styles from './Component.module.css';
|
|
66
95
|
- This gives you time to migrate gradually
|
67
96
|
|
68
97
|
**Benefits of the change:**
|
98
|
+
|
69
99
|
- Eliminates webpack/TypeScript warnings
|
70
100
|
- Better tree-shaking of unused CSS classes
|
71
101
|
- More explicit about which classes are used
|
@@ -76,15 +106,17 @@ import * as styles from './Component.module.css';
|
|
76
106
|
**What changed:** The configuration option has been renamed to better reflect its purpose.
|
77
107
|
|
78
108
|
**Before (v8):**
|
109
|
+
|
79
110
|
```yml
|
80
111
|
# config/shakapacker.yml
|
81
|
-
webpack_loader:
|
112
|
+
webpack_loader: "babel"
|
82
113
|
```
|
83
114
|
|
84
115
|
**After (v9):**
|
116
|
+
|
85
117
|
```yml
|
86
118
|
# config/shakapacker.yml
|
87
|
-
javascript_transpiler:
|
119
|
+
javascript_transpiler: "babel"
|
88
120
|
```
|
89
121
|
|
90
122
|
**Note:** The old `webpack_loader` option is deprecated but still supported with a warning.
|
@@ -96,38 +128,48 @@ javascript_transpiler: 'babel'
|
|
96
128
|
**Why:** SWC is 20x faster than Babel while maintaining compatibility with most JavaScript and TypeScript code.
|
97
129
|
|
98
130
|
**Impact on existing projects:**
|
131
|
+
|
99
132
|
- Your project will continue using Babel if you already have babel packages in package.json
|
100
133
|
- To switch to SWC for better performance, see migration options below
|
101
134
|
|
102
135
|
**Impact on new projects:**
|
136
|
+
|
103
137
|
- New installations will use SWC by default
|
104
138
|
- Babel dependencies won't be installed unless explicitly configured
|
105
139
|
|
106
140
|
### Migration Options
|
107
141
|
|
108
142
|
#### Option 1 (Recommended): Switch to SWC
|
143
|
+
|
109
144
|
```yml
|
110
145
|
# config/shakapacker.yml
|
111
|
-
javascript_transpiler:
|
146
|
+
javascript_transpiler: "swc"
|
112
147
|
```
|
148
|
+
|
113
149
|
Then install SWC:
|
150
|
+
|
114
151
|
```bash
|
115
152
|
npm install @swc/core swc-loader
|
116
153
|
```
|
117
154
|
|
118
155
|
#### Option 2: Keep using Babel
|
156
|
+
|
119
157
|
```yml
|
120
158
|
# config/shakapacker.yml
|
121
|
-
javascript_transpiler:
|
159
|
+
javascript_transpiler: "babel"
|
122
160
|
```
|
161
|
+
|
123
162
|
No other changes needed - your existing babel packages will continue to work.
|
124
163
|
|
125
164
|
#### Option 3: Use esbuild
|
165
|
+
|
126
166
|
```yml
|
127
167
|
# config/shakapacker.yml
|
128
|
-
javascript_transpiler:
|
168
|
+
javascript_transpiler: "esbuild"
|
129
169
|
```
|
170
|
+
|
130
171
|
Then install esbuild:
|
172
|
+
|
131
173
|
```bash
|
132
174
|
npm install esbuild esbuild-loader
|
133
175
|
```
|
@@ -138,7 +180,7 @@ npm install esbuild esbuild-loader
|
|
138
180
|
|
139
181
|
```yml
|
140
182
|
# config/shakapacker.yml
|
141
|
-
assets_bundler:
|
183
|
+
assets_bundler: "rspack" # or 'webpack' (default)
|
142
184
|
```
|
143
185
|
|
144
186
|
### 5. All Peer Dependencies Now Optional
|
@@ -146,16 +188,19 @@ assets_bundler: 'rspack' # or 'webpack' (default)
|
|
146
188
|
**What changed:** All peer dependencies are now marked as optional via `peerDependenciesMeta`.
|
147
189
|
|
148
190
|
**Benefits:**
|
191
|
+
|
149
192
|
- **No installation warnings** - You won't see peer dependency warnings for packages you don't use
|
150
193
|
- **Install only what you need** - Using webpack? Don't install rspack. Using SWC? Don't install Babel.
|
151
194
|
- **Clear version constraints** - When you do install a package, version compatibility is still enforced
|
152
195
|
|
153
196
|
**What this means for you:**
|
197
|
+
|
154
198
|
- **Existing projects:** No changes needed. Your existing dependencies will continue to work.
|
155
199
|
- **New projects:** The installer only adds the packages you actually need based on your configuration.
|
156
200
|
- **Package manager behavior:** npm, yarn, and pnpm will no longer warn about missing peer dependencies.
|
157
201
|
|
158
202
|
**Example:** If you're using SWC with webpack, you only need:
|
203
|
+
|
159
204
|
```json
|
160
205
|
{
|
161
206
|
"dependencies": {
|
@@ -168,6 +213,7 @@ assets_bundler: 'rspack' # or 'webpack' (default)
|
|
168
213
|
}
|
169
214
|
}
|
170
215
|
```
|
216
|
+
|
171
217
|
You won't get warnings about missing Babel, Rspack, or esbuild packages.
|
172
218
|
|
173
219
|
## Migration Steps
|
@@ -186,22 +232,22 @@ yarn upgrade shakapacker@^9.0.0
|
|
186
232
|
|
187
233
|
```js
|
188
234
|
// Find imports like this:
|
189
|
-
import styles from
|
235
|
+
import styles from "./styles.module.css"
|
190
236
|
|
191
237
|
// Replace with named imports:
|
192
|
-
import { className1, className2 } from
|
238
|
+
import { className1, className2 } from "./styles.module.css"
|
193
239
|
```
|
194
240
|
|
195
241
|
#### Update TypeScript definitions:
|
196
242
|
|
197
243
|
```typescript
|
198
244
|
// Update your CSS module type definitions
|
199
|
-
declare module
|
245
|
+
declare module "*.module.css" {
|
200
246
|
// With namedExport: true, css-loader generates individual named exports
|
201
247
|
// TypeScript can't know the exact names at compile time, so we declare
|
202
248
|
// a module with any number of string exports
|
203
|
-
const classes: { readonly [key: string]: string }
|
204
|
-
export = classes
|
249
|
+
const classes: { readonly [key: string]: string }
|
250
|
+
export = classes
|
205
251
|
// Note: This allows 'import * as styles' but not 'import styles from'
|
206
252
|
// because css-loader with namedExport: true doesn't generate a default export
|
207
253
|
}
|
@@ -213,13 +259,15 @@ v9 automatically converts kebab-case to camelCase with `exportLocalsConvention:
|
|
213
259
|
|
214
260
|
```css
|
215
261
|
/* styles.module.css */
|
216
|
-
.my-button {
|
217
|
-
|
262
|
+
.my-button {
|
263
|
+
}
|
264
|
+
.primary-color {
|
265
|
+
}
|
218
266
|
```
|
219
267
|
|
220
268
|
```js
|
221
269
|
// v9 default - camelCase conversion
|
222
|
-
import { myButton, primaryColor } from
|
270
|
+
import { myButton, primaryColor } from "./styles.module.css"
|
223
271
|
```
|
224
272
|
|
225
273
|
**Alternative: Keep kebab-case names with 'dashesOnly'**
|
@@ -256,7 +304,7 @@ If you have `webpack_loader` in your configuration:
|
|
256
304
|
# webpack_loader: 'babel'
|
257
305
|
|
258
306
|
# NEW:
|
259
|
-
javascript_transpiler:
|
307
|
+
javascript_transpiler: "babel"
|
260
308
|
```
|
261
309
|
|
262
310
|
### Step 5: Run Tests
|
@@ -291,6 +339,7 @@ If you see warnings about CSS module exports, ensure you've updated all imports
|
|
291
339
|
### Build Error: exportLocalsConvention Incompatible with namedExport
|
292
340
|
|
293
341
|
If you see this error:
|
342
|
+
|
294
343
|
```
|
295
344
|
"exportLocalsConvention" with "camelCase" value is incompatible with "namedExport: true" option
|
296
345
|
```
|
@@ -312,30 +361,35 @@ If you want to use `'camelCase'` (which exports both original and camelCase vers
|
|
312
361
|
If you experience unexpected peer dependency warnings after upgrading to v9, you may need to clear your package manager's cache and reinstall dependencies. This ensures the new optional peer dependency configuration takes effect properly.
|
313
362
|
|
314
363
|
**For npm:**
|
364
|
+
|
315
365
|
```bash
|
316
366
|
rm -rf node_modules package-lock.json
|
317
367
|
npm install
|
318
368
|
```
|
319
369
|
|
320
370
|
**For Yarn:**
|
371
|
+
|
321
372
|
```bash
|
322
373
|
rm -rf node_modules yarn.lock
|
323
374
|
yarn install
|
324
375
|
```
|
325
376
|
|
326
377
|
**For pnpm:**
|
378
|
+
|
327
379
|
```bash
|
328
380
|
rm -rf node_modules pnpm-lock.yaml
|
329
381
|
pnpm install
|
330
382
|
```
|
331
383
|
|
332
384
|
**For Bun:**
|
385
|
+
|
333
386
|
```bash
|
334
387
|
rm -rf node_modules bun.lockb
|
335
388
|
bun install
|
336
389
|
```
|
337
390
|
|
338
391
|
**When is this necessary?**
|
392
|
+
|
339
393
|
- If you see peer dependency warnings for packages you don't use (e.g., warnings about Babel when using SWC)
|
340
394
|
- If your package manager cached the old dependency resolution from v8
|
341
395
|
- After switching transpilers or bundlers (e.g., from Babel to SWC, or webpack to rspack)
|
data/lib/shakapacker/version.rb
CHANGED
data/lib/shakapacker.rb
CHANGED
data/package/env.ts
CHANGED
@@ -6,21 +6,32 @@ const { isFileNotFoundError } = require("./utils/errorHelpers")
|
|
6
6
|
const { sanitizeEnvValue } = require("./utils/pathValidation")
|
7
7
|
|
8
8
|
const NODE_ENVIRONMENTS = ["development", "production", "test"] as const
|
9
|
-
const DEFAULT = "production"
|
10
9
|
|
11
10
|
// Sanitize environment variables to prevent injection
|
12
11
|
const initialRailsEnv = sanitizeEnvValue(process.env.RAILS_ENV)
|
13
12
|
const rawNodeEnv = sanitizeEnvValue(process.env.NODE_ENV)
|
14
13
|
|
14
|
+
// Default NODE_ENV based on RAILS_ENV to match bin/shakapacker behavior (see lib/shakapacker/runner.rb:27)
|
15
|
+
// - RAILS_ENV=production → DEFAULT="production" (safe for production builds)
|
16
|
+
// - RAILS_ENV=development, test, staging, or unset → DEFAULT="development" (good DX for dev server)
|
17
|
+
// This ensures the dev server works out of the box without requiring NODE_ENV to be set explicitly
|
18
|
+
const DEFAULT = initialRailsEnv === "production" ? "production" : "development"
|
19
|
+
|
15
20
|
// Validate NODE_ENV strictly
|
16
21
|
const nodeEnv =
|
17
|
-
rawNodeEnv &&
|
22
|
+
rawNodeEnv &&
|
23
|
+
NODE_ENVIRONMENTS.includes(rawNodeEnv as (typeof NODE_ENVIRONMENTS)[number])
|
24
|
+
? rawNodeEnv
|
25
|
+
: DEFAULT
|
18
26
|
|
19
27
|
// Log warning if NODE_ENV was invalid
|
20
|
-
if (
|
28
|
+
if (
|
29
|
+
rawNodeEnv &&
|
30
|
+
!NODE_ENVIRONMENTS.includes(rawNodeEnv as (typeof NODE_ENVIRONMENTS)[number])
|
31
|
+
) {
|
21
32
|
console.warn(
|
22
33
|
`[SHAKAPACKER WARNING] Invalid NODE_ENV value: ${rawNodeEnv}. ` +
|
23
|
-
|
34
|
+
`Valid values are: ${NODE_ENVIRONMENTS.join(", ")}. Using default: ${DEFAULT}`
|
24
35
|
)
|
25
36
|
}
|
26
37
|
|
@@ -42,13 +53,13 @@ try {
|
|
42
53
|
} catch (defaultError) {
|
43
54
|
throw new Error(
|
44
55
|
`Failed to load Shakapacker configuration.\n` +
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
56
|
+
`Neither user config (${configPath}) nor default config (${defaultConfigPath}) could be loaded.\n\n` +
|
57
|
+
`To fix this issue:\n` +
|
58
|
+
`1. Create a config/shakapacker.yml file in your project\n` +
|
59
|
+
`2. Or set the SHAKAPACKER_CONFIG environment variable to point to your config file\n` +
|
60
|
+
`3. Or reinstall Shakapacker to restore the default configuration:\n` +
|
61
|
+
` npm install shakapacker --force\n` +
|
62
|
+
` yarn add shakapacker --force`
|
52
63
|
)
|
53
64
|
}
|
54
65
|
} else {
|
@@ -61,13 +72,14 @@ const regex = new RegExp(`^(${availableEnvironments})$`, "g")
|
|
61
72
|
|
62
73
|
const runningWebpackDevServer = process.env.WEBPACK_SERVE === "true"
|
63
74
|
|
64
|
-
const validatedRailsEnv =
|
75
|
+
const validatedRailsEnv =
|
76
|
+
initialRailsEnv && initialRailsEnv.match(regex) ? initialRailsEnv : DEFAULT
|
65
77
|
|
66
78
|
if (initialRailsEnv && validatedRailsEnv !== initialRailsEnv) {
|
67
79
|
/* eslint no-console:0 */
|
68
80
|
console.warn(
|
69
81
|
`[SHAKAPACKER WARNING] Environment '${initialRailsEnv}' not found in the configuration.\n` +
|
70
|
-
|
82
|
+
`Using '${DEFAULT}' configuration as a fallback.`
|
71
83
|
)
|
72
84
|
}
|
73
85
|
|
data/package.json
CHANGED
data/test/package/config.test.js
CHANGED
@@ -71,6 +71,7 @@ describe("Config", () => {
|
|
71
71
|
})
|
72
72
|
|
73
73
|
test("should allow enabling integrity", () => {
|
74
|
+
process.env.RAILS_ENV = "production"
|
74
75
|
process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
|
75
76
|
const config = require("../../package/config")
|
76
77
|
|
@@ -78,6 +79,7 @@ describe("Config", () => {
|
|
78
79
|
})
|
79
80
|
|
80
81
|
test("should allow configuring hash functions", () => {
|
82
|
+
process.env.RAILS_ENV = "production"
|
81
83
|
process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
|
82
84
|
const config = require("../../package/config")
|
83
85
|
|
@@ -89,6 +91,7 @@ describe("Config", () => {
|
|
89
91
|
})
|
90
92
|
|
91
93
|
test("should allow configuring crossorigin", () => {
|
94
|
+
process.env.RAILS_ENV = "production"
|
92
95
|
process.env.SHAKAPACKER_CONFIG = "config/shakapacker_integrity.yml"
|
93
96
|
const config = require("../../package/config")
|
94
97
|
|
data/test/package/env.test.js
CHANGED
@@ -24,6 +24,18 @@ describe("Env", () => {
|
|
24
24
|
delete process.env.NODE_ENV
|
25
25
|
expect(require("../../package/env")).toStrictEqual({
|
26
26
|
railsEnv: "development",
|
27
|
+
nodeEnv: "development",
|
28
|
+
isProduction: false,
|
29
|
+
isDevelopment: true,
|
30
|
+
runningWebpackDevServer: false
|
31
|
+
})
|
32
|
+
})
|
33
|
+
|
34
|
+
test("with undefined NODE_ENV and RAILS_ENV set to production", () => {
|
35
|
+
process.env.RAILS_ENV = "production"
|
36
|
+
delete process.env.NODE_ENV
|
37
|
+
expect(require("../../package/env")).toStrictEqual({
|
38
|
+
railsEnv: "production",
|
27
39
|
nodeEnv: "production",
|
28
40
|
isProduction: true,
|
29
41
|
isDevelopment: false,
|
@@ -35,10 +47,10 @@ describe("Env", () => {
|
|
35
47
|
delete process.env.NODE_ENV
|
36
48
|
delete process.env.RAILS_ENV
|
37
49
|
expect(require("../../package/env")).toStrictEqual({
|
38
|
-
railsEnv: "
|
39
|
-
nodeEnv: "
|
40
|
-
isProduction:
|
41
|
-
isDevelopment:
|
50
|
+
railsEnv: "development",
|
51
|
+
nodeEnv: "development",
|
52
|
+
isProduction: false,
|
53
|
+
isDevelopment: true,
|
42
54
|
runningWebpackDevServer: false
|
43
55
|
})
|
44
56
|
})
|
@@ -48,10 +60,33 @@ describe("Env", () => {
|
|
48
60
|
process.env.NODE_ENV = "staging"
|
49
61
|
expect(require("../../package/env")).toStrictEqual({
|
50
62
|
railsEnv: "staging",
|
51
|
-
nodeEnv: "
|
52
|
-
isProduction:
|
53
|
-
isDevelopment:
|
63
|
+
nodeEnv: "development",
|
64
|
+
isProduction: false,
|
65
|
+
isDevelopment: true,
|
66
|
+
runningWebpackDevServer: false
|
67
|
+
})
|
68
|
+
})
|
69
|
+
|
70
|
+
test("rejects malicious NODE_ENV values and uses default", () => {
|
71
|
+
process.env.RAILS_ENV = "development"
|
72
|
+
process.env.NODE_ENV = "../../../etc/passwd"
|
73
|
+
expect(require("../../package/env")).toStrictEqual({
|
74
|
+
railsEnv: "development",
|
75
|
+
nodeEnv: "development",
|
76
|
+
isProduction: false,
|
77
|
+
isDevelopment: true,
|
54
78
|
runningWebpackDevServer: false
|
55
79
|
})
|
56
80
|
})
|
81
|
+
|
82
|
+
test("warns when NODE_ENV is invalid", () => {
|
83
|
+
const consoleSpy = jest.spyOn(console, "warn").mockImplementation()
|
84
|
+
process.env.NODE_ENV = "invalid"
|
85
|
+
delete process.env.RAILS_ENV
|
86
|
+
require("../../package/env")
|
87
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
88
|
+
expect.stringContaining("Invalid NODE_ENV value: invalid")
|
89
|
+
)
|
90
|
+
consoleSpy.mockRestore()
|
91
|
+
})
|
57
92
|
})
|
@@ -7,6 +7,10 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
|
|
7
7
|
const rootPath = process.cwd()
|
8
8
|
chdirTestApp()
|
9
9
|
|
10
|
+
// Set NODE_ENV before requiring modules to ensure contenthash is enabled
|
11
|
+
// Base config tests expect production-like behavior with contenthash
|
12
|
+
process.env.NODE_ENV = "production"
|
13
|
+
|
10
14
|
const baseConfig = require("../../../package/environments/base")
|
11
15
|
const config = require("../../../package/config")
|
12
16
|
|
@@ -19,7 +19,7 @@ describe("Custom environment", () => {
|
|
19
19
|
describe("generateWebpackConfig", () => {
|
20
20
|
beforeEach(() => jest.resetModules())
|
21
21
|
|
22
|
-
test("should use staging config and default
|
22
|
+
test("should use staging config and default development environment", () => {
|
23
23
|
process.env.RAILS_ENV = "staging"
|
24
24
|
delete process.env.NODE_ENV
|
25
25
|
|
@@ -31,9 +31,10 @@ describe("Custom environment", () => {
|
|
31
31
|
resolve("public", "packs-staging")
|
32
32
|
)
|
33
33
|
expect(webpackConfig.output.publicPath).toBe("/packs-staging/")
|
34
|
+
// With the NODE_ENV fix, staging now defaults to development environment
|
35
|
+
// instead of production, providing better DX for staging environments
|
34
36
|
expect(webpackConfig).toMatchObject({
|
35
|
-
devtool: "source-map"
|
36
|
-
stats: "normal"
|
37
|
+
devtool: "cheap-module-source-map"
|
37
38
|
})
|
38
39
|
})
|
39
40
|
})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.0.beta.
|
4
|
+
version: 9.0.0.beta.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -347,7 +347,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
347
347
|
licenses:
|
348
348
|
- MIT
|
349
349
|
metadata:
|
350
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.
|
350
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.10
|
351
351
|
rdoc_options: []
|
352
352
|
require_paths:
|
353
353
|
- lib
|