shakapacker 7.2.0.rc.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/dummy.yml +3 -0
- data/CHANGELOG.md +11 -0
- data/docs/v6_upgrade.md +1 -1
- data/lib/install/config/shakapacker.yml +5 -2
- data/lib/shakapacker/configuration.rb +10 -2
- data/lib/shakapacker/dev_server.rb +7 -1
- data/lib/shakapacker/dev_server_runner.rb +5 -2
- data/lib/shakapacker/digest_strategy.rb +3 -1
- data/lib/shakapacker/version.rb +1 -1
- data/package.json +51 -51
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +84 -18
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +1 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker.yml +1 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml +1 -1
- data/spec/dummy/Gemfile +0 -2
- data/spec/dummy/package.json +1 -2
- data/spec/shakapacker/compiler_spec.rb +5 -9
- data/spec/shakapacker/configuration_spec.rb +55 -14
- data/spec/shakapacker/dev_server_runner_spec.rb +100 -18
- data/spec/shakapacker/digest_strategy_spec.rb +22 -0
- data/spec/shakapacker/spec_helper_initializer.rb +0 -18
- data/spec/shakapacker/test_app/config/shakapacker.yml +1 -1
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae742f19f77532f469332730b57bb1e381c6f238ace6cd5eb113a95f607bde68
|
|
4
|
+
data.tar.gz: 246d1e8dba39d501d219d1e37f4665c8b9f1ab401825173f22cbe270bf95a933
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d57fc47ab68b52626fa66d643d5d62ceeb62fd27b707844c5b187c5ef4e29a15cbb8296a3bbb9204740ecd3769371c05c1ea6046ac2deffc7771bbf2b0839484
|
|
7
|
+
data.tar.gz: 5af5dc61cf4d3f01b17eaca403a8f09ae8a63fe3d2adffdb3dd91969c0e71684118ae0365a893a27690ed4275c03fb1d46a20b30fcb56f8821fdae44110b212e
|
data/.github/workflows/dummy.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,17 @@ _Please add entries here for your pull requests that are not yet released._
|
|
|
11
11
|
|
|
12
12
|
### Added
|
|
13
13
|
- 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).
|
|
14
|
+
- Support `hmr: only` configuration [PR 378](https://github.com/shakacode/shakapacker/pull/378) by [SimenB](https://github.com/SimenB).
|
|
15
|
+
- 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).
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Recommend `server` option instead of deprecated `https` option when `--https` is provided [PR 380](https://github.com/shakacode/shakapacker/pull/380) by [G-Rath](https://github.com/g-rath)
|
|
19
|
+
- Recompile assets on asset host change [PR 364](https://github.com/shakacode/shakapacker/pull/364) by [ahangarha](https://github.com/ahangarha).
|
|
20
|
+
- 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).
|
|
21
|
+
- 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).
|
|
22
|
+
|
|
23
|
+
### Deprecated
|
|
24
|
+
- 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).
|
|
14
25
|
|
|
15
26
|
## [v7.1.0] - September 30, 2023
|
|
16
27
|
|
data/docs/v6_upgrade.md
CHANGED
|
@@ -168,5 +168,5 @@ _If you're on webpacker v5, follow [how to upgrade to webpacker v6.0.0.rc.6 from
|
|
|
168
168
|
|
|
169
169
|
## Examples of v5 to v6
|
|
170
170
|
|
|
171
|
-
1. [React on Rails Project with HMR and SSR](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/compare/webpacker-5.x...
|
|
171
|
+
1. [React on Rails Project with HMR and SSR](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/compare/webpacker-5.x...61e897f2c604085f45b9ab5e23642501e430fb28)
|
|
172
172
|
2. [Vue and Sass Example](https://github.com/guillaumebriday/upgrade-webpacker-5-to-6)
|
|
@@ -50,6 +50,11 @@ default: &default
|
|
|
50
50
|
# https://webpack.js.org/guides/build-performance/#avoid-production-specific-tooling
|
|
51
51
|
useContentHash: false
|
|
52
52
|
|
|
53
|
+
# Setting the asset host here will override Rails.application.config.asset_host.
|
|
54
|
+
# Here, you can set different asset_host per environment. Note that
|
|
55
|
+
# SHAKAPACKER_ASSET_HOST will override both configurations.
|
|
56
|
+
# asset_host: custom-path
|
|
57
|
+
|
|
53
58
|
development:
|
|
54
59
|
<<: *default
|
|
55
60
|
compile: true
|
|
@@ -59,8 +64,6 @@ development:
|
|
|
59
64
|
# Keys not described there are documented inline and in https://github.com/shakacode/shakapacker/
|
|
60
65
|
dev_server:
|
|
61
66
|
# For running dev server with https, set `server: https`.
|
|
62
|
-
# You may use `https: true` instead but notice that it is deprecated in favor of `server: https`
|
|
63
|
-
# Ensure only one of these entries is set.
|
|
64
67
|
# server: https
|
|
65
68
|
|
|
66
69
|
host: localhost
|
|
@@ -117,11 +117,19 @@ class Shakapacker::Configuration
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
def asset_host
|
|
120
|
-
ENV.fetch(
|
|
120
|
+
ENV.fetch(
|
|
121
|
+
"SHAKAPACKER_ASSET_HOST",
|
|
122
|
+
fetch(:asset_host) || ActionController::Base.helpers.compute_asset_host
|
|
123
|
+
)
|
|
121
124
|
end
|
|
122
125
|
|
|
123
126
|
def relative_url_root
|
|
124
|
-
|
|
127
|
+
Shakapacker.puts_deprecation_message "The usage of relative_url_root is deprecated in Shakapacker and will be removed in v8."
|
|
128
|
+
|
|
129
|
+
ENV.fetch(
|
|
130
|
+
"SHAKAPACKER_RELATIVE_URL_ROOT",
|
|
131
|
+
fetch(:relative_url_root) || ActionController::Base.relative_url_root
|
|
132
|
+
)
|
|
125
133
|
end
|
|
126
134
|
|
|
127
135
|
private
|
|
@@ -31,7 +31,13 @@ class Shakapacker::DevServer
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def https?
|
|
34
|
-
|
|
34
|
+
value = fetch(:https)
|
|
35
|
+
|
|
36
|
+
unless value.nil?
|
|
37
|
+
puts "WARNING: `https: true` has been deprecated in favor of `server: 'https'`"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
case value
|
|
35
41
|
when true, "true", Hash
|
|
36
42
|
true
|
|
37
43
|
else
|
|
@@ -48,7 +48,7 @@ module Shakapacker
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
if @argv.include?("--https") && !@https
|
|
51
|
-
$stdout.puts "
|
|
51
|
+
$stdout.puts "--https requires that 'server' in shakapacker.yml is set to 'https'"
|
|
52
52
|
exit!
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -86,7 +86,10 @@ module Shakapacker
|
|
|
86
86
|
cmd += ["--config", @webpack_config]
|
|
87
87
|
cmd += ["--progress", "--color"] if @pretty
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
# Default behavior of webpack-dev-server is @hot = true
|
|
90
|
+
cmd += ["--hot", "only"] if @hot == "only"
|
|
91
|
+
cmd += ["--no-hot"] if !@hot
|
|
92
|
+
|
|
90
93
|
cmd += @argv
|
|
91
94
|
|
|
92
95
|
Dir.chdir(@app_path) do
|
|
@@ -44,7 +44,9 @@ module Shakapacker
|
|
|
44
44
|
end
|
|
45
45
|
files = Dir[*expanded_paths].reject { |f| File.directory?(f) }
|
|
46
46
|
file_ids = files.sort.map { |f| "#{File.basename(f)}/#{Digest::SHA1.file(f).hexdigest}" }
|
|
47
|
-
|
|
47
|
+
|
|
48
|
+
asset_host = Shakapacker.config.asset_host.to_s
|
|
49
|
+
Digest::SHA1.hexdigest(file_ids.join("/").concat(asset_host))
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
def record_compilation_digest
|
data/lib/shakapacker/version.rb
CHANGED
data/package.json
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shakapacker",
|
|
3
|
-
"version": "7.2.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
|
5
|
+
"homepage": "https://github.com/shakacode/shakapacker",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/shakacode/shakapacker/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/shakacode/shakapacker.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "David Heinemeier Hansson <david@basecamp.com>, Justin Gordon <justin@shakacode.com>",
|
|
5
15
|
"main": "package/index.js",
|
|
6
16
|
"types": "package/index.d.ts",
|
|
7
17
|
"files": [
|
|
8
18
|
"package",
|
|
9
19
|
"lib/install/config/shakapacker.yml"
|
|
10
20
|
],
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
},
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"@types/babel__core": "^7.0.0",
|
|
17
|
-
"@types/webpack": "^5.0.0",
|
|
18
|
-
"@babel/core": "^7.17.9",
|
|
19
|
-
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
20
|
-
"@babel/preset-env": "^7.16.11",
|
|
21
|
-
"@babel/runtime": "^7.17.9",
|
|
22
|
-
"babel-loader": "^8.2.4 || ^9.0.0",
|
|
23
|
-
"compression-webpack-plugin": "^9.0.0 || ^10.0.0",
|
|
24
|
-
"terser-webpack-plugin": "^5.3.1",
|
|
25
|
-
"webpack": "^5.72.0",
|
|
26
|
-
"webpack-assets-manifest": "^5.0.6",
|
|
27
|
-
"webpack-cli": "^4.9.2 || ^5.0.0",
|
|
28
|
-
"webpack-dev-server": "^4.9.0",
|
|
29
|
-
"webpack-merge": "^5.8.0"
|
|
21
|
+
"scripts": {
|
|
22
|
+
"lint": "eslint package/",
|
|
23
|
+
"test": "jest"
|
|
30
24
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
25
|
+
"jest": {
|
|
26
|
+
"roots": [
|
|
27
|
+
"<rootDir>/package"
|
|
28
|
+
],
|
|
29
|
+
"testPathIgnorePatterns": [
|
|
30
|
+
"/__fixtures__/",
|
|
31
|
+
"/__utils__/"
|
|
32
|
+
],
|
|
33
|
+
"testRegex": "(/__tests__/.*|(\\.|/))\\.jsx?$"
|
|
38
34
|
},
|
|
39
35
|
"dependencies": {
|
|
40
36
|
"glob": "^7.2.0",
|
|
@@ -59,31 +55,35 @@
|
|
|
59
55
|
"webpack-assets-manifest": "^5.0.6",
|
|
60
56
|
"webpack-merge": "^5.8.0"
|
|
61
57
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"lint": "eslint package/"
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@babel/core": "^7.17.9",
|
|
60
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
61
|
+
"@babel/preset-env": "^7.16.11",
|
|
62
|
+
"@babel/runtime": "^7.17.9",
|
|
63
|
+
"@types/babel__core": "^7.0.0",
|
|
64
|
+
"@types/webpack": "^5.0.0",
|
|
65
|
+
"babel-loader": "^8.2.4 || ^9.0.0",
|
|
66
|
+
"compression-webpack-plugin": "^9.0.0 || ^10.0.0",
|
|
67
|
+
"terser-webpack-plugin": "^5.3.1",
|
|
68
|
+
"webpack": "^5.72.0",
|
|
69
|
+
"webpack-assets-manifest": "^5.0.6",
|
|
70
|
+
"webpack-cli": "^4.9.2 || ^5.0.0",
|
|
71
|
+
"webpack-dev-server": "^4.9.0",
|
|
72
|
+
"webpack-merge": "^5.8.0"
|
|
78
73
|
},
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@types/babel__core": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"@types/webpack": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
82
81
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"url": "https://github.com/shakacode/shakapacker/issues"
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": "^12.13.0 || ^14 || >=16",
|
|
84
|
+
"yarn": ">=1 <5"
|
|
87
85
|
},
|
|
88
|
-
"
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public"
|
|
88
|
+
}
|
|
89
89
|
}
|
|
@@ -45,19 +45,52 @@ describe "DevServerRunner" do
|
|
|
45
45
|
verify_command(cmd, argv: (["--quiet"]))
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
+
it "does not automatically pass the --https flag" do
|
|
49
|
+
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
|
50
|
+
|
|
51
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
52
|
+
double(
|
|
53
|
+
host: "localhost",
|
|
54
|
+
port: "3035",
|
|
55
|
+
pretty?: false,
|
|
56
|
+
protocol: "https",
|
|
57
|
+
hmr?: true
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
verify_command(cmd)
|
|
62
|
+
end
|
|
63
|
+
|
|
48
64
|
it "supports the https flag" do
|
|
49
65
|
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"])
|
|
50
66
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
68
|
+
double(
|
|
69
|
+
host: "localhost",
|
|
70
|
+
port: "3035",
|
|
71
|
+
pretty?: false,
|
|
72
|
+
protocol: "https",
|
|
73
|
+
hmr?: true
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
verify_command(cmd, argv: ["--https"])
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "supports disabling hot module reloading" do
|
|
81
|
+
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--no-hot"])
|
|
82
|
+
|
|
83
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
84
|
+
double(
|
|
85
|
+
host: "localhost",
|
|
86
|
+
port: "3035",
|
|
87
|
+
pretty?: false,
|
|
88
|
+
protocol: "http",
|
|
89
|
+
hmr?: false
|
|
90
|
+
)
|
|
91
|
+
)
|
|
57
92
|
|
|
58
|
-
|
|
59
|
-
verify_command(cmd, argv: (["--https"]))
|
|
60
|
-
end.and_return(dev_server)
|
|
93
|
+
verify_command(cmd)
|
|
61
94
|
end
|
|
62
95
|
|
|
63
96
|
it "accepts environment variables" do
|
|
@@ -94,19 +127,52 @@ describe "DevServerRunner" do
|
|
|
94
127
|
verify_command(cmd, argv: (["--quiet"]))
|
|
95
128
|
end
|
|
96
129
|
|
|
130
|
+
it "does not automatically pass the --https flag" do
|
|
131
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
|
132
|
+
|
|
133
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
134
|
+
double(
|
|
135
|
+
host: "localhost",
|
|
136
|
+
port: "3035",
|
|
137
|
+
pretty?: false,
|
|
138
|
+
protocol: "https",
|
|
139
|
+
hmr?: true
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
verify_command(cmd)
|
|
144
|
+
end
|
|
145
|
+
|
|
97
146
|
it "supports the https flag" do
|
|
98
147
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"]
|
|
99
148
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
149
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
150
|
+
double(
|
|
151
|
+
host: "localhost",
|
|
152
|
+
port: "3035",
|
|
153
|
+
pretty?: false,
|
|
154
|
+
protocol: "https",
|
|
155
|
+
hmr?: true
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
verify_command(cmd, argv: ["--https"])
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
it "supports disabling hot module reloading" do
|
|
163
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--no-hot"]
|
|
164
|
+
|
|
165
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
166
|
+
double(
|
|
167
|
+
host: "localhost",
|
|
168
|
+
port: "3035",
|
|
169
|
+
pretty?: false,
|
|
170
|
+
protocol: "http",
|
|
171
|
+
hmr?: false
|
|
172
|
+
)
|
|
173
|
+
)
|
|
106
174
|
|
|
107
|
-
|
|
108
|
-
verify_command(cmd, argv: (["--https"]))
|
|
109
|
-
end.and_return(dev_server)
|
|
175
|
+
verify_command(cmd)
|
|
110
176
|
end
|
|
111
177
|
|
|
112
178
|
it "accepts environment variables" do
|
data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml
CHANGED
|
@@ -42,7 +42,7 @@ development:
|
|
|
42
42
|
host: localhost
|
|
43
43
|
port: 3035
|
|
44
44
|
public: localhost:3035
|
|
45
|
-
hmr:
|
|
45
|
+
hmr: true
|
|
46
46
|
# If HMR is on, CSS will by inlined by delivering it as part of the script payload via style-loader. Be sure
|
|
47
47
|
# that you add style-loader to your project dependencies.
|
|
48
48
|
#
|
data/spec/dummy/Gemfile
CHANGED
|
@@ -46,8 +46,6 @@ group :test do
|
|
|
46
46
|
gem "capybara", "~> 3.39.1"
|
|
47
47
|
# gem 'capybara-webkit'
|
|
48
48
|
gem "selenium-webdriver", ">= 4.9"
|
|
49
|
-
# Easy installation and use of web drivers to run system tests with browsers
|
|
50
|
-
gem "webdrivers"
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
data/spec/dummy/package.json
CHANGED
|
@@ -50,14 +50,10 @@ describe "Shakapacker::Compiler" do
|
|
|
50
50
|
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to be nil
|
|
51
51
|
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to be nil
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
with_env_variable(custom_env_variables) do
|
|
59
|
-
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar"
|
|
60
|
-
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz"
|
|
61
|
-
end
|
|
53
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("foo.bar")
|
|
54
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return("/baz")
|
|
55
|
+
|
|
56
|
+
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar"
|
|
57
|
+
expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz"
|
|
62
58
|
end
|
|
63
59
|
end
|
|
@@ -341,16 +341,35 @@ describe "Shakapacker::Configuration" do
|
|
|
341
341
|
end
|
|
342
342
|
|
|
343
343
|
it "returns the value of SHAKAPACKER_ASSET_HOST if set" do
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("custom_host.abc")
|
|
345
|
+
|
|
346
|
+
expect(config.asset_host).to eq "custom_host.abc"
|
|
347
347
|
end
|
|
348
348
|
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
context "without SHAKAPACKER_ASSET_HOST set" do
|
|
350
|
+
it "returns asset_host in shakapacker.yml if set" do
|
|
351
|
+
expect(config).to receive(:fetch).with(:asset_host).and_return("value-in-config-file.com")
|
|
352
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", "value-in-config-file.com").and_return("value-in-config-file.com")
|
|
353
|
+
|
|
354
|
+
expect(config.asset_host).to eq "value-in-config-file.com"
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
context "without asset_host set in the shakapacker.yml" do
|
|
358
|
+
it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_ASSET_HOST is not set" do
|
|
359
|
+
expect(config).to receive(:fetch).with(:asset_host).and_return(nil)
|
|
360
|
+
expect(ActionController::Base.helpers).to receive(:compute_asset_host).and_return("domain.abc")
|
|
361
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", "domain.abc").and_return("domain.abc")
|
|
351
362
|
|
|
352
|
-
|
|
353
|
-
|
|
363
|
+
expect(config.asset_host).to eq "domain.abc"
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
context "without ActionController::Base.helpers.compute_asset_host returing any value" do
|
|
367
|
+
it "returns nil" do
|
|
368
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return(nil)
|
|
369
|
+
|
|
370
|
+
expect(config.asset_host).to be nil
|
|
371
|
+
end
|
|
372
|
+
end
|
|
354
373
|
end
|
|
355
374
|
end
|
|
356
375
|
end
|
|
@@ -364,17 +383,39 @@ describe "Shakapacker::Configuration" do
|
|
|
364
383
|
)
|
|
365
384
|
end
|
|
366
385
|
|
|
386
|
+
it "shows deprecation message" do
|
|
387
|
+
expect { config.relative_url_root }.to output(/deprecated/).to_stdout
|
|
388
|
+
end
|
|
389
|
+
|
|
367
390
|
it "returns the value of SHAKAPACKER_RELATIVE_URL_ROOT if set" do
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
391
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return("custom_value")
|
|
392
|
+
|
|
393
|
+
expect(config.relative_url_root).to eq "custom_value"
|
|
371
394
|
end
|
|
372
395
|
|
|
373
|
-
|
|
374
|
-
|
|
396
|
+
context "without SHAKAPACKER_RELATIVE_URL_ROOT set" do
|
|
397
|
+
it "returns relative_url_root in shakapacker.yml if set" do
|
|
398
|
+
expect(config).to receive(:fetch).with(:relative_url_root).and_return("value-in-config-file")
|
|
399
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", "value-in-config-file").and_return("value-in-config-file")
|
|
400
|
+
|
|
401
|
+
expect(config.relative_url_root).to eq "value-in-config-file"
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
context "without relative_url_root set in the shakapacker.yml" do
|
|
405
|
+
it "returns ActionController::Base.relative_url_root if SHAKAPACKER_RELATIVE_URL_ROOT is not set" do
|
|
406
|
+
expect(ActionController::Base).to receive(:relative_url_root).and_return("abcd")
|
|
407
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", "abcd").and_return("abcd")
|
|
408
|
+
|
|
409
|
+
expect(config.relative_url_root).to eq "abcd"
|
|
410
|
+
end
|
|
375
411
|
|
|
376
|
-
|
|
377
|
-
|
|
412
|
+
context "without ActionController::Base.relative_url_root returing any value" do
|
|
413
|
+
it "returns an empty string" do
|
|
414
|
+
expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return(nil)
|
|
415
|
+
|
|
416
|
+
expect(config.relative_url_root).to be nil
|
|
417
|
+
end
|
|
418
|
+
end
|
|
378
419
|
end
|
|
379
420
|
end
|
|
380
421
|
end
|
|
@@ -44,19 +44,52 @@ describe "DevServerRunner" do
|
|
|
44
44
|
verify_command(cmd, argv: (["--quiet"]))
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
it "does not automatically pass the --https flag" do
|
|
48
|
+
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"])
|
|
49
|
+
|
|
50
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
51
|
+
double(
|
|
52
|
+
host: "localhost",
|
|
53
|
+
port: "3035",
|
|
54
|
+
pretty?: false,
|
|
55
|
+
protocol: "https",
|
|
56
|
+
hmr?: true
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
verify_command(cmd)
|
|
61
|
+
end
|
|
62
|
+
|
|
47
63
|
it "supports the https flag" do
|
|
48
64
|
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"])
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
67
|
+
double(
|
|
68
|
+
host: "localhost",
|
|
69
|
+
port: "3035",
|
|
70
|
+
pretty?: false,
|
|
71
|
+
protocol: "https",
|
|
72
|
+
hmr?: true
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
verify_command(cmd, argv: ["--https"])
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "supports disabling hot module reloading" do
|
|
80
|
+
cmd = package_json.manager.native_exec_command("webpack", ["serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--no-hot"])
|
|
81
|
+
|
|
82
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
83
|
+
double(
|
|
84
|
+
host: "localhost",
|
|
85
|
+
port: "3035",
|
|
86
|
+
pretty?: false,
|
|
87
|
+
protocol: "http",
|
|
88
|
+
hmr?: false
|
|
89
|
+
)
|
|
90
|
+
)
|
|
56
91
|
|
|
57
|
-
|
|
58
|
-
verify_command(cmd, argv: (["--https"]))
|
|
59
|
-
end.and_return(dev_server)
|
|
92
|
+
verify_command(cmd)
|
|
60
93
|
end
|
|
61
94
|
|
|
62
95
|
it "accepts environment variables" do
|
|
@@ -92,19 +125,68 @@ describe "DevServerRunner" do
|
|
|
92
125
|
verify_command(cmd, argv: (["--quiet"]))
|
|
93
126
|
end
|
|
94
127
|
|
|
128
|
+
it "does not automatically pass the --https flag" do
|
|
129
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js"]
|
|
130
|
+
|
|
131
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
132
|
+
double(
|
|
133
|
+
host: "localhost",
|
|
134
|
+
port: "3035",
|
|
135
|
+
pretty?: false,
|
|
136
|
+
protocol: "https",
|
|
137
|
+
hmr?: true
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
verify_command(cmd)
|
|
142
|
+
end
|
|
143
|
+
|
|
95
144
|
it "supports the https flag" do
|
|
96
145
|
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--https"]
|
|
97
146
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
147
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
148
|
+
double(
|
|
149
|
+
host: "localhost",
|
|
150
|
+
port: "3035",
|
|
151
|
+
pretty?: false,
|
|
152
|
+
protocol: "https",
|
|
153
|
+
hmr?: true
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
verify_command(cmd, argv: ["--https"])
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "supports disabling hot module reloading" do
|
|
161
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--no-hot"]
|
|
162
|
+
|
|
163
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
164
|
+
double(
|
|
165
|
+
host: "localhost",
|
|
166
|
+
port: "3035",
|
|
167
|
+
pretty?: false,
|
|
168
|
+
protocol: "http",
|
|
169
|
+
hmr?: false
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
verify_command(cmd)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "supports --hot being 'only'" do
|
|
177
|
+
cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/webpack.config.js", "--hot", "only"]
|
|
178
|
+
|
|
179
|
+
allow(Shakapacker::DevServer).to receive(:new).and_return(
|
|
180
|
+
double(
|
|
181
|
+
host: "localhost",
|
|
182
|
+
port: "3035",
|
|
183
|
+
pretty?: false,
|
|
184
|
+
protocol: "http",
|
|
185
|
+
hmr?: "only"
|
|
186
|
+
)
|
|
187
|
+
)
|
|
104
188
|
|
|
105
|
-
|
|
106
|
-
verify_command(cmd, argv: (["--https"]))
|
|
107
|
-
end.and_return(dev_server)
|
|
189
|
+
verify_command(cmd)
|
|
108
190
|
end
|
|
109
191
|
|
|
110
192
|
it "accepts environment variables" do
|
|
@@ -28,7 +28,29 @@ describe "DigestStrategy" do
|
|
|
28
28
|
expect(@digest_strategy.fresh?).to be true
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
it "is stale when host changes" do
|
|
32
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("old-host")
|
|
33
|
+
# Record the digests for old-host
|
|
34
|
+
@digest_strategy.after_compile_hook
|
|
35
|
+
|
|
36
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("new-host")
|
|
37
|
+
expect(@digest_strategy.stale?).to be true
|
|
38
|
+
expect(@digest_strategy.fresh?).to be_falsey
|
|
39
|
+
end
|
|
40
|
+
|
|
31
41
|
it "generates correct compilation_digest_path" do
|
|
42
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("custom-path")
|
|
43
|
+
|
|
44
|
+
actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
|
|
45
|
+
host_hash = Digest::SHA1.hexdigest("custom-path")
|
|
46
|
+
expected_path = "last-compilation-digest-#{Shakapacker.env}"
|
|
47
|
+
|
|
48
|
+
expect(actual_path).to eq expected_path
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "generates correct compilation_digest_path without the digest of the asset host if asset host is not set" do
|
|
52
|
+
allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return(nil)
|
|
53
|
+
|
|
32
54
|
actual_path = @digest_strategy.send(:compilation_digest_path).basename.to_s
|
|
33
55
|
expected_path = "last-compilation-digest-#{Shakapacker.env}"
|
|
34
56
|
|
|
@@ -22,21 +22,3 @@ ensure
|
|
|
22
22
|
Rails.env = ActiveSupport::StringInquirer.new(original)
|
|
23
23
|
reloaded_config
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
# Temportarily set env variables to a custom value
|
|
27
|
-
# arg: a hash with key:value for each custom env
|
|
28
|
-
# Keys could be string or symbol
|
|
29
|
-
def with_env_variable(custom_env_hash)
|
|
30
|
-
original_env = {}
|
|
31
|
-
custom_env_hash.each do |key, new_value|
|
|
32
|
-
upcased_key = key.to_s.upcase
|
|
33
|
-
original_env[upcased_key] = new_value
|
|
34
|
-
ENV[upcased_key] = new_value
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
yield
|
|
38
|
-
ensure
|
|
39
|
-
original_env.each do |key, original_value|
|
|
40
|
-
ENV[key] = original_value
|
|
41
|
-
end
|
|
42
|
-
end
|
|
@@ -42,7 +42,7 @@ development:
|
|
|
42
42
|
host: localhost
|
|
43
43
|
port: 3035
|
|
44
44
|
public: localhost:3035
|
|
45
|
-
hmr:
|
|
45
|
+
hmr: true
|
|
46
46
|
# If HMR is on, CSS will by inlined by delivering it as part of the script payload via style-loader. Be sure
|
|
47
47
|
# that you add style-loader to your project dependencies.
|
|
48
48
|
#
|
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: 7.2.0
|
|
4
|
+
version: 7.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-
|
|
13
|
+
date: 2023-12-29 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -566,7 +566,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
|
566
566
|
licenses:
|
|
567
567
|
- MIT
|
|
568
568
|
metadata:
|
|
569
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.2.0
|
|
569
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v7.2.0
|
|
570
570
|
post_install_message:
|
|
571
571
|
rdoc_options: []
|
|
572
572
|
require_paths:
|
|
@@ -578,9 +578,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
578
578
|
version: 2.6.0
|
|
579
579
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
580
580
|
requirements:
|
|
581
|
-
- - "
|
|
581
|
+
- - ">="
|
|
582
582
|
- !ruby/object:Gem::Version
|
|
583
|
-
version:
|
|
583
|
+
version: '0'
|
|
584
584
|
requirements: []
|
|
585
585
|
rubygems_version: 3.4.12
|
|
586
586
|
signing_key:
|