shakapacker 8.0.2 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db9b65b6bcad3c69564cc6e9a1c81ef86586b551cceac4426ff4648388943063
4
- data.tar.gz: 764219a7ff3a435f16bf8554f538f56b5d32f29e1849cdf06241504098b5f9c9
3
+ metadata.gz: 50df828db39af7e84673e9ab8bd4569d644084e428902d02084574b77db9bd8e
4
+ data.tar.gz: 6aac530ddb579fc7f92888a1e65282bbf69c98bc2773fcd27d77ec19671ec74d
5
5
  SHA512:
6
- metadata.gz: 1b45a4a37953a95d40eeaa8382350991058e074157594a8eeb977eace38db31d0c2507db9aec61eb8eea20485e135d68e9e9d688fc8fe094f4672532715ecc01
7
- data.tar.gz: b053d207e3e1d56ab2e92987d216212f75e4b6d41d49d6b5bed1ccfdb29d917b94ac4d17220f607253ffc9d335de733089deb1e5aca44dc389a6177168e244da
6
+ metadata.gz: e6250e22762bd47aaf6dc0d2b93354bea65e3ca2e5d629177bec478495de3e6eaba5a458e3f0feda712bf08bf2b48f2f0a6f003baa6b2ffb354e49fb042e65d3
7
+ data.tar.gz: 45f445078b0d50f1eebc6d27f8a76ceeb3c8eb38cce4a4881562ab77d3a47f6e86d293f5c46a468a8fc4566bc217b39105cec85a78b5fdc1e77112c22a1d3ff8
@@ -25,6 +25,7 @@ jobs:
25
25
  - uses: ruby/setup-ruby@v1
26
26
  with:
27
27
  ruby-version: '3.1.2'
28
+ rubygems: latest
28
29
  - name: Install dependencies
29
30
  run: |
30
31
  bundle install
@@ -18,24 +18,42 @@ jobs:
18
18
  strategy:
19
19
  matrix:
20
20
  os: [ubuntu-latest]
21
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
21
+ ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
22
22
  gemfile:
23
23
  - gemfiles/Gemfile-rails.6.0.x
24
24
  - gemfiles/Gemfile-rails.6.1.x
25
25
  - gemfiles/Gemfile-rails.7.0.x
26
26
  - gemfiles/Gemfile-rails.7.1.x
27
+ - gemfiles/Gemfile-rails.7.2.x
28
+ - gemfiles/Gemfile-rails.8.0.x
27
29
  # Uncomment the following line only to ensure compatibility with the
28
30
  # upcomming Rails versions, maybe before a release.
29
31
  #- gemfiles/Gemfile-rails-edge
30
32
  exclude:
33
+ - ruby: '2.7'
34
+ gemfile: gemfiles/Gemfile-rails.7.2.x
35
+ - ruby: '2.7'
36
+ gemfile: gemfiles/Gemfile-rails.8.0.x
37
+ - ruby: '3.0'
38
+ gemfile: gemfiles/Gemfile-rails.7.2.x
39
+ - ruby: '3.0'
40
+ gemfile: gemfiles/Gemfile-rails.8.0.x
31
41
  - ruby: '3.1'
32
42
  gemfile: gemfiles/Gemfile-rails.6.0.x
43
+ - ruby: '3.1'
44
+ gemfile: gemfiles/Gemfile-rails.8.0.x
33
45
  - ruby: '3.2'
34
46
  gemfile: gemfiles/Gemfile-rails.6.0.x
35
47
  - ruby: '3.3'
36
48
  gemfile: gemfiles/Gemfile-rails.6.0.x
37
49
  - ruby: '3.3'
38
50
  gemfile: gemfiles/Gemfile-rails.6.1.x
51
+ - ruby: '3.4'
52
+ gemfile: gemfiles/Gemfile-rails.6.0.x
53
+ - ruby: '3.4'
54
+ gemfile: gemfiles/Gemfile-rails.6.1.x
55
+ - ruby: '3.4'
56
+ gemfile: gemfiles/Gemfile-rails.7.0.x
39
57
 
40
58
  env:
41
59
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -47,5 +65,6 @@ jobs:
47
65
  - uses: ruby/setup-ruby@v1
48
66
  with:
49
67
  ruby-version: ${{ matrix.ruby }}
68
+ rubygems: latest
50
69
  bundler-cache: true
51
70
  - run: bundle exec rake run_spec:generator
@@ -23,7 +23,8 @@ jobs:
23
23
  run: rm -f Gemfile.lock
24
24
  - uses: ruby/setup-ruby@v1
25
25
  with:
26
- ruby-version: '3.3'
26
+ ruby-version: '3.4'
27
+ rubygems: latest
27
28
  bundler-cache: true
28
29
 
29
30
  - name: Ruby rubocop
@@ -35,24 +36,42 @@ jobs:
35
36
  strategy:
36
37
  matrix:
37
38
  os: [ubuntu-latest]
38
- ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
39
+ ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
39
40
  gemfile:
40
41
  - gemfiles/Gemfile-rails.6.0.x
41
42
  - gemfiles/Gemfile-rails.6.1.x
42
43
  - gemfiles/Gemfile-rails.7.0.x
43
44
  - gemfiles/Gemfile-rails.7.1.x
45
+ - gemfiles/Gemfile-rails.7.2.x
46
+ - gemfiles/Gemfile-rails.8.0.x
44
47
  # Uncomment the following line only to ensure compatibility with the
45
48
  # upcomming Rails versions, maybe before a release.
46
49
  #- gemfiles/Gemfile-rails-edge
47
50
  exclude:
51
+ - ruby: '2.7'
52
+ gemfile: gemfiles/Gemfile-rails.7.2.x
53
+ - ruby: '2.7'
54
+ gemfile: gemfiles/Gemfile-rails.8.0.x
55
+ - ruby: '3.0'
56
+ gemfile: gemfiles/Gemfile-rails.7.2.x
57
+ - ruby: '3.0'
58
+ gemfile: gemfiles/Gemfile-rails.8.0.x
48
59
  - ruby: '3.1'
49
60
  gemfile: gemfiles/Gemfile-rails.6.0.x
61
+ - ruby: '3.1'
62
+ gemfile: gemfiles/Gemfile-rails.8.0.x
50
63
  - ruby: '3.2'
51
64
  gemfile: gemfiles/Gemfile-rails.6.0.x
52
65
  - ruby: '3.3'
53
66
  gemfile: gemfiles/Gemfile-rails.6.0.x
54
67
  - ruby: '3.3'
55
68
  gemfile: gemfiles/Gemfile-rails.6.1.x
69
+ - ruby: '3.4'
70
+ gemfile: gemfiles/Gemfile-rails.6.0.x
71
+ - ruby: '3.4'
72
+ gemfile: gemfiles/Gemfile-rails.6.1.x
73
+ - ruby: '3.4'
74
+ gemfile: gemfiles/Gemfile-rails.7.0.x
56
75
 
57
76
  env:
58
77
  BUNDLE_GEMFILE: ${{ matrix.gemfile }}
@@ -64,6 +83,7 @@ jobs:
64
83
  - uses: ruby/setup-ruby@v1
65
84
  with:
66
85
  ruby-version: ${{ matrix.ruby }}
86
+ rubygems: latest
67
87
  bundler-cache: true
68
88
 
69
89
  - name: Ruby specs
data/CHANGELOG.md CHANGED
@@ -10,9 +10,24 @@ _next_ branch is for v8 changes
10
10
  ## [Unreleased]
11
11
  Changes since the last non-beta release.
12
12
 
13
+ ## [v8.1.0] - January 20, 2025
14
+
15
+ ### Added
16
+
17
+ - Allow `webpack-cli` v6. [PR 533](https://github.com/shakacode/shakapacker/pull/533) by [tagliala](https://github.com/tagliala).
18
+
13
19
  ### Changed
20
+ - 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).
21
+ - 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).
14
22
 
15
- - Fix wrong instruction in esbuild loader documentation [PR 504](https://github.com/shakacode/shakapacker/pull/504) by [adriangohjw](https://github.com/adriangohjw)
23
+ ### Fixed
24
+ - Fix error when rails environment is required from outside the rails root directory [PR 520](https://github.com/shakacode/shakapacker/pull/520)
25
+
26
+ ## [v8.0.2] - August 28, 2024
27
+
28
+ ### Fixed
29
+ - Fix wrong instruction in esbuild loader documentation [PR 504](https://github.com/shakacode/shakapacker/pull/504) by [adriangohjw](https://github.com/adriangohjw).
30
+ - 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).
16
31
 
17
32
  ## [v8.0.1] - July 10, 2024
18
33
 
@@ -386,7 +401,9 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
386
401
  ## v5.4.3 and prior changes from rails/webpacker
387
402
  See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
388
403
 
389
- [Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.0.1...main
404
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.1.0...main
405
+ [v8.1.0]: https://github.com/shakacode/shakapacker/compare/v8.0.2...v8.1.0
406
+ [v8.0.2]: https://github.com/shakacode/shakapacker/compare/v8.0.1...v8.0.2
390
407
  [v8.0.1]: https://github.com/shakacode/shakapacker/compare/v8.0.0...v8.0.1
391
408
  [v8.0.0]: https://github.com/shakacode/shakapacker/compare/v7.2.3...v8.0.0
392
409
  [v7.2.3]: https://github.com/shakacode/shakapacker/compare/v7.2.2...v7.2.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (8.0.2)
4
+ shakapacker (8.1.0)
5
5
  activesupport (>= 5.2)
6
6
  package_json
7
7
  rack-proxy (>= 0.6.1)
@@ -11,86 +11,82 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- actioncable (7.1.3.4)
15
- actionpack (= 7.1.3.4)
16
- activesupport (= 7.1.3.4)
14
+ actioncable (7.2.1)
15
+ actionpack (= 7.2.1)
16
+ activesupport (= 7.2.1)
17
17
  nio4r (~> 2.0)
18
18
  websocket-driver (>= 0.6.1)
19
19
  zeitwerk (~> 2.6)
20
- actionmailbox (7.1.3.4)
21
- actionpack (= 7.1.3.4)
22
- activejob (= 7.1.3.4)
23
- activerecord (= 7.1.3.4)
24
- activestorage (= 7.1.3.4)
25
- activesupport (= 7.1.3.4)
26
- mail (>= 2.7.1)
27
- net-imap
28
- net-pop
29
- net-smtp
30
- actionmailer (7.1.3.4)
31
- actionpack (= 7.1.3.4)
32
- actionview (= 7.1.3.4)
33
- activejob (= 7.1.3.4)
34
- activesupport (= 7.1.3.4)
35
- mail (~> 2.5, >= 2.5.4)
36
- net-imap
37
- net-pop
38
- net-smtp
20
+ actionmailbox (7.2.1)
21
+ actionpack (= 7.2.1)
22
+ activejob (= 7.2.1)
23
+ activerecord (= 7.2.1)
24
+ activestorage (= 7.2.1)
25
+ activesupport (= 7.2.1)
26
+ mail (>= 2.8.0)
27
+ actionmailer (7.2.1)
28
+ actionpack (= 7.2.1)
29
+ actionview (= 7.2.1)
30
+ activejob (= 7.2.1)
31
+ activesupport (= 7.2.1)
32
+ mail (>= 2.8.0)
39
33
  rails-dom-testing (~> 2.2)
40
- actionpack (7.1.3.4)
41
- actionview (= 7.1.3.4)
42
- activesupport (= 7.1.3.4)
34
+ actionpack (7.2.1)
35
+ actionview (= 7.2.1)
36
+ activesupport (= 7.2.1)
43
37
  nokogiri (>= 1.8.5)
44
38
  racc
45
- rack (>= 2.2.4)
39
+ rack (>= 2.2.4, < 3.2)
46
40
  rack-session (>= 1.0.1)
47
41
  rack-test (>= 0.6.3)
48
42
  rails-dom-testing (~> 2.2)
49
43
  rails-html-sanitizer (~> 1.6)
50
- actiontext (7.1.3.4)
51
- actionpack (= 7.1.3.4)
52
- activerecord (= 7.1.3.4)
53
- activestorage (= 7.1.3.4)
54
- activesupport (= 7.1.3.4)
44
+ useragent (~> 0.16)
45
+ actiontext (7.2.1)
46
+ actionpack (= 7.2.1)
47
+ activerecord (= 7.2.1)
48
+ activestorage (= 7.2.1)
49
+ activesupport (= 7.2.1)
55
50
  globalid (>= 0.6.0)
56
51
  nokogiri (>= 1.8.5)
57
- actionview (7.1.3.4)
58
- activesupport (= 7.1.3.4)
52
+ actionview (7.2.1)
53
+ activesupport (= 7.2.1)
59
54
  builder (~> 3.1)
60
55
  erubi (~> 1.11)
61
56
  rails-dom-testing (~> 2.2)
62
57
  rails-html-sanitizer (~> 1.6)
63
- activejob (7.1.3.4)
64
- activesupport (= 7.1.3.4)
58
+ activejob (7.2.1)
59
+ activesupport (= 7.2.1)
65
60
  globalid (>= 0.3.6)
66
- activemodel (7.1.3.4)
67
- activesupport (= 7.1.3.4)
68
- activerecord (7.1.3.4)
69
- activemodel (= 7.1.3.4)
70
- activesupport (= 7.1.3.4)
61
+ activemodel (7.2.1)
62
+ activesupport (= 7.2.1)
63
+ activerecord (7.2.1)
64
+ activemodel (= 7.2.1)
65
+ activesupport (= 7.2.1)
71
66
  timeout (>= 0.4.0)
72
- activestorage (7.1.3.4)
73
- actionpack (= 7.1.3.4)
74
- activejob (= 7.1.3.4)
75
- activerecord (= 7.1.3.4)
76
- activesupport (= 7.1.3.4)
67
+ activestorage (7.2.1)
68
+ actionpack (= 7.2.1)
69
+ activejob (= 7.2.1)
70
+ activerecord (= 7.2.1)
71
+ activesupport (= 7.2.1)
77
72
  marcel (~> 1.0)
78
- activesupport (7.1.3.4)
73
+ activesupport (7.2.1)
79
74
  base64
80
75
  bigdecimal
81
- concurrent-ruby (~> 1.0, >= 1.0.2)
76
+ concurrent-ruby (~> 1.0, >= 1.3.1)
82
77
  connection_pool (>= 2.2.5)
83
78
  drb
84
79
  i18n (>= 1.6, < 2)
80
+ logger (>= 1.4.2)
85
81
  minitest (>= 5.1)
86
- mutex_m
87
- tzinfo (~> 2.0)
82
+ securerandom (>= 0.3)
83
+ tzinfo (~> 2.0, >= 2.0.5)
88
84
  ast (2.4.2)
89
85
  base64 (0.2.0)
90
86
  bigdecimal (3.1.8)
91
87
  builder (3.3.0)
92
88
  byebug (11.1.3)
93
- concurrent-ruby (1.3.3)
89
+ concurrent-ruby (1.3.4)
94
90
  connection_pool (2.4.1)
95
91
  crass (1.0.6)
96
92
  date (3.3.4)
@@ -107,6 +103,7 @@ GEM
107
103
  reline (>= 0.4.2)
108
104
  json (2.7.2)
109
105
  language_server-protocol (3.17.0.3)
106
+ logger (1.6.0)
110
107
  loofah (2.22.0)
111
108
  crass (~> 1.0.2)
112
109
  nokogiri (>= 1.12.0)
@@ -118,9 +115,8 @@ GEM
118
115
  marcel (1.0.4)
119
116
  mini_mime (1.1.5)
120
117
  mini_portile2 (2.8.7)
121
- minitest (5.24.1)
122
- mutex_m (0.2.0)
123
- net-imap (0.4.14)
118
+ minitest (5.25.1)
119
+ net-imap (0.4.15)
124
120
  date
125
121
  net-protocol
126
122
  net-pop (0.1.2)
@@ -130,18 +126,18 @@ GEM
130
126
  net-smtp (0.5.0)
131
127
  net-protocol
132
128
  nio4r (2.7.3)
133
- nokogiri (1.16.6)
129
+ nokogiri (1.16.7)
134
130
  mini_portile2 (~> 2.8.2)
135
131
  racc (~> 1.4)
136
132
  package_json (0.1.0)
137
- parallel (1.25.1)
138
- parser (3.3.3.0)
133
+ parallel (1.26.3)
134
+ parser (3.3.4.2)
139
135
  ast (~> 2.4.1)
140
136
  racc
141
137
  psych (5.1.2)
142
138
  stringio
143
- racc (1.8.0)
144
- rack (3.1.6)
139
+ racc (1.8.1)
140
+ rack (3.1.7)
145
141
  rack-proxy (0.7.7)
146
142
  rack
147
143
  rack-session (2.0.0)
@@ -151,20 +147,20 @@ GEM
151
147
  rackup (2.1.0)
152
148
  rack (>= 3)
153
149
  webrick (~> 1.8)
154
- rails (7.1.3.4)
155
- actioncable (= 7.1.3.4)
156
- actionmailbox (= 7.1.3.4)
157
- actionmailer (= 7.1.3.4)
158
- actionpack (= 7.1.3.4)
159
- actiontext (= 7.1.3.4)
160
- actionview (= 7.1.3.4)
161
- activejob (= 7.1.3.4)
162
- activemodel (= 7.1.3.4)
163
- activerecord (= 7.1.3.4)
164
- activestorage (= 7.1.3.4)
165
- activesupport (= 7.1.3.4)
150
+ rails (7.2.1)
151
+ actioncable (= 7.2.1)
152
+ actionmailbox (= 7.2.1)
153
+ actionmailer (= 7.2.1)
154
+ actionpack (= 7.2.1)
155
+ actiontext (= 7.2.1)
156
+ actionview (= 7.2.1)
157
+ activejob (= 7.2.1)
158
+ activemodel (= 7.2.1)
159
+ activerecord (= 7.2.1)
160
+ activestorage (= 7.2.1)
161
+ activesupport (= 7.2.1)
166
162
  bundler (>= 1.15.0)
167
- railties (= 7.1.3.4)
163
+ railties (= 7.2.1)
168
164
  rails-dom-testing (2.2.0)
169
165
  activesupport (>= 5.0.0)
170
166
  minitest
@@ -172,10 +168,10 @@ GEM
172
168
  rails-html-sanitizer (1.6.0)
173
169
  loofah (~> 2.21)
174
170
  nokogiri (~> 1.14)
175
- railties (7.1.3.4)
176
- actionpack (= 7.1.3.4)
177
- activesupport (= 7.1.3.4)
178
- irb
171
+ railties (7.2.1)
172
+ actionpack (= 7.2.1)
173
+ activesupport (= 7.2.1)
174
+ irb (~> 1.13)
179
175
  rackup (>= 1.0.0)
180
176
  rake (>= 12.2)
181
177
  thor (~> 1.0, >= 1.2.2)
@@ -187,11 +183,9 @@ GEM
187
183
  regexp_parser (2.9.2)
188
184
  reline (0.5.9)
189
185
  io-console (~> 0.5)
190
- rexml (3.3.1)
191
- strscan
192
186
  rspec-core (3.13.0)
193
187
  rspec-support (~> 3.13.0)
194
- rspec-expectations (3.13.1)
188
+ rspec-expectations (3.13.2)
195
189
  diff-lcs (>= 1.2.0, < 2.0)
196
190
  rspec-support (~> 3.13.0)
197
191
  rspec-mocks (3.13.1)
@@ -206,36 +200,36 @@ GEM
206
200
  rspec-mocks (~> 3.12)
207
201
  rspec-support (~> 3.12)
208
202
  rspec-support (3.13.1)
209
- rubocop (1.64.1)
203
+ rubocop (1.66.0)
210
204
  json (~> 2.3)
211
205
  language_server-protocol (>= 3.17.0)
212
206
  parallel (~> 1.10)
213
207
  parser (>= 3.3.0.2)
214
208
  rainbow (>= 2.2.2, < 4.0)
215
- regexp_parser (>= 1.8, < 3.0)
216
- rexml (>= 3.2.5, < 4.0)
217
- rubocop-ast (>= 1.31.1, < 2.0)
209
+ regexp_parser (>= 2.4, < 3.0)
210
+ rubocop-ast (>= 1.32.1, < 2.0)
218
211
  ruby-progressbar (~> 1.7)
219
212
  unicode-display_width (>= 2.4.0, < 3.0)
220
- rubocop-ast (1.31.3)
213
+ rubocop-ast (1.32.1)
221
214
  parser (>= 3.3.1.0)
222
215
  rubocop-performance (1.21.1)
223
216
  rubocop (>= 1.48.1, < 2.0)
224
217
  rubocop-ast (>= 1.31.1, < 2.0)
225
218
  ruby-progressbar (1.13.0)
219
+ securerandom (0.3.1)
226
220
  semantic_range (3.0.0)
227
221
  stringio (3.1.1)
228
- strscan (3.1.0)
229
- thor (1.3.1)
222
+ thor (1.3.2)
230
223
  timeout (0.4.1)
231
224
  tzinfo (2.0.6)
232
225
  concurrent-ruby (~> 1.0)
233
226
  unicode-display_width (2.5.0)
227
+ useragent (0.16.10)
234
228
  webrick (1.8.1)
235
229
  websocket-driver (0.7.6)
236
230
  websocket-extensions (>= 0.1.0)
237
231
  websocket-extensions (0.1.5)
238
- zeitwerk (2.6.16)
232
+ zeitwerk (2.6.17)
239
233
 
240
234
  PLATFORMS
241
235
  ruby
@@ -254,4 +248,4 @@ DEPENDENCIES
254
248
  shakapacker!
255
249
 
256
250
  BUNDLED WITH
257
- 2.5.9
251
+ 2.5.18
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Shakapacker (v8)
2
2
 
3
- _Official, actively maintained successor to [rails/webpacker](https://github.com/rails/webpacker).ShakaCode stands behind the long-term maintenance and development of this project for the Rails community._
3
+ _Official, actively maintained successor to [rails/webpacker](https://github.com/rails/webpacker). ShakaCode stands behind the long-term maintenance and development of this project for the Rails community._
4
4
 
5
5
  * ⚠️ See the [6-stable](https://github.com/shakacode/shakapacker/tree/6-stable) branch for Shakapacker v6.x code and documentation. :warning:
6
6
  * See [V8 Upgrade](./docs/v8_upgrade.md) for upgrading from the v7 release.
@@ -675,6 +675,24 @@ module.exports = generateWebpackConfig({
675
675
  });
676
676
  ```
677
677
 
678
+ Optionally, your webpack config file itself can be written in Typescript:
679
+
680
+ ``` bash
681
+ npm install ts-node @types/node @types/webpack
682
+ ```
683
+
684
+ ```ts
685
+ // config/webpack/webpack.config.ts
686
+ import { generateWebpackConfig } from "shakapacker";
687
+ import ForkTSCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
688
+
689
+ const config = generateWebpackConfig({
690
+ plugins: [new ForkTSCheckerWebpackPlugin()],
691
+ });
692
+
693
+ export default config;
694
+ ```
695
+
678
696
  #### CSS
679
697
 
680
698
  To enable CSS support in your application, add the following packages:
data/docs/react.md CHANGED
@@ -34,7 +34,7 @@ Update the Babel configuration in the `package.json` file:
34
34
  },
35
35
  ```
36
36
 
37
- And that's it. You can now create a React app using `app/javascript/application.js` as your entry point.
37
+ And that's it. You can now create a React app using `app/javascript/packs/application.js` as your entry point.
38
38
 
39
39
  ## Enabling Hot Module Replacement (HMR)
40
40
 
@@ -152,11 +152,11 @@ echo '<div id="root"></div>' > app/views/site/index.html.erb
152
152
  touch app/javascript/App.css app/javascript/App.js
153
153
  ```
154
154
 
155
- 4. Edit `app/javascript/application.js` like so:
155
+ 4. Edit `app/javascript/packs/application.js` like so:
156
156
  ```jsx
157
157
  import React from 'react';
158
158
  import { createRoot } from 'react-dom/client';
159
- import HelloMessage from './App';
159
+ import HelloMessage from '../App';
160
160
 
161
161
  const container = document.getElementById('root');
162
162
  const root = createRoot(container);
@@ -267,4 +267,4 @@ rails s
267
267
 
268
268
  11. Edit either the React component at `app/javascript/App.js` or the CSS file at `app/javascript/App.css` and observe the HMR goodness.
269
269
 
270
- Note that HMR will not work if you edit `app/javascript/application.js` and experience a full refresh with a warning in the console. For more info on this, see here: https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/177
270
+ Note that HMR will not work if you edit `app/javascript/packs/application.js` and experience a full refresh with a warning in the console. For more info on this, see here: https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/177
@@ -228,3 +228,32 @@ issue.
228
228
 
229
229
  See [this issue](https://github.com/rails/webpacker/issues/3005) for more
230
230
  details.
231
+
232
+ ## Static file dependencies emitted outside of public output path
233
+
234
+ For static file assets (images, fonts), we use [a Webpack rule](https://github.com/shakacode/shakapacker/blob/main/package/rules/file.js) to handle those files as `asset/resource` type and output them in the `static` folder in the public output path.
235
+
236
+ In order to generate the storage path, we rely on the filename that's [provided by webpack internals](https://webpack.js.org/configuration/output/#outputfilename).
237
+
238
+ This usually works out of the box. There's a potential problem however, if you use the [context setting](https://webpack.js.org/configuration/entry-context/#context) in your webpack config. By default this is set to current Node working directory/project root.
239
+
240
+ If you were to override it like:
241
+ ```
242
+ {
243
+ context: path.resolve(__dirname, '../../app/javascript')
244
+ }
245
+ ```
246
+
247
+ Then the filename available in the rule generator will be relative to that directory.
248
+
249
+ This means for example:
250
+ - a static asset from `node_modules` folder could end up being referenced with path of `../../node_modules/some_module/static_file.jpg` rather than simply `node_modules/some_module/static_file.jpg`.
251
+ - a static asset in one of the `additional_paths`, example `app/assets/images/image.jpg`, would end up being referenced with path of `../assets/images/image.jpg`.
252
+
253
+ Those paths are later passed to [output path generation in the rule](https://github.com/shakacode/shakapacker/blob/e52b335dbabfb934fe7d3076a8322b97d5ef3470/package/rules/file.js#L25-L26), where we would end up with a path like `static/../../node_modules/some_module/static_file.jpg`, resulting in the file being output in a location two directories above the desired path.
254
+
255
+ You can avoid this by:
256
+ - not using overridden `context` in your webpack config, if there's no good reason for it.
257
+ - using custom Webpack config to modify the static file rule, following a similar process as outlined in the [Webpack Configuration](https://github.com/shakacode/shakapacker/blob/main/README.md#webpack-configuration) section of the readme.
258
+
259
+ See [this issue](https://github.com/shakacode/shakapacker/issues/538) for more details.
data/docs/v8_upgrade.md CHANGED
@@ -21,9 +21,7 @@ If your host might differ, between various environments for example, you will ei
21
21
  - Ensure the assets are specifically rebuilt for each environment (Heroku pipeline promote feature for example does not do that by default).
22
22
  - Make sure the assets are compiled with `SHAKAPACKER_ASSET_HOST=''` ENV variable to avoid hardcording URLs in packs output.
23
23
 
24
- Second option has got a certain gotcha - dynamic imports and static asset references (like image paths in CSS) will end up without host reference and the app will try and fetch them from your app host rather than defined `config.asset_host`.
25
-
26
- Make sure the assets are compiled with `SHAKAPACKER_ASSET_HOST=''` ENV variable to avoid hardcoding URLs in packs output.
24
+ The second option has got a certain gotcha - dynamic imports and static asset references (like image paths in CSS) will end up without a host reference and the app will try and fetch them from your app host rather than defined `config.asset_host`.
27
25
 
28
26
  To get around that, you can use dynamic override as outlined by [Webpack documentation](https://webpack.js.org/guides/asset-modules/#on-the-fly-override).
29
27
 
@@ -102,10 +100,10 @@ namespace :assets do
102
100
  raise if File.exist?("package.json") && !(system "npm ci")
103
101
 
104
102
  # yarn v1.x (classic)
105
- raise if File.exist?("package.json") && !(system "yarn install --immutable")
103
+ raise if File.exist?("package.json") && !(system "yarn install --frozen-lockfile")
106
104
 
107
105
  # yarn v2+ (berry)
108
- raise if File.exist?("package.json") && !(system "yarn install --frozen-lockfile")
106
+ raise if File.exist?("package.json") && !(system "yarn install --immutable")
109
107
 
110
108
  # bun v1+
111
109
  raise if File.exist?("package.json") && !(system "bun install --frozen-lockfile")
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec path: "../"
4
4
 
5
- gem "rails", "~> 6.0.0.rc2"
5
+ gem "rails", "~> 6.0.0"
6
6
  gem "rake", ">= 11.1"
7
7
  gem "rack-proxy", require: false
8
8
  gem "rspec-rails", "~> 5.0.0"
@@ -5,7 +5,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
  gemspec path: "../"
6
6
 
7
7
  gem "rails", '~>6.1.0'
8
- gem "arel", github: "rails/arel"
9
8
  gem "rake", ">= 11.1"
10
9
  gem "rack-proxy", require: false
11
10
  gem "rspec-rails", "~> 6.0.0"
@@ -5,8 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
  gemspec path: "../"
6
6
 
7
7
  gem "rails", '~>7.0.0'
8
- gem "arel", github: "rails/arel"
9
8
  gem "rake", ">= 11.1"
10
9
  gem "rack-proxy", require: false
11
- gem "rspec-rails", "~> 6.0.0"
10
+ gem "rspec-rails", "~> 7.0"
12
11
  gem "byebug"
@@ -5,8 +5,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
  gemspec path: "../"
6
6
 
7
7
  gem "rails", '~>7.1.0'
8
- gem "arel", github: "rails/arel"
9
8
  gem "rake", ">= 11.1"
10
9
  gem "rack-proxy", require: false
11
- gem "rspec-rails", "~> 6.0.0"
10
+ gem "rspec-rails", "~> 7.0"
12
11
  gem "byebug"
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "rails", '~>7.2.0'
8
+ gem "rake", ">= 11.1"
9
+ gem "rack-proxy", require: false
10
+ gem "rspec-rails", "~> 7.0"
11
+ gem "byebug"
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "rails", '~>8.0.0'
8
+ gem "rake", ">= 11.1"
9
+ gem "rack-proxy", require: false
10
+ gem "rspec-rails", "~> 7.0"
11
+ gem "byebug"
@@ -1,7 +1,8 @@
1
1
  require "open3"
2
- require "shakapacker/compiler_strategy"
3
2
  require "fileutils"
4
3
 
4
+ require_relative "compiler_strategy"
5
+
5
6
  class Shakapacker::Compiler
6
7
  # Additional environment variables that the compiler is being run with
7
8
  # Shakapacker::Compiler.env['FRONTEND_API_KEY'] = 'your_secret_key'
@@ -1,5 +1,5 @@
1
- require "shakapacker/mtime_strategy"
2
- require "shakapacker/digest_strategy"
1
+ require_relative "mtime_strategy"
2
+ require_relative "digest_strategy"
3
3
 
4
4
  module Shakapacker
5
5
  class CompilerStrategy
@@ -1,8 +1,9 @@
1
1
  require "shellwords"
2
2
  require "socket"
3
- require "shakapacker/configuration"
4
- require "shakapacker/dev_server"
5
- require "shakapacker/runner"
3
+
4
+ require_relative "configuration"
5
+ require_relative "dev_server"
6
+ require_relative "runner"
6
7
 
7
8
  module Shakapacker
8
9
  class DevServerRunner < Shakapacker::Runner
@@ -1,5 +1,6 @@
1
1
  require "digest/sha1"
2
- require "shakapacker/base_strategy"
2
+
3
+ require_relative "base_strategy"
3
4
 
4
5
  module Shakapacker
5
6
  class DigestStrategy < BaseStrategy
@@ -195,7 +195,7 @@ module Shakapacker::Helper
195
195
 
196
196
  def update_javascript_pack_tag_queue(defer:)
197
197
  if @javascript_pack_tag_loaded
198
- raise "You can only call #{caller_locations(1..1).first.label} before javascript_pack_tag helper. " \
198
+ raise "You can only call #{caller_locations(1..1).first.base_label} before javascript_pack_tag helper. " \
199
199
  "Please refer to https://github.com/shakacode/shakapacker/blob/main/README.md#view-helper-append_javascript_pack_tag-prepend_javascript_pack_tag-and-append_stylesheet_pack_tag for the usage guide"
200
200
  end
201
201
 
@@ -1,4 +1,4 @@
1
- require "shakapacker/base_strategy"
1
+ require_relative "base_strategy"
2
2
 
3
3
  module Shakapacker
4
4
  class MtimeStrategy < BaseStrategy
@@ -1,9 +1,9 @@
1
1
  require "rails/railtie"
2
2
 
3
- require "shakapacker/helper"
4
- require "shakapacker/dev_server_proxy"
5
- require "shakapacker/version_checker"
6
- require "shakapacker/utils/manager"
3
+ require_relative "helper"
4
+ require_relative "dev_server_proxy"
5
+ require_relative "version_checker"
6
+ require_relative "utils/manager"
7
7
 
8
8
  class Shakapacker::Engine < ::Rails::Engine
9
9
  # Allows Shakapacker config values to be set via Rails env config files
@@ -1,5 +1,6 @@
1
- require "shakapacker/utils/misc"
2
- require "shakapacker/utils/manager"
1
+ require_relative "utils/misc"
2
+ require_relative "utils/manager"
3
+
3
4
  require "package_json"
4
5
 
5
6
  module Shakapacker
@@ -14,13 +15,8 @@ module Shakapacker
14
15
  @argv = argv
15
16
 
16
17
  @app_path = File.expand_path(".", Dir.pwd)
17
- @webpack_config = File.join(@app_path, "config/webpack/webpack.config.js")
18
18
  @shakapacker_config = ENV["SHAKAPACKER_CONFIG"] || File.join(@app_path, "config/shakapacker.yml")
19
-
20
- unless File.exist?(@webpack_config)
21
- $stderr.puts "webpack config #{@webpack_config} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or add the missing config file for your custom environment."
22
- exit!
23
- end
19
+ @webpack_config = find_webpack_config
24
20
 
25
21
  Shakapacker::Utils::Manager.error_unless_package_manager_is_obvious!
26
22
  end
@@ -28,5 +24,18 @@ module Shakapacker
28
24
  def package_json
29
25
  @package_json ||= PackageJson.read(@app_path)
30
26
  end
27
+
28
+ private
29
+ def find_webpack_config
30
+ possible_paths = %w[ts js].map do |ext|
31
+ File.join(@app_path, "config/webpack/webpack.config.#{ext}")
32
+ end
33
+ path = possible_paths.find { |f| File.exist?(f) }
34
+ unless path
35
+ $stderr.puts "webpack config #{possible_paths.last} not found, please run 'bundle exec rails shakapacker:install' to install Shakapacker with default configs or add the missing config file for your custom environment."
36
+ exit!
37
+ end
38
+ path
39
+ end
31
40
  end
32
41
  end
@@ -16,7 +16,7 @@ module Shakapacker
16
16
 
17
17
  # Emits a warning if it's not obvious what package manager to use
18
18
  def self.error_unless_package_manager_is_obvious!
19
- return unless PackageJson.read.fetch("packageManager", nil).nil?
19
+ return unless PackageJson.read(rails_root).fetch("packageManager", nil).nil?
20
20
 
21
21
  guessed_binary = guess_binary
22
22
 
@@ -35,7 +35,7 @@ module Shakapacker
35
35
  #
36
36
  # @return [String]
37
37
  def self.guess_binary
38
- MANAGER_LOCKS.find { |_, lock| File.exist?(lock) }&.first || "npm"
38
+ MANAGER_LOCKS.find { |_, lock| File.exist?(rails_root.join(lock)) }&.first || "npm"
39
39
  end
40
40
 
41
41
  # Guesses the version of the package manager to use by calling `<manager> --version`
@@ -53,6 +53,17 @@ module Shakapacker
53
53
 
54
54
  stdout.chomp
55
55
  end
56
+
57
+ private
58
+ def self.rails_root
59
+ if defined?(APP_ROOT)
60
+ Pathname.new(APP_ROOT)
61
+ elsif defined?(Rails)
62
+ Rails.root
63
+ else
64
+ raise "can only be called from a rails environment or with APP_ROOT defined"
65
+ end
66
+ end
56
67
  end
57
68
  end
58
69
  end
@@ -1,4 +1,4 @@
1
1
  module Shakapacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "8.0.2".freeze
3
+ VERSION = "8.1.0".freeze
4
4
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require "shakapacker/version"
2
+ require_relative "version"
3
3
 
4
4
  module Shakapacker
5
5
  class VersionChecker
@@ -1,5 +1,6 @@
1
1
  require "shellwords"
2
- require "shakapacker/runner"
2
+
3
+ require_relative "runner"
3
4
 
4
5
  module Shakapacker
5
6
  class WebpackRunner < Shakapacker::Runner
data/lib/shakapacker.rb CHANGED
@@ -37,13 +37,13 @@ module Shakapacker
37
37
  delegate :bootstrap, :clean, :clobber, :compile, to: :commands
38
38
  end
39
39
 
40
- require "shakapacker/instance"
41
- require "shakapacker/env"
42
- require "shakapacker/configuration"
43
- require "shakapacker/manifest"
44
- require "shakapacker/compiler"
45
- require "shakapacker/commands"
46
- require "shakapacker/dev_server"
47
- require "shakapacker/deprecation_helper"
48
-
49
- require "shakapacker/railtie" if defined?(Rails)
40
+ require_relative "shakapacker/instance"
41
+ require_relative "shakapacker/env"
42
+ require_relative "shakapacker/configuration"
43
+ require_relative "shakapacker/manifest"
44
+ require_relative "shakapacker/compiler"
45
+ require_relative "shakapacker/commands"
46
+ require_relative "shakapacker/dev_server"
47
+ require_relative "shakapacker/deprecation_helper"
48
+
49
+ require_relative "shakapacker/railtie" if defined?(Rails)
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shakapacker",
3
- "version": "8.0.2",
3
+ "version": "8.1.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": {
@@ -60,7 +60,7 @@
60
60
  "terser-webpack-plugin": "^5.3.1",
61
61
  "webpack": "^5.72.0",
62
62
  "webpack-assets-manifest": "^5.0.6",
63
- "webpack-cli": "^4.9.2 || ^5.0.0",
63
+ "webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
64
64
  "webpack-dev-server": "^4.9.0 || ^5.0.0",
65
65
  "webpack-merge": "^5.8.0 || ^6.0.0"
66
66
  },
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: 8.0.2
4
+ version: 8.1.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: 2024-08-29 00:00:00.000000000 Z
13
+ date: 2025-01-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -176,6 +176,8 @@ files:
176
176
  - gemfiles/Gemfile-rails.6.1.x
177
177
  - gemfiles/Gemfile-rails.7.0.x
178
178
  - gemfiles/Gemfile-rails.7.1.x
179
+ - gemfiles/Gemfile-rails.7.2.x
180
+ - gemfiles/Gemfile-rails.8.0.x
179
181
  - jest.config.js
180
182
  - lib/install/application.js
181
183
  - lib/install/bin/shakapacker
@@ -282,7 +284,7 @@ homepage: https://github.com/shakacode/shakapacker
282
284
  licenses:
283
285
  - MIT
284
286
  metadata:
285
- source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.0.2
287
+ source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.1.0
286
288
  post_install_message:
287
289
  rdoc_options: []
288
290
  require_paths:
@@ -298,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
300
  - !ruby/object:Gem::Version
299
301
  version: '0'
300
302
  requirements: []
301
- rubygems_version: 3.5.3
303
+ rubygems_version: 3.5.11
302
304
  signing_key:
303
305
  specification_version: 4
304
306
  summary: Use webpack to manage app-like JavaScript modules in Rails