shakapacker 8.2.0 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/docs/react.md +2 -10
- data/docs/subresource_integrity.md +54 -0
- data/lib/install/config/shakapacker.yml +13 -3
- data/lib/install/template.rb +1 -1
- data/lib/shakapacker/configuration.rb +4 -0
- data/lib/shakapacker/helper.rb +40 -4
- data/lib/shakapacker/manifest.rb +6 -1
- data/lib/shakapacker/version.rb +1 -1
- data/package/babel/preset.js +16 -5
- data/package/config.js +2 -0
- data/package/environments/base.js +32 -3
- data/package/index.d.ts +40 -3
- data/package/rules/index.js +13 -17
- data/package/utils/helpers.js +6 -2
- data/package.json +15 -10
- data/test/helpers.js +1 -1
- data/test/package/config.test.js +40 -0
- data/yarn.lock +2049 -2399
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ccbba3c39a550ae683e13c45e3ac4f79733ae6ffebabf2d6ab55f37b7427d99
|
4
|
+
data.tar.gz: 569998bb9475e8ed2b8ba786d1ccdf2b84d562d61ba8ef78d08ad195c3ea2230
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c529d5f970394ca40b79d7ac1ddb430c197cbd508bf533195f13d81937cca872232436bcb92c5a8f38eafc9968ef0d1a82c280120545e421d143dcf72d12f0c
|
7
|
+
data.tar.gz: b341f56e92124b2418b56483dab20374aee03fca5de1e946e5b09ce1f2ca7d0daa16c47ed365a90f51a8f5bdf55235dbe9107cf95dc0a3b9b00e19056f72f343
|
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,38 @@
|
|
4
4
|
* Please see the [v6 Upgrade Guide](./docs/v6_upgrade.md) to go from versions prior to v6.
|
5
5
|
* [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).
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
## Versions
|
7
|
+
# Versions
|
10
8
|
## [Unreleased]
|
11
9
|
Changes since the last non-beta release.
|
12
10
|
|
11
|
+
## [v8.4.0] - September 8, 2025
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Support for subresource integrity. [PR 570](https://github.com/shakacode/shakapacker/pull/570) by [panagiotisplytas](https://github.com/panagiotisplytas)
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
|
19
|
+
- 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).
|
20
|
+
- Remove duplicate word in comment from generated `shakapacker.yml` config [PR 572](https://github.com/shakacode/shakapacker/pull/572) by [G-Rath](https://github.com/g-rath).
|
21
|
+
- fix: update webpack-dev-server to secure versions (^4.15.2 || ^5.2.2) [PR 585](https://github.com/shakacode/shakapacker/pull/585) by [justin808](https://github.com/justin808)
|
22
|
+
|
23
|
+
|
24
|
+
## [v8.3.0] - April 25, 2025
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- 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).
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
- Instead of a fixed `core-js` version, take the current one from `node_modules` if available. [PR 556](https://github.com/shakacode/shakapacker/pull/556) by [alexeyr-ci2](https://github.com/alexeyr-ci2).
|
32
|
+
- Require webpack >= 5.76.0 to reduce exposure to CVE-2023-28154. [PR 568](https://github.com/shakacode/shakapacker/pull/568) by [granowski](https://github.com/granowski).
|
33
|
+
|
34
|
+
### Fixed
|
35
|
+
|
36
|
+
- 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).
|
37
|
+
|
38
|
+
## [v8.2.0] - March 12, 2025
|
13
39
|
### Added
|
14
40
|
|
15
41
|
- 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).
|
@@ -406,7 +432,10 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
|
|
406
432
|
## v5.4.3 and prior changes from rails/webpacker
|
407
433
|
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
|
408
434
|
|
409
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.
|
435
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.4.0...main
|
436
|
+
[v8.4.0]: https://github.com/shakacode/shakapacker/compare/v8.3.0...v8.4.0
|
437
|
+
[v8.3.0]: https://github.com/shakacode/shakapacker/compare/v8.2.0...v8.3.0
|
438
|
+
[v8.2.0]: https://github.com/shakacode/shakapacker/compare/v8.1.0...v8.2.0
|
410
439
|
[v8.1.0]: https://github.com/shakacode/shakapacker/compare/v8.0.2...v8.1.0
|
411
440
|
[v8.0.2]: https://github.com/shakacode/shakapacker/compare/v8.0.1...v8.0.2
|
412
441
|
[v8.0.1]: https://github.com/shakacode/shakapacker/compare/v8.0.0...v8.0.1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -625,7 +625,7 @@ By default, you will find the Shakapacker preset in your `package.json`. Note, y
|
|
625
625
|
]
|
626
626
|
},
|
627
627
|
```
|
628
|
-
Optionally, you can change your Babel configuration by removing these lines in your `package.json` and adding [a Babel
|
628
|
+
Optionally, you can change your Babel configuration by removing these lines in your `package.json` and adding [a Babel configuration file](https://babeljs.io/docs/en/config-files) to your project. For an example of customization based on the original, see [Customizing Babel Config](./docs/customizing_babel_config.md).
|
629
629
|
|
630
630
|
|
631
631
|
### SWC configuration
|
data/docs/react.md
CHANGED
@@ -61,11 +61,7 @@ const webpackConfig = generateWebpackConfig();
|
|
61
61
|
|
62
62
|
if (isDevelopment && inliningCss) {
|
63
63
|
webpackConfig.plugins.push(
|
64
|
-
new ReactRefreshWebpackPlugin(
|
65
|
-
overlay: {
|
66
|
-
sockPort: webpackConfig.devServer.port,
|
67
|
-
},
|
68
|
-
})
|
64
|
+
new ReactRefreshWebpackPlugin()
|
69
65
|
);
|
70
66
|
}
|
71
67
|
|
@@ -201,11 +197,7 @@ const webpackConfig = generateWebpackConfig();
|
|
201
197
|
|
202
198
|
if (isDevelopment && inliningCss) {
|
203
199
|
webpackConfig.plugins.push(
|
204
|
-
new ReactRefreshWebpackPlugin(
|
205
|
-
overlay: {
|
206
|
-
sockPort: webpackConfig.devServer.port,
|
207
|
-
},
|
208
|
-
})
|
200
|
+
new ReactRefreshWebpackPlugin()
|
209
201
|
);
|
210
202
|
}
|
211
203
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Subresource integrity
|
2
|
+
It's a cryptographic hash that helps browsers check that the served js or css file has not been tampered in any way.
|
3
|
+
|
4
|
+
[MDN - Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)
|
5
|
+
|
6
|
+
## Important notes
|
7
|
+
- If you somehow modify the file after the hash was generated, it will automatically be considered as tampered, and the browser will not allow it to be executed.
|
8
|
+
- Enabling subresource integrity generation, will change the structure of `manifest.json`. Keep that in mind if you utilize this file in any other custom implementation.
|
9
|
+
|
10
|
+
Before:
|
11
|
+
```json
|
12
|
+
{
|
13
|
+
"application.js": "/path_to_asset"
|
14
|
+
}
|
15
|
+
```
|
16
|
+
|
17
|
+
After:
|
18
|
+
```json
|
19
|
+
{
|
20
|
+
"application.js": {
|
21
|
+
"src": "/path_to_asset",
|
22
|
+
"integrity": "<sha256-hash> <sha384-hash> <sha512-hash>"
|
23
|
+
}
|
24
|
+
}
|
25
|
+
```
|
26
|
+
|
27
|
+
## Possible CORS issues
|
28
|
+
Enabling subresource integrity for an asset, actually enforces CORS checks on that resource too. Which means that
|
29
|
+
if you haven't set that up properly beforehand, it will probably lead to CORS errors with cached assets.
|
30
|
+
|
31
|
+
[MDN - How browsers handle Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#how_browsers_handle_subresource_integrity)
|
32
|
+
|
33
|
+
## Configuration
|
34
|
+
|
35
|
+
By default, this setting is disabled, to ensure backwards compatibility, and let developers adapt at their own pace.
|
36
|
+
This may change in the future, as it is a very nice security feature, and it should be enabled by default.
|
37
|
+
|
38
|
+
To enable it, just add this in `shakapacker.yml`
|
39
|
+
```yml
|
40
|
+
integrity:
|
41
|
+
enabled: true
|
42
|
+
```
|
43
|
+
|
44
|
+
For further customization, you can also utilize the options `hash_functions` that control the functions used to generate
|
45
|
+
integrity hashes. And `cross_origin` that sets the cross-origin loading attribute.
|
46
|
+
|
47
|
+
```yml
|
48
|
+
integrity:
|
49
|
+
enabled: true
|
50
|
+
hash_functions: ["sha256", "sha384", "sha512"]
|
51
|
+
cross_origin: "anonymous" # or "use-credentials"
|
52
|
+
```
|
53
|
+
|
54
|
+
This will utilize under the hood webpack-subresource-integrity plugin and will modify `manifest.json` to include integrity hashes.
|
@@ -42,7 +42,7 @@ default: &default
|
|
42
42
|
# Raises an error if there is a mismatch in the shakapacker gem and npm package being used
|
43
43
|
ensure_consistent_versioning: true
|
44
44
|
|
45
|
-
# Select whether the compiler will use SHA digest ('digest' option) or most
|
45
|
+
# Select whether the compiler will use SHA digest ('digest' option) or most recent modified timestamp ('mtime') to determine freshness
|
46
46
|
compiler_strategy: digest
|
47
47
|
|
48
48
|
# Select whether the compiler will always use a content hash and not just in production
|
@@ -55,6 +55,16 @@ default: &default
|
|
55
55
|
# SHAKAPACKER_ASSET_HOST will override both configurations.
|
56
56
|
# asset_host: custom-path
|
57
57
|
|
58
|
+
# Utilizing webpack-subresource-integrity plugin, will generate integrity hashes for all entries in manifest.json
|
59
|
+
# https://github.com/waysact/webpack-subresource-integrity/tree/main/webpack-subresource-integrity
|
60
|
+
integrity:
|
61
|
+
enabled: false
|
62
|
+
# Which cryptographic function(s) to use, for generating the integrity hash(es). Default sha-384. Other possible values sha256, sha512
|
63
|
+
hash_functions: ["sha384"]
|
64
|
+
# Default "anonymous". Other possible value "use-credentials"
|
65
|
+
# https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#cross-origin_resource_sharing_and_subresource_integrity
|
66
|
+
cross_origin: "anonymous"
|
67
|
+
|
58
68
|
development:
|
59
69
|
<<: *default
|
60
70
|
compile: true
|
@@ -71,7 +81,7 @@ development:
|
|
71
81
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
72
82
|
# Used instead of the `hot` key in https://webpack.js.org/configuration/dev-server/#devserverhot
|
73
83
|
hmr: false
|
74
|
-
# If HMR is on, CSS will
|
84
|
+
# If HMR is on, CSS will be inlined by delivering it as part of the script payload via style-loader. Be sure
|
75
85
|
# that you add style-loader to your project dependencies.
|
76
86
|
#
|
77
87
|
# If you want to instead deliver CSS via <link> with the mini-css-extract-plugin, set inline_css to false.
|
@@ -114,7 +124,7 @@ production:
|
|
114
124
|
# Production depends on precompilation of packs prior to booting for performance.
|
115
125
|
compile: false
|
116
126
|
|
117
|
-
# Use content hash for naming assets. Cannot be overridden
|
127
|
+
# Use content hash for naming assets. Cannot be overridden in production.
|
118
128
|
useContentHash: true
|
119
129
|
|
120
130
|
# Cache manifest.json for performance
|
data/lib/install/template.rb
CHANGED
@@ -136,7 +136,7 @@ Dir.chdir(Rails.root) do
|
|
136
136
|
dev_dependencies_to_add = []
|
137
137
|
|
138
138
|
peers.each do |(package, version)|
|
139
|
-
major_version = version.match(/(\d+)/)[1]
|
139
|
+
major_version = version.split("||").last.match(/(\d+)/)[1]
|
140
140
|
entry = "#{package}@#{major_version}"
|
141
141
|
|
142
142
|
if dev_dependency_packages.include? package
|
data/lib/shakapacker/helper.rb
CHANGED
@@ -109,11 +109,11 @@ module Shakapacker::Helper
|
|
109
109
|
@javascript_pack_tag_loaded = true
|
110
110
|
|
111
111
|
capture do
|
112
|
-
|
112
|
+
render_tags(async, :javascript, **options.dup.tap { |o| o[:async] = true })
|
113
113
|
concat "\n" if async.any? && deferred.any?
|
114
|
-
|
114
|
+
render_tags(deferred, :javascript, **options.dup.tap { |o| o[:defer] = true })
|
115
115
|
concat "\n" if sync.any? && deferred.any?
|
116
|
-
|
116
|
+
render_tags(sync, :javascript, options)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -166,7 +166,9 @@ module Shakapacker::Helper
|
|
166
166
|
|
167
167
|
@stylesheet_pack_tag_loaded = true
|
168
168
|
|
169
|
-
|
169
|
+
capture do
|
170
|
+
render_tags(requested_packs | appended_packs, :stylesheet, options)
|
171
|
+
end
|
170
172
|
end
|
171
173
|
|
172
174
|
def append_stylesheet_pack_tag(*names)
|
@@ -238,4 +240,38 @@ module Shakapacker::Helper
|
|
238
240
|
rescue
|
239
241
|
path_to_asset(current_shakapacker_instance.manifest.lookup!(name), options)
|
240
242
|
end
|
243
|
+
|
244
|
+
def lookup_integrity(source)
|
245
|
+
(source.respond_to?(:dig) && source.dig("integrity")) || nil
|
246
|
+
end
|
247
|
+
|
248
|
+
def lookup_source(source)
|
249
|
+
(source.respond_to?(:dig) && source.dig("src")) || source
|
250
|
+
end
|
251
|
+
|
252
|
+
# Handles rendering javascript and stylesheet tags with integrity, if that's enabled.
|
253
|
+
def render_tags(sources, type, options)
|
254
|
+
return unless sources.present? || type.present?
|
255
|
+
|
256
|
+
sources.each.with_index do |source, index|
|
257
|
+
tag_source = lookup_source(source)
|
258
|
+
|
259
|
+
if current_shakapacker_instance.config.integrity[:enabled]
|
260
|
+
integrity = lookup_integrity(source)
|
261
|
+
|
262
|
+
if integrity.present?
|
263
|
+
options[:integrity] = integrity
|
264
|
+
options[:crossorigin] = current_shakapacker_instance.config.integrity[:cross_origin]
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
if type == :javascript
|
269
|
+
concat javascript_include_tag(tag_source, **options)
|
270
|
+
else
|
271
|
+
concat stylesheet_link_tag(tag_source, **options)
|
272
|
+
end
|
273
|
+
|
274
|
+
concat "\n" unless index == sources.size - 1
|
275
|
+
end
|
276
|
+
end
|
241
277
|
end
|
data/lib/shakapacker/manifest.rb
CHANGED
@@ -67,7 +67,12 @@ class Shakapacker::Manifest
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def find(name)
|
70
|
-
data[name.to_s].
|
70
|
+
return nil unless data[name.to_s].present?
|
71
|
+
|
72
|
+
return data[name.to_s] unless data[name.to_s].respond_to?(:dig)
|
73
|
+
|
74
|
+
# Try to return src, if that fails, (ex. entrypoints object) return the whole object.
|
75
|
+
data[name.to_s].dig("src") || data[name.to_s]
|
71
76
|
end
|
72
77
|
|
73
78
|
def full_pack_name(name, pack_type)
|
data/lib/shakapacker/version.rb
CHANGED
data/package/babel/preset.js
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
-
const { moduleExists } = require("
|
1
|
+
const { moduleExists, packageFullVersion } = require("../utils/helpers")
|
2
2
|
|
3
|
+
const coreJsVersion = () => {
|
4
|
+
try {
|
5
|
+
return packageFullVersion("core-js").match(/^\d+\.\d+/)[0]
|
6
|
+
} catch (e) {
|
7
|
+
if (e.code !== "MODULE_NOT_FOUND") {
|
8
|
+
throw e
|
9
|
+
}
|
10
|
+
|
11
|
+
return "3.8"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
/** @param api {import("@babel/core").ConfigAPI} */
|
3
16
|
module.exports = function config(api) {
|
4
17
|
const validEnv = ["development", "test", "production"]
|
5
18
|
const currentEnv = api.env()
|
@@ -9,9 +22,7 @@ module.exports = function config(api) {
|
|
9
22
|
|
10
23
|
if (!validEnv.includes(currentEnv)) {
|
11
24
|
throw new Error(
|
12
|
-
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${
|
13
|
-
currentEnv
|
14
|
-
)}".`
|
25
|
+
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${currentEnv}".`
|
15
26
|
)
|
16
27
|
}
|
17
28
|
|
@@ -22,7 +33,7 @@ module.exports = function config(api) {
|
|
22
33
|
"@babel/preset-env",
|
23
34
|
{
|
24
35
|
useBuiltIns: "entry",
|
25
|
-
corejs:
|
36
|
+
corejs: coreJsVersion(),
|
26
37
|
modules: "auto",
|
27
38
|
bugfixes: true,
|
28
39
|
exclude: ["transform-typeof-symbol"]
|
data/package/config.js
CHANGED
@@ -50,5 +50,7 @@ if (config.manifest_path) {
|
|
50
50
|
} else {
|
51
51
|
config.manifestPath = resolve(config.outputPath, "manifest.json")
|
52
52
|
}
|
53
|
+
// Ensure no duplicate hash functions exist in the returned config object
|
54
|
+
config.integrity.hash_functions = [...new Set(config.integrity.hash_functions)]
|
53
55
|
|
54
56
|
module.exports = config
|
@@ -4,6 +4,7 @@
|
|
4
4
|
const { existsSync, readdirSync } = require("fs")
|
5
5
|
const { basename, dirname, join, relative, resolve } = require("path")
|
6
6
|
const extname = require("path-complete-extname")
|
7
|
+
// TODO: Change to `const { WebpackAssetsManifest }` when dropping 'webpack-assets-manifest < 6.0.0' (Node >=20.10.0) support
|
7
8
|
const WebpackAssetsManifest = require("webpack-assets-manifest")
|
8
9
|
const webpack = require("webpack")
|
9
10
|
const rules = require("../rules")
|
@@ -72,15 +73,22 @@ const getModulePaths = () => {
|
|
72
73
|
return result
|
73
74
|
}
|
74
75
|
|
76
|
+
// TODO: Remove WebpackAssetsManifestConstructor workaround when dropping 'webpack-assets-manifest < 6.0.0' (Node >=20.10.0) support
|
77
|
+
const WebpackAssetsManifestConstructor =
|
78
|
+
"WebpackAssetsManifest" in WebpackAssetsManifest
|
79
|
+
? WebpackAssetsManifest.WebpackAssetsManifest
|
80
|
+
: WebpackAssetsManifest
|
75
81
|
const getPlugins = () => {
|
76
82
|
const plugins = [
|
77
83
|
new webpack.EnvironmentPlugin(process.env),
|
78
|
-
new
|
84
|
+
new WebpackAssetsManifestConstructor({
|
79
85
|
entrypoints: true,
|
80
86
|
writeToDisk: true,
|
81
87
|
output: config.manifestPath,
|
82
88
|
entrypointsUseAssets: true,
|
83
|
-
publicPath: config.publicPathWithoutCDN
|
89
|
+
publicPath: config.publicPathWithoutCDN,
|
90
|
+
integrity: config.integrity.enabled,
|
91
|
+
integrityHashes: config.integrity.hash_functions
|
84
92
|
})
|
85
93
|
]
|
86
94
|
|
@@ -99,6 +107,22 @@ const getPlugins = () => {
|
|
99
107
|
)
|
100
108
|
}
|
101
109
|
|
110
|
+
if (
|
111
|
+
moduleExists("webpack-subresource-integrity") &&
|
112
|
+
config.integrity.enabled
|
113
|
+
) {
|
114
|
+
const {
|
115
|
+
SubresourceIntegrityPlugin
|
116
|
+
} = require("webpack-subresource-integrity")
|
117
|
+
|
118
|
+
plugins.push(
|
119
|
+
new SubresourceIntegrityPlugin({
|
120
|
+
hashFuncNames: config.integrity.hash_functions,
|
121
|
+
enabled: isProduction
|
122
|
+
})
|
123
|
+
)
|
124
|
+
}
|
125
|
+
|
102
126
|
return plugins
|
103
127
|
}
|
104
128
|
|
@@ -115,7 +139,12 @@ module.exports = {
|
|
115
139
|
// https://webpack.js.org/configuration/output/#outputhotupdatechunkfilename
|
116
140
|
hotUpdateChunkFilename: "js/[id].[fullhash].hot-update.js",
|
117
141
|
path: config.outputPath,
|
118
|
-
publicPath: config.publicPath
|
142
|
+
publicPath: config.publicPath,
|
143
|
+
|
144
|
+
// This is required for SRI to work.
|
145
|
+
crossOriginLoading: config.integrity.enabled
|
146
|
+
? config.integrity.cross_origin
|
147
|
+
: false
|
119
148
|
},
|
120
149
|
entry: getEntryObject(),
|
121
150
|
resolve: {
|
data/package/index.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
declare module 'shakapacker' {
|
2
|
-
import { Configuration } from 'webpack'
|
2
|
+
import { Configuration, RuleSetRule } from 'webpack'
|
3
|
+
import * as https from 'node:https';
|
3
4
|
|
4
5
|
export interface Config {
|
5
6
|
source_path: string
|
@@ -32,12 +33,48 @@ declare module 'shakapacker' {
|
|
32
33
|
runningWebpackDevServer: boolean
|
33
34
|
}
|
34
35
|
|
36
|
+
type Header = Array<{ key: string; value: string }> | Record<string, string | string[]>
|
37
|
+
type ServerType = 'http' | 'https' | 'spdy'
|
38
|
+
type WebSocketType = 'sockjs' | 'ws'
|
39
|
+
|
40
|
+
/**
|
41
|
+
* This has the same keys and behavior as https://webpack.js.org/configuration/dev-server/ except:
|
42
|
+
* 1. `hot` is replaced by `hmr`;
|
43
|
+
* 2. Camel-cased properties are replaced by snake-cased ones.
|
44
|
+
* @see {import('webpack-dev-server').Configuration}
|
45
|
+
*/
|
46
|
+
interface DevServerConfig {
|
47
|
+
allowed_hosts?: 'all' | 'auto' | string | string[]
|
48
|
+
bonjour?: boolean | Record<string, unknown> // bonjour.BonjourOptions
|
49
|
+
client?: Record<string, unknown> // Client
|
50
|
+
compress?: boolean
|
51
|
+
dev_middleware?: Record<string, unknown> // webpackDevMiddleware.Options
|
52
|
+
headers?: Header | (() => Header)
|
53
|
+
history_api_fallback?: boolean | Record<string, unknown> // HistoryApiFallbackOptions
|
54
|
+
hmr?: 'only' | boolean
|
55
|
+
host?: 'local-ip' | 'local-ipv4' | 'local-ipv6' | string
|
56
|
+
http2?: boolean
|
57
|
+
https?: boolean | https.ServerOptions
|
58
|
+
ipc?: boolean | string
|
59
|
+
magic_html?: boolean
|
60
|
+
live_reload?: boolean
|
61
|
+
open?: boolean | string | string[] | Record<string, unknown> | Record<string, unknown>[]
|
62
|
+
port?: 'auto' | string | number
|
63
|
+
proxy?: unknown // ProxyConfigMap | ProxyConfigArray
|
64
|
+
setup_exit_signals?: boolean
|
65
|
+
static?: boolean | string | unknown // Static | Array<string | Static>
|
66
|
+
watch_files?: string | string[] | unknown // WatchFiles | Array<WatchFiles | string>
|
67
|
+
web_socket_server?: string | boolean | WebSocketType | { type?: string | boolean | WebSocketType, options?: Record<string, unknown> }
|
68
|
+
server?: string | boolean | ServerType | { type?: string | boolean | ServerType, options?: https.ServerOptions }
|
69
|
+
[otherWebpackDevServerConfigKey: string]: unknown
|
70
|
+
}
|
71
|
+
|
35
72
|
export const config: Config
|
36
|
-
export const devServer:
|
73
|
+
export const devServer: DevServerConfig
|
37
74
|
export function generateWebpackConfig(extraConfig?: Configuration): Configuration
|
38
75
|
export const baseConfig: Configuration
|
39
76
|
export const env: Env
|
40
|
-
export const rules:
|
77
|
+
export const rules: RuleSetRule[]
|
41
78
|
export function moduleExists(packageName: string): boolean
|
42
79
|
export function canProcess<T = unknown>(rule: string, fn: (modulePath: string) => T): T | null
|
43
80
|
export const inliningCss: boolean
|
data/package/rules/index.js
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
/* eslint import/no-dynamic-require: 0 */
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
module.exports = Object.keys(rules)
|
19
|
-
.filter((key) => !!rules[key])
|
20
|
-
.map((key) => rules[key])
|
4
|
+
module.exports = [
|
5
|
+
require("./raw"),
|
6
|
+
require("./file"),
|
7
|
+
require("./css"),
|
8
|
+
require("./sass"),
|
9
|
+
require("./babel"),
|
10
|
+
require("./swc"),
|
11
|
+
require("./esbuild"),
|
12
|
+
require("./erb"),
|
13
|
+
require("./coffee"),
|
14
|
+
require("./less"),
|
15
|
+
require("./stylus")
|
16
|
+
].filter(Boolean)
|
data/package/utils/helpers.js
CHANGED
@@ -41,18 +41,22 @@ const loaderMatches = (configLoader, loaderToCheck, fn) => {
|
|
41
41
|
return fn()
|
42
42
|
}
|
43
43
|
|
44
|
-
const
|
44
|
+
const packageFullVersion = (packageName) => {
|
45
45
|
// eslint-disable-next-line import/no-dynamic-require
|
46
46
|
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
47
47
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
48
|
-
return require(packageJsonPath).version
|
48
|
+
return require(packageJsonPath).version
|
49
49
|
}
|
50
50
|
|
51
|
+
const packageMajorVersion = (packageName) =>
|
52
|
+
packageFullVersion(packageName).match(/^\d+/)[0]
|
53
|
+
|
51
54
|
module.exports = {
|
52
55
|
isBoolean,
|
53
56
|
ensureTrailingSlash,
|
54
57
|
canProcess,
|
55
58
|
moduleExists,
|
56
59
|
loaderMatches,
|
60
|
+
packageFullVersion,
|
57
61
|
packageMajorVersion
|
58
62
|
}
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.4.0",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"homepage": "https://github.com/shakacode/shakapacker",
|
6
6
|
"bugs": {
|
@@ -33,19 +33,20 @@
|
|
33
33
|
"eslint": "^8.0.0",
|
34
34
|
"eslint-config-airbnb": "^19.0.0",
|
35
35
|
"eslint-config-prettier": "^9.0.0",
|
36
|
-
"eslint-plugin-import": "^2.
|
36
|
+
"eslint-plugin-import": "^2.31.0",
|
37
37
|
"eslint-plugin-jest": "^27.9.0",
|
38
|
-
"eslint-plugin-jsx-a11y": "^6.
|
39
|
-
"eslint-plugin-prettier": "^5.
|
40
|
-
"eslint-plugin-react": "^7.
|
38
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
39
|
+
"eslint-plugin-prettier": "^5.2.6",
|
40
|
+
"eslint-plugin-react": "^7.37.5",
|
41
41
|
"eslint-plugin-react-hooks": "^4.6.0",
|
42
|
-
"jest": "^
|
42
|
+
"jest": "^29.7.0",
|
43
43
|
"memory-fs": "^0.5.0",
|
44
44
|
"prettier": "^3.2.5",
|
45
45
|
"swc-loader": "^0.1.15",
|
46
46
|
"thenify": "^3.3.1",
|
47
|
-
"webpack": "
|
47
|
+
"webpack": "5.93.0",
|
48
48
|
"webpack-assets-manifest": "^5.0.6",
|
49
|
+
"webpack-subresource-integrity": "^5.1.0",
|
49
50
|
"webpack-merge": "^5.8.0"
|
50
51
|
},
|
51
52
|
"peerDependencies": {
|
@@ -58,10 +59,11 @@
|
|
58
59
|
"babel-loader": "^8.2.4 || ^9.0.0 || ^10.0.0",
|
59
60
|
"compression-webpack-plugin": "^9.0.0 || ^10.0.0|| ^11.0.0",
|
60
61
|
"terser-webpack-plugin": "^5.3.1",
|
61
|
-
"webpack": "^5.
|
62
|
-
"webpack-assets-manifest": "^5.0.6",
|
62
|
+
"webpack": "^5.76.0",
|
63
|
+
"webpack-assets-manifest": "^5.0.6 || ^6.0.0",
|
64
|
+
"webpack-subresource-integrity": "^5.1.0",
|
63
65
|
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
|
64
|
-
"webpack-dev-server": "^4.
|
66
|
+
"webpack-dev-server": "^4.15.2 || ^5.2.2",
|
65
67
|
"webpack-merge": "^5.8.0 || ^6.0.0"
|
66
68
|
},
|
67
69
|
"peerDependenciesMeta": {
|
@@ -70,6 +72,9 @@
|
|
70
72
|
},
|
71
73
|
"@types/webpack": {
|
72
74
|
"optional": true
|
75
|
+
},
|
76
|
+
"webpack-subresource-integrity": {
|
77
|
+
"optional": true
|
73
78
|
}
|
74
79
|
},
|
75
80
|
"packageManager": "yarn@1.22.22",
|