webpacker 6.0.0.beta.6 → 6.0.0.beta.7

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: 3e389b1e654d5e3b6e50adb6a908c94cb1039e978b119f32c49c07813f0733ca
4
- data.tar.gz: 4843befc313e31f85996e36ce59c994f8c3842e82034da51872a2a4f8cb0e5d7
3
+ metadata.gz: 2425c109984a7a6029a78cecf6cbc2a9567cc91ea9fb9d85efc11bb4c7f5e591
4
+ data.tar.gz: c58f07ce11e2e4d8813016947f4365e681a3366225142cb5ba35a352063da428
5
5
  SHA512:
6
- metadata.gz: 8238ffb0c0b369bbffdf26766a237ca9ab059989aa79c9fa752fe8f217a79ee2985d00ec52861b7320fe2a5610d5df48941ddb597995bf95c846b381a3f7544d
7
- data.tar.gz: ce30d8500790565854a174e2ab67598a4fa7ff90eb67a226fb182861baba8d4bb7446958c0457c9b22aedaf345438f69f6542f52a672a6fa2204882220d5d277
6
+ metadata.gz: 405ea2a5d1be7ee478b7556e2306be7db07b48d48cbccf260a6bfcad71ccde747f114c1d71309571db3061dca03cd75bc719e2a400d09f7ab1eb6096e86662f9
7
+ data.tar.gz: 81458c1b088cf49dc03072a6fcd94dded64739b1820f2a83631c0eb36ecd2174d180a325353f2f950cefbc45db6d016e4151d0d81cb9b00f0615cb9667b1218f
data/.rubocop.yml CHANGED
@@ -118,3 +118,108 @@ Layout/EndAlignment:
118
118
  # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
119
119
  Lint/RequireParentheses:
120
120
  Enabled: true
121
+
122
+ # Use `bind_call(obj, args, ...)` instead of `bind(obj).call(args, ...)`.
123
+ Performance/BindCall:
124
+ Enabled: true
125
+
126
+ # Use `caller(n..n)` instead of `caller`.
127
+ Performance/Caller:
128
+ Enabled: true
129
+
130
+ # Use `casecmp` for case comparison.
131
+ Performance/Casecmp:
132
+ Enabled: true
133
+
134
+ # Extract Array and Hash literals outside of loops into local variables or constants.
135
+ Performance/CollectionLiteralInLoop:
136
+ Enabled: true
137
+
138
+ # Prefer `sort_by(&:foo)` instead of `sort { |a, b| a.foo <=> b.foo }`.
139
+ Performance/CompareWithBlock:
140
+ Enabled: true
141
+
142
+ # Use `count` instead of `{select,find_all,filter,reject}...{size,count,length}`.
143
+ Performance/Count:
144
+ Enabled: true
145
+
146
+ # Use `delete_prefix` instead of `gsub`.
147
+ Performance/DeletePrefix:
148
+ Enabled: true
149
+
150
+ # Use `delete_suffix` instead of `gsub`.
151
+ Performance/DeleteSuffix:
152
+ Enabled: true
153
+
154
+ # Use `detect` instead of `select.first`, `find_all.first`, `filter.first`, `select.last`, `find_all.last`, and `filter.last`.
155
+ Performance/Detect:
156
+ Enabled: true
157
+
158
+ # Use `str.{start,end}_with?(x, ..., y, ...)` instead of `str.{start,end}_with?(x, ...) || str.{start,end}_with?(y, ...)`.
159
+ Performance/DoubleStartEndWith:
160
+ Enabled: true
161
+
162
+ # Use `end_with?` instead of a regex match anchored to the end of a string.
163
+ Performance/EndWith:
164
+ Enabled: true
165
+
166
+ # Do not compute the size of statically sized objects except in constants.
167
+ Performance/FixedSize:
168
+ Enabled: true
169
+
170
+ # Use `Enumerable#flat_map` instead of `Enumerable#map...Array#flatten(1).
171
+ Performance/FlatMap:
172
+ Enabled: true
173
+
174
+ # Use `key?` or `value?` instead of `keys.include?` or `values.include?`.
175
+ Performance/InefficientHashSearch:
176
+ Enabled: true
177
+
178
+ # Use `Range#cover?` instead of `Range#include?` (or `Range#member?`).
179
+ Performance/RangeInclude:
180
+ Enabled: true
181
+
182
+ # Use `yield` instead of `block.call`.
183
+ Performance/RedundantBlockCall:
184
+ Enabled: true
185
+
186
+ # Use `=~` instead of `String#match` or `Regexp#match` in a context where the returned `MatchData` is not needed.
187
+ Performance/RedundantMatch:
188
+ Enabled: true
189
+
190
+ # Use Hash#[]=, rather than Hash#merge! with a single key-value pair.
191
+ Performance/RedundantMerge:
192
+ Enabled: true
193
+
194
+ # Use `match?` instead of `Regexp#match`, `String#match`, `Symbol#match`, `Regexp#===`, or `=~` when `MatchData` is not used.
195
+ Performance/RegexpMatch:
196
+ Enabled: true
197
+
198
+ # Use `reverse_each` instead of `reverse.each`.
199
+ Performance/ReverseEach:
200
+ Enabled: true
201
+
202
+ # Use `size` instead of `count` for counting the number of elements in `Array` and `Hash`.
203
+ Performance/Size:
204
+ Enabled: true
205
+
206
+ # Use `start_with?` instead of a regex match anchored to the beginning of a string.
207
+ Performance/StartWith:
208
+ Enabled: true
209
+
210
+ # Use `tr` instead of `gsub` when you are replacing the same number of characters.
211
+ # Use `delete` instead of `gsub` when you are deleting characters.
212
+ Performance/StringReplacement:
213
+ Enabled: true
214
+
215
+ # Checks for .times.map calls.
216
+ Performance/TimesMap:
217
+ Enabled: true
218
+
219
+ # Use unary plus to get an unfrozen string literal.
220
+ Performance/UnfreezeString:
221
+ Enabled: true
222
+
223
+ # Use `URI::DEFAULT_PARSER` instead of `URI::Parser.new`.
224
+ Performance/UriDefaultParser:
225
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ## [[6.0.0]](https://github.com/rails/webpacker/compare/v5.1.1...master) - 2021-TBD
6
6
 
7
+ Please see [UPGRADE GUIDE](./docs/v6_upgrade.md) for more informations.
8
+
7
9
  - `node_modules` will no longer be 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:
8
10
 
9
11
  ```js
@@ -27,8 +29,6 @@ environment.loaders.append('nodeModules', nodeModules)
27
29
  - CSS extraction enabled by default
28
30
  - Optional CSS support
29
31
 
30
- Please see upgrade [guide](./6_0_upgrade.md)
31
-
32
32
  ## [[5.2.1]](https://github.com/rails/webpacker/compare/v5.2.0...5.2.1) - 2020-08-17
33
33
 
34
34
  - Revert [#1311](https://github.com/rails/webpacker/pull/1311).
@@ -806,11 +806,11 @@ yarn add coffeescript
806
806
 
807
807
  ### Added
808
808
 
809
- - `resolved_paths` option to allow adding additional paths webpack should lookup when resolving modules
809
+ - `resolved_paths` option to allow adding additional paths webpack should look up when resolving modules
810
810
 
811
811
  ```yml
812
812
  # config/webpacker.yml
813
- # Additional paths webpack should lookup modules
813
+ # Additional paths webpack should look up modules
814
814
  resolved_paths: [] # empty by default
815
815
  ```
816
816
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (6.0.0.beta.6)
4
+ webpacker (6.0.0.beta.7)
5
5
  activesupport (>= 5.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 5.2)
@@ -10,89 +10,91 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (6.0.3.2)
14
- actionpack (= 6.0.3.2)
13
+ actioncable (6.1.3.1)
14
+ actionpack (= 6.1.3.1)
15
+ activesupport (= 6.1.3.1)
15
16
  nio4r (~> 2.0)
16
17
  websocket-driver (>= 0.6.1)
17
- actionmailbox (6.0.3.2)
18
- actionpack (= 6.0.3.2)
19
- activejob (= 6.0.3.2)
20
- activerecord (= 6.0.3.2)
21
- activestorage (= 6.0.3.2)
22
- activesupport (= 6.0.3.2)
18
+ actionmailbox (6.1.3.1)
19
+ actionpack (= 6.1.3.1)
20
+ activejob (= 6.1.3.1)
21
+ activerecord (= 6.1.3.1)
22
+ activestorage (= 6.1.3.1)
23
+ activesupport (= 6.1.3.1)
23
24
  mail (>= 2.7.1)
24
- actionmailer (6.0.3.2)
25
- actionpack (= 6.0.3.2)
26
- actionview (= 6.0.3.2)
27
- activejob (= 6.0.3.2)
25
+ actionmailer (6.1.3.1)
26
+ actionpack (= 6.1.3.1)
27
+ actionview (= 6.1.3.1)
28
+ activejob (= 6.1.3.1)
29
+ activesupport (= 6.1.3.1)
28
30
  mail (~> 2.5, >= 2.5.4)
29
31
  rails-dom-testing (~> 2.0)
30
- actionpack (6.0.3.2)
31
- actionview (= 6.0.3.2)
32
- activesupport (= 6.0.3.2)
33
- rack (~> 2.0, >= 2.0.8)
32
+ actionpack (6.1.3.1)
33
+ actionview (= 6.1.3.1)
34
+ activesupport (= 6.1.3.1)
35
+ rack (~> 2.0, >= 2.0.9)
34
36
  rack-test (>= 0.6.3)
35
37
  rails-dom-testing (~> 2.0)
36
38
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
- actiontext (6.0.3.2)
38
- actionpack (= 6.0.3.2)
39
- activerecord (= 6.0.3.2)
40
- activestorage (= 6.0.3.2)
41
- activesupport (= 6.0.3.2)
39
+ actiontext (6.1.3.1)
40
+ actionpack (= 6.1.3.1)
41
+ activerecord (= 6.1.3.1)
42
+ activestorage (= 6.1.3.1)
43
+ activesupport (= 6.1.3.1)
42
44
  nokogiri (>= 1.8.5)
43
- actionview (6.0.3.2)
44
- activesupport (= 6.0.3.2)
45
+ actionview (6.1.3.1)
46
+ activesupport (= 6.1.3.1)
45
47
  builder (~> 3.1)
46
48
  erubi (~> 1.4)
47
49
  rails-dom-testing (~> 2.0)
48
50
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.0.3.2)
50
- activesupport (= 6.0.3.2)
51
+ activejob (6.1.3.1)
52
+ activesupport (= 6.1.3.1)
51
53
  globalid (>= 0.3.6)
52
- activemodel (6.0.3.2)
53
- activesupport (= 6.0.3.2)
54
- activerecord (6.0.3.2)
55
- activemodel (= 6.0.3.2)
56
- activesupport (= 6.0.3.2)
57
- activestorage (6.0.3.2)
58
- actionpack (= 6.0.3.2)
59
- activejob (= 6.0.3.2)
60
- activerecord (= 6.0.3.2)
61
- marcel (~> 0.3.1)
62
- activesupport (6.0.3.2)
54
+ activemodel (6.1.3.1)
55
+ activesupport (= 6.1.3.1)
56
+ activerecord (6.1.3.1)
57
+ activemodel (= 6.1.3.1)
58
+ activesupport (= 6.1.3.1)
59
+ activestorage (6.1.3.1)
60
+ actionpack (= 6.1.3.1)
61
+ activejob (= 6.1.3.1)
62
+ activerecord (= 6.1.3.1)
63
+ activesupport (= 6.1.3.1)
64
+ marcel (~> 1.0.0)
65
+ mini_mime (~> 1.0.2)
66
+ activesupport (6.1.3.1)
63
67
  concurrent-ruby (~> 1.0, >= 1.0.2)
64
- i18n (>= 0.7, < 2)
65
- minitest (~> 5.1)
66
- tzinfo (~> 1.1)
67
- zeitwerk (~> 2.2, >= 2.2.2)
68
- ast (2.4.1)
68
+ i18n (>= 1.6, < 2)
69
+ minitest (>= 5.1)
70
+ tzinfo (~> 2.0)
71
+ zeitwerk (~> 2.3)
72
+ ast (2.4.2)
69
73
  builder (3.2.4)
70
74
  byebug (11.1.3)
71
- concurrent-ruby (1.1.6)
75
+ concurrent-ruby (1.1.8)
72
76
  crass (1.0.6)
73
- erubi (1.9.0)
77
+ erubi (1.10.0)
74
78
  globalid (0.4.2)
75
79
  activesupport (>= 4.2.0)
76
- i18n (1.8.5)
80
+ i18n (1.8.10)
77
81
  concurrent-ruby (~> 1.0)
78
- loofah (2.6.0)
82
+ loofah (2.9.1)
79
83
  crass (~> 1.0.2)
80
84
  nokogiri (>= 1.5.9)
81
85
  mail (2.7.1)
82
86
  mini_mime (>= 0.1.1)
83
- marcel (0.3.3)
84
- mimemagic (~> 0.3.2)
87
+ marcel (1.0.1)
85
88
  method_source (1.0.0)
86
- mimemagic (0.3.5)
87
- mini_mime (1.0.2)
89
+ mini_mime (1.0.3)
88
90
  mini_portile2 (2.5.0)
89
- minitest (5.14.3)
90
- nio4r (2.5.2)
91
- nokogiri (1.11.1)
91
+ minitest (5.14.4)
92
+ nio4r (2.5.7)
93
+ nokogiri (1.11.3)
92
94
  mini_portile2 (~> 2.5.0)
93
95
  racc (~> 1.4)
94
- parallel (1.19.2)
95
- parser (2.7.2.0)
96
+ parallel (1.20.1)
97
+ parser (3.0.1.0)
96
98
  ast (~> 2.4.1)
97
99
  racc (1.5.2)
98
100
  rack (2.2.3)
@@ -100,36 +102,36 @@ GEM
100
102
  rack
101
103
  rack-test (1.1.0)
102
104
  rack (>= 1.0, < 3)
103
- rails (6.0.3.2)
104
- actioncable (= 6.0.3.2)
105
- actionmailbox (= 6.0.3.2)
106
- actionmailer (= 6.0.3.2)
107
- actionpack (= 6.0.3.2)
108
- actiontext (= 6.0.3.2)
109
- actionview (= 6.0.3.2)
110
- activejob (= 6.0.3.2)
111
- activemodel (= 6.0.3.2)
112
- activerecord (= 6.0.3.2)
113
- activestorage (= 6.0.3.2)
114
- activesupport (= 6.0.3.2)
115
- bundler (>= 1.3.0)
116
- railties (= 6.0.3.2)
105
+ rails (6.1.3.1)
106
+ actioncable (= 6.1.3.1)
107
+ actionmailbox (= 6.1.3.1)
108
+ actionmailer (= 6.1.3.1)
109
+ actionpack (= 6.1.3.1)
110
+ actiontext (= 6.1.3.1)
111
+ actionview (= 6.1.3.1)
112
+ activejob (= 6.1.3.1)
113
+ activemodel (= 6.1.3.1)
114
+ activerecord (= 6.1.3.1)
115
+ activestorage (= 6.1.3.1)
116
+ activesupport (= 6.1.3.1)
117
+ bundler (>= 1.15.0)
118
+ railties (= 6.1.3.1)
117
119
  sprockets-rails (>= 2.0.0)
118
120
  rails-dom-testing (2.0.3)
119
121
  activesupport (>= 4.2.0)
120
122
  nokogiri (>= 1.6)
121
123
  rails-html-sanitizer (1.3.0)
122
124
  loofah (~> 2.3)
123
- railties (6.0.3.2)
124
- actionpack (= 6.0.3.2)
125
- activesupport (= 6.0.3.2)
125
+ railties (6.1.3.1)
126
+ actionpack (= 6.1.3.1)
127
+ activesupport (= 6.1.3.1)
126
128
  method_source
127
129
  rake (>= 0.8.7)
128
- thor (>= 0.20.3, < 2.0)
130
+ thor (~> 1.0)
129
131
  rainbow (3.0.0)
130
- rake (13.0.1)
131
- regexp_parser (1.8.2)
132
- rexml (3.2.4)
132
+ rake (13.0.3)
133
+ regexp_parser (2.1.1)
134
+ rexml (3.2.5)
133
135
  rubocop (0.93.1)
134
136
  parallel (~> 1.10)
135
137
  parser (>= 2.7.1.5)
@@ -139,29 +141,28 @@ GEM
139
141
  rubocop-ast (>= 0.6.0)
140
142
  ruby-progressbar (~> 1.7)
141
143
  unicode-display_width (>= 1.4.0, < 2.0)
142
- rubocop-ast (0.8.0)
144
+ rubocop-ast (1.4.1)
143
145
  parser (>= 2.7.1.5)
144
- rubocop-performance (1.8.1)
145
- rubocop (>= 0.87.0)
146
+ rubocop-performance (1.10.2)
147
+ rubocop (>= 0.90.0, < 2.0)
146
148
  rubocop-ast (>= 0.4.0)
147
- ruby-progressbar (1.10.1)
148
- semantic_range (2.3.0)
149
+ ruby-progressbar (1.11.0)
150
+ semantic_range (3.0.0)
149
151
  sprockets (4.0.2)
150
152
  concurrent-ruby (~> 1.0)
151
153
  rack (> 1, < 3)
152
- sprockets-rails (3.2.1)
154
+ sprockets-rails (3.2.2)
153
155
  actionpack (>= 4.0)
154
156
  activesupport (>= 4.0)
155
157
  sprockets (>= 3.0.0)
156
- thor (1.0.1)
157
- thread_safe (0.3.6)
158
- tzinfo (1.2.7)
159
- thread_safe (~> 0.1)
158
+ thor (1.1.0)
159
+ tzinfo (2.0.4)
160
+ concurrent-ruby (~> 1.0)
160
161
  unicode-display_width (1.7.0)
161
162
  websocket-driver (0.7.3)
162
163
  websocket-extensions (>= 0.1.0)
163
164
  websocket-extensions (0.1.5)
164
- zeitwerk (2.4.0)
165
+ zeitwerk (2.4.2)
165
166
 
166
167
  PLATFORMS
167
168
  ruby
@@ -179,4 +180,4 @@ DEPENDENCIES
179
180
  webpacker!
180
181
 
181
182
  BUNDLED WITH
182
- 2.1.4
183
+ 2.2.3
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  [![Gem](https://img.shields.io/gem/v/webpacker.svg)](https://rubygems.org/gems/webpacker)
10
10
 
11
11
  Webpacker makes it easy to use the JavaScript pre-processor and bundler
12
- [webpack 5.x.x+](https://webpack.js.org/)
12
+ [Webpack v5](https://webpack.js.org/)
13
13
  to manage application-like JavaScript in Rails. It coexists with the asset pipeline,
14
14
  as the primary purpose for webpack is app-like JavaScript, not images, CSS, or
15
15
  even JavaScript Sprinkles (that all continues to live in app/assets).
@@ -46,11 +46,11 @@ in which case you may not even need the asset pipeline. This is mostly relevant
46
46
  - Ruby 2.4+
47
47
  - Rails 5.2+
48
48
  - Node.js 10.22.1+ || 12+ || 14+
49
- - Yarn 1.x+
49
+ - Yarn 1.x+ || 2.x+
50
50
 
51
51
  ## Features
52
52
 
53
- - [webpack 5.x.x](https://webpack.js.org/)
53
+ - [Webpack v5](https://webpack.js.org/)
54
54
  - ES6 with [babel](https://babeljs.io/)
55
55
  - Automatic code splitting using multiple entry points
56
56
  - Asset compression, source-maps, and minification
@@ -107,8 +107,7 @@ yarn upgrade
107
107
  When `package.json` and/or `yarn.lock` changes, such as when pulling down changes to your local environment in a team settings, be sure to keep your NPM packages up-to-date:
108
108
 
109
109
  ```bash
110
- # default for `yarn` is to install
111
- yarn
110
+ yarn install
112
111
  ```
113
112
 
114
113
  ### Usage
@@ -118,7 +117,7 @@ Once installed, you can start writing modern ES6-flavored JavaScript apps right
118
117
  ```yml
119
118
  app/packs:
120
119
  ├── entrypoints:
121
- │ # Only webpack entry files here
120
+ │ # Only Webpack entry files here
122
121
  │ └── application.js
123
122
  │ └── application.css
124
123
  └── src:
@@ -165,7 +164,7 @@ If you want to use images in your stylesheets:
165
164
  }
166
165
  ```
167
166
 
168
- Note, if you are using server-side rendering of JavaScript with dynamic code-spliting,
167
+ Note, if you are using server-side rendering of JavaScript with dynamic code-spliting,
169
168
  as is often done with extensions to Webpacker, like [React on Rails](https://github.com/shakacode/react_on_rails)
170
169
  your JavaScript should create the link prefetch HTML tags that you will use, so you won't
171
170
  need to use to `asset_pack_path` in those circumstances.
@@ -190,7 +189,7 @@ be painfully slow for front-end development in this default way. Instead, you sh
190
189
  run the `bin/webpack --watch` or run `./bin/webpack-dev-server`
191
190
 
192
191
  If you want to use live code reloading, or you have enough JavaScript that on-demand compilation is too slow, you'll need to run `./bin/webpack-dev-server` or `ruby ./bin/webpack-dev-server`.
193
- Windows users will need to run these commands in a terminal separate from `bundle exec rails s`.
192
+ Windows users will need to run these commands in a terminal separate from `bundle exec rails s`.
194
193
  This process will watch for changes in the `app/packs/entrypoints/*.js` files and automatically
195
194
  reload the browser to match. This feature is also known as
196
195
  [Hot Module Replacement](https://webpack.js.org/concepts/hot-module-replacement/).
@@ -437,7 +436,7 @@ if you are using typescript, update your `tsconfig.json`
437
436
  ```
438
437
 
439
438
  For more information on React props hydration and Server-Side Rendering (SSR), see the article
440
- [Rails/Webpacker React Integration Options](https://github.com/shakacode/react_on_rails/blob/master/docs/rails-webpacker-react-integration-options.md)
439
+ [Rails/Webpacker React Integration Options](https://github.com/shakacode/react_on_rails/blob/master/docs/rails-webpacker-react-integration-options.md)
441
440
  in the [ShakaCode/react_on_rails](https://github.com/shakacode/react_on_rails) repo.
442
441
 
443
442
  #### Other frameworks
@@ -576,7 +575,7 @@ development:
576
575
  ```
577
576
 
578
577
  If you have `hmr` turned to true, then the `stylesheet_pack_tag` generates no output,
579
- as you will want to configure your styles to be inlined in your JavaScript for hot reloading.
578
+ as you will want to configure your styles to be inlined in your JavaScript for hot reloading.
580
579
  During production and testing, the `stylesheet_pack_tag` will create the appropriate HTML tags.
581
580
 
582
581
  ### Additional paths
@@ -585,7 +584,7 @@ If you are adding Webpacker to an existing app that has most of the assets insid
585
584
  `app/assets` or inside an engine, and you want to share that
586
585
  with webpack modules, you can use the `additional_paths`
587
586
  option available in `config/webpacker.yml`. This lets you
588
- add additional paths that webpack should lookup when resolving modules:
587
+ add additional paths that webpack should look up when resolving modules:
589
588
 
590
589
  ```yml
591
590
  additional_paths: ['app/assets', 'vendor/assets']
@@ -609,6 +608,8 @@ Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which
609
608
 
610
609
  When compiling assets for production on a remote server, such as a continuous integration environment, it's recommended to use `yarn install --frozen-lockfile` to install NPM packages on the remote host to ensure that the installed packages match the `yarn.lock` file.
611
610
 
611
+ If you are using a CDN setup, webpacker will use the configured [asset host](https://guides.rubyonrails.org/configuring.html#rails-general-configuration) value to prefix URLs for images or font icons which are included inside JS code or CSS. It is possible to override this value during asset compilation by setting the `WEBPACKER_ASSET_HOST` environment variable.
612
+
612
613
  ## Troubleshooting
613
614
 
614
615
  See the doc page for [Troubleshooting](./docs/troubleshooting.md).
@@ -0,0 +1,128 @@
1
+ # Deployment
2
+
3
+ Webpacker hooks up a new `webpacker:compile` task to `assets:precompile`, which gets run whenever you run `assets:precompile`.
4
+ If you are not using Sprockets `webpacker:compile` is automatically aliased to `assets:precompile`. Remember to set `NODE_ENV` environment variable to production during deployment or when running the rake task.
5
+
6
+ The `javascript_pack_tag` and `stylesheet_pack_tag` helper method will automatically insert the correct HTML tag for compiled pack. Just like the asset pipeline does it.
7
+
8
+ By default the output will look like this in different environments:
9
+
10
+ ```html
11
+ <!-- In development mode with webpack-dev-server -->
12
+ <script src="http://localhost:8080/calendar-0bd141f6d9360cf4a7f5.js"></script>
13
+ <link rel="stylesheet" media="screen" href="http://localhost:8080/calendar-dc02976b5f94b507e3b6.css">
14
+
15
+ <!-- In production or development mode -->
16
+ <script src="/packs/js/calendar-0bd141f6d9360cf4a7f5.js"></script>
17
+ <link rel="stylesheet" media="screen" href="/packs/css/calendar-dc02976b5f94b507e3b6.css">
18
+ ```
19
+
20
+ ## Heroku
21
+
22
+ In order for your Webpacker app to run on Heroku, you'll need to do a bit of configuration before hand.
23
+
24
+ ```bash
25
+ heroku create my-webpacker-heroku-app
26
+ heroku addons:create heroku-postgresql:hobby-dev
27
+ heroku buildpacks:add heroku/nodejs
28
+ heroku buildpacks:add heroku/ruby
29
+ git push heroku master
30
+ ```
31
+
32
+ We're essentially doing the following here:
33
+
34
+ * Creating an app on Heroku
35
+ * Creating a Postgres database for the app (this is assuming that you're using Heroku Postgres for your app)
36
+ * Adding the Heroku NodeJS and Ruby buildpacks for your app. This allows the `npm` or `yarn` executables to properly function when compiling your app - as well as Ruby.
37
+ * Pushing our code to Heroku and kicking off the deployment
38
+
39
+ ## Nginx
40
+
41
+ Webpacker doesn't serve anything in production. You’re expected to configure your web server to serve files in public/ directly.
42
+
43
+ Some servers support sending precompressed versions of files when they're available. For example, nginx offers a `gzip_static` directive that serves files with the `.gz` extension to supported clients. With an optional module, nginx can also serve Brotli compressed files with the `.br` extension (see below for installation and configuration instructions).
44
+
45
+ Here's a sample nginx site config for a Rails app using Webpacker:
46
+
47
+ ```nginx
48
+ upstream app {
49
+ # server unix:///path/to/app/tmp/puma.sock;
50
+ }
51
+
52
+ server {
53
+ listen 80;
54
+ server_name www.example.com;
55
+ root /path/to/app/public;
56
+
57
+ location @app {
58
+ proxy_pass http://app;
59
+ proxy_redirect off;
60
+
61
+ proxy_set_header Host $host;
62
+ proxy_set_header X-Real-IP $remote_addr;
63
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
64
+ proxy_set_header X-Forwarded-Proto $scheme;
65
+ }
66
+
67
+ location / {
68
+ try_files $uri @app;
69
+ }
70
+
71
+ location = /favicon.ico { access_log off; log_not_found off; }
72
+ location = /robots.txt { access_log off; log_not_found off; }
73
+
74
+ location ~ /\.(?!well-known).* {
75
+ deny all;
76
+ }
77
+
78
+ location ~ ^/(assets|packs)/ {
79
+ gzip_static on;
80
+ brotli_static on; # Optional, see below
81
+ expires max;
82
+ add_header Cache-Control public;
83
+ }
84
+ }
85
+ ```
86
+
87
+ ### Installing the ngx_brotli module
88
+
89
+ If you want to serve Brotli compressed files with nginx, you will need to install the `nginx_brotli` module. Installation instructions from source can be found in the official [google/ngx_brotli](https://github.com/google/ngx_brotli) git repository. Alternatively, depending on your platform, the module might be available via a pre-compiled package.
90
+
91
+ Once installed, you need to load the module. As we want to serve the pre-compressed files, we only need the static module. Add the following line to your `nginx.conf` file and reload nginx:
92
+
93
+ ```
94
+ load_module modules/ngx_http_brotli_static_module.so;
95
+ ```
96
+
97
+ Now, you can set `brotli_static on;` in your nginx site config, as per the config in the last section above.
98
+
99
+ ## CDN
100
+
101
+ Webpacker out-of-the-box provides CDN support using your Rails app `config.action_controller.asset_host` setting. If you already have [CDN](http://guides.rubyonrails.org/asset_pipeline.html#cdns) added in your Rails app
102
+ you don't need to do anything extra for Webpacker, it just works.
103
+
104
+ ## Capistrano
105
+
106
+ ### Assets compiling on every deployment even if JavaScript and CSS files are not changed
107
+
108
+ Make sure you have `public/packs` and `node_modules` in `:linked_dirs`
109
+
110
+ ```ruby
111
+ append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/packs", ".bundle", "node_modules"
112
+ ```
113
+
114
+ If you have `node_modules` added to `:linked_dirs` you'll need to run yarn install before `deploy:assets:precompile`, so you can add this code snippet at the bottom deploy.rb
115
+
116
+ ```ruby
117
+ before "deploy:assets:precompile", "deploy:yarn_install"
118
+ namespace :deploy do
119
+ desc "Run rake yarn install"
120
+ task :yarn_install do
121
+ on roles(:web) do
122
+ within release_path do
123
+ execute("cd #{release_path} && yarn install --silent --no-progress --no-audit --no-optional")
124
+ end
125
+ end
126
+ end
127
+ end
128
+ ```
@@ -0,0 +1,86 @@
1
+ # To Webpacker v6 from v5
2
+
3
+ This guide aims to help you migrating to Webpacker 6. If you are using vanilla Webpacker install then hopefully, the upgrade should be really straightforward.
4
+
5
+ ## Main differences with v5
6
+
7
+ The main goal for Webpacker v6 is to manage the JavaScript in your Rails application with Webpack. This will allows you, for example, to use JavaScript modules, automatic code splitting using multiple entry points, use PostCSS or use [Vue](https://vuejs.org/) or [React](https://reactjs.org/).
8
+
9
+ You probably don't want to install Webpacker and Webpack if you only need some JavaScript Sprinkles, Sass integration, images and fonts support.
10
+
11
+ ### Default integrations
12
+
13
+ By default, Webpacker v6 out of the box supports JS and static assets (fonts, images etc.) compilation. Webpacker now detects automatically relevant packages to support more tools.
14
+
15
+ See [Integrations](https://github.com/rails/webpacker#integrations) for more information.
16
+
17
+ Why? Because most developers don't need to handle CSS, SASS or another tools with Webpack. [Sprockets](https://github.com/rails/sprockets) is probably enough and we don't want to make things harder.
18
+
19
+ ### Simpler API
20
+
21
+ Webpacker is still a wrapper around [Webpack](https://webpack.js.org/) to simplify the integration in your Rails application.
22
+
23
+ But we noticed that the [Webpacker v5 configuration](https://github.com/rails/webpacker/blob/5-x-stable/docs/webpack.md) was a bit confusing mostly because Webpack is a complicated beast to manage.
24
+
25
+ There are so many different toolchains in JavaScript these days, it would be impossible to create te perfect configuration for everybody. That is also why defaults installers have been removed.
26
+
27
+ In order to simplify even more the configuration, the custom API to manage the Webpack configuration has been removed.
28
+
29
+ Now you have a straight access to the Webpack configuration and you can change it very easily with webpack-merge. So now, you can refer to the documentation of the tools you want to install it with Webpack. Here is an example with [Vue](https://github.com/rails/webpacker#other-frameworks).
30
+
31
+ ## How to upgrade to Webpacker v6
32
+
33
+ 1. If your `source_path` is `app/javascript`, rename it to `app/packs`
34
+ 2. If your `source_entry_path` is `packs`, rename it to `entrypoints`
35
+ 3. Rename `config/webpack` to `config/webpack_old`
36
+ 4. Rename `config/webpacker.yml` to `config/webpacker_old.yml`
37
+ 5. Uninstall the current version of `webpack-dev-server`: `yarn remove webpack-dev-server`
38
+ 6. Upgrade Webpacker
39
+
40
+ ```ruby
41
+ # Gemfile
42
+ gem 'webpacker', '~> 6.0.0.pre.2'
43
+ ```
44
+
45
+ ```bash
46
+ bundle install
47
+ ```
48
+
49
+ ```bash
50
+ yarn add @rails/webpacker@next
51
+ ```
52
+
53
+ ```bash
54
+ bundle exec rails webpacker:install
55
+ ```
56
+
57
+ - Change `javascript_packs_with_chunks_tag` and `stylesheet_packs_with_chunks_tag` to `javascript_pack_tag` and
58
+ `stylesheet_pack_tag`.
59
+
60
+ 7. If you are using any integrations like `css`, `React` or `TypeScript`. Please see https://github.com/rails/webpacker#integrations section on how they work in v6.
61
+
62
+ 8. Copy over any custom webpack config from `config/webpack_old`
63
+
64
+ - Common code previously called 'environment' changed to 'base'
65
+ - import `environment` changed name to `webpackConfig`.
66
+
67
+ ```js
68
+ // config/webpack/base.js
69
+ const { webpackConfig, merge } = require('@rails/webpacker')
70
+ const customConfig = require('./custom')
71
+
72
+ module.exports = merge(webpackConfig, customConfig)
73
+ ```
74
+
75
+ 9. Copy over custom browserlist config from `.browserlistrc` if it exists into the `"browserlist"` key in `package.json` and remove `.browserslistrc`.
76
+
77
+ 10. `extensions` was removed from the webpacker.yml file. Move custom extensions to
78
+ your configuration by by merging an object like this. For more details, see docs for
79
+ [Webpack Configuration](https://github.com/rails/webpacker/blob/master/README.md#webpack-configuration)
80
+ ```js
81
+ {
82
+ resolve: {
83
+ extensions: ['.ts', '.tsx']
84
+ }
85
+ }
86
+ ```
@@ -8,7 +8,7 @@ default: &default
8
8
  cache_path: tmp/cache/webpacker
9
9
  webpack_compile_output: true
10
10
 
11
- # Additional paths webpack should lookup modules
11
+ # Additional paths webpack should look up modules
12
12
  # ['app/assets', 'engine/foo/app/assets']
13
13
  additional_paths: []
14
14
 
@@ -26,13 +26,15 @@ if File.exists?(git_ignore_path)
26
26
  end
27
27
  end
28
28
 
29
+ results = []
30
+
29
31
  Dir.chdir(Rails.root) do
30
- if Webpacker::VERSION =~ /^[0-9]+\.[0-9]+\.[0-9]+$/
32
+ if Webpacker::VERSION.match?(/^[0-9]+\.[0-9]+\.[0-9]+$/)
31
33
  say "Installing all JavaScript dependencies [#{Webpacker::VERSION}]"
32
- run "yarn add @rails/webpacker@#{Webpacker::VERSION}"
34
+ results << run("yarn add @rails/webpacker@#{Webpacker::VERSION}")
33
35
  else
34
36
  say "Installing all JavaScript dependencies [from prerelease rails/webpacker]"
35
- run "yarn add @rails/webpacker@next"
37
+ results << run("yarn add @rails/webpacker@next")
36
38
  end
37
39
 
38
40
  package_json = File.read("#{__dir__}/../../package.json")
@@ -41,10 +43,10 @@ Dir.chdir(Rails.root) do
41
43
 
42
44
  # needed for experimental Yarn 2 support and should not harm Yarn 1
43
45
  say "Installing webpack and webpack-cli as direct dependencies"
44
- run "yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}"
46
+ results << run("yarn add webpack@#{webpack_version} webpack-cli@#{webpack_cli_version}")
45
47
 
46
48
  say "Installing dev server for live reloading"
47
- run "yarn add --dev webpack-dev-server @webpack-cli/serve"
49
+ results << run("yarn add --dev webpack-dev-server @webpack-cli/serve")
48
50
  end
49
51
 
50
52
  insert_into_file Rails.root.join("package.json").to_s, before: /\n}\n*$/ do
@@ -66,4 +68,9 @@ if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR > 1
66
68
  say "policy.connect_src :self, :https, \"http://localhost:3035\", \"ws://localhost:3035\" if Rails.env.development?", :yellow
67
69
  end
68
70
 
69
- say "Webpacker successfully installed 🎉 🍰", :green
71
+ if results.all?
72
+ say "Webpacker successfully installed 🎉 🍰", :green
73
+ else
74
+ say "Webpacker installation failed 😭 See above for details.", :red
75
+ exit 1
76
+ end
@@ -7,9 +7,9 @@ namespace :webpacker do
7
7
  prefix = task.name.split(/#|webpacker:binstubs/).first
8
8
 
9
9
  if Rails::VERSION::MAJOR >= 5
10
- exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION=#{binstubs_template_path}"
10
+ exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{binstubs_template_path}'"
11
11
  else
12
- exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION=#{binstubs_template_path}"
12
+ exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{binstubs_template_path}'"
13
13
  end
14
14
  end
15
15
  end
@@ -3,6 +3,7 @@ namespace :webpacker do
3
3
  desc "Verifies if Node.js is installed"
4
4
  task :check_node do
5
5
  begin
6
+ raise Errno::ENOENT if `which node || which nodejs`.strip.empty?
6
7
  node_version = `node -v || nodejs -v`.strip
7
8
  raise Errno::ENOENT if node_version.blank?
8
9
 
@@ -3,6 +3,7 @@ namespace :webpacker do
3
3
  desc "Verifies if Yarn is installed"
4
4
  task :check_yarn do
5
5
  begin
6
+ raise Errno::ENOENT if `which yarn`.strip.empty?
6
7
  yarn_version = `yarn --version`.strip
7
8
  raise Errno::ENOENT if yarn_version.blank?
8
9
 
@@ -7,9 +7,9 @@ namespace :webpacker do
7
7
  prefix = task.name.split(/#|webpacker:install/).first
8
8
 
9
9
  if Rails::VERSION::MAJOR >= 5
10
- exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION=#{install_template_path}"
10
+ exec "#{RbConfig.ruby} #{bin_path}/rails #{prefix}app:template LOCATION='#{install_template_path}'"
11
11
  else
12
- exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION=#{install_template_path}"
12
+ exec "#{RbConfig.ruby} #{bin_path}/rake #{prefix}rails:template LOCATION='#{install_template_path}'"
13
13
  end
14
14
  end
15
15
  end
@@ -63,11 +63,11 @@ class Webpacker::Configuration
63
63
  fetch(:webpack_compile_output)
64
64
  end
65
65
 
66
- private
67
- def fetch(key)
68
- data.fetch(key, defaults[key])
69
- end
66
+ def fetch(key)
67
+ data.fetch(key, defaults[key])
68
+ end
70
69
 
70
+ private
71
71
  def data
72
72
  @data ||= load
73
73
  end
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "6.0.0.beta.6".freeze
3
+ VERSION = "6.0.0.beta.7".freeze
4
4
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "6.0.0-beta.6",
3
+ "version": "6.0.0-beta.7",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -10,7 +10,6 @@ const WebpackAssetsManifest = require('webpack-assets-manifest')
10
10
  const webpack = require('webpack')
11
11
  const rules = require('../rules')
12
12
  const config = require('../config')
13
- const { isDevelopment } = require('../env')
14
13
  const { moduleExists } = require('../utils/helpers')
15
14
 
16
15
  const getEntryObject = () => {
@@ -67,12 +66,8 @@ const getPlugins = () => {
67
66
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
68
67
  plugins.push(
69
68
  new MiniCssExtractPlugin({
70
- filename: isDevelopment
71
- ? 'css/[name].css'
72
- : 'css/[name]-[contenthash:8].css',
73
- chunkFilename: isDevelopment
74
- ? 'css/[id].css'
75
- : 'css/[id]-[contenthash:8].css'
69
+ filename: 'css/[name]-[contenthash:8].css',
70
+ chunkFilename: 'css/[id]-[contenthash:8].css'
76
71
  })
77
72
  )
78
73
  }
@@ -37,7 +37,7 @@ const tryCssMinimizer = () => {
37
37
  moduleExists('css-minimizer-webpack-plugin')
38
38
  ) {
39
39
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
40
- return new CssMinimizerPlugin({ sourceMap: true })
40
+ return new CssMinimizerPlugin()
41
41
  }
42
42
 
43
43
  return null
@@ -6,7 +6,7 @@ default: &default
6
6
  public_output_path: packs
7
7
  cache_path: tmp/cache/webpacker
8
8
 
9
- # Additional paths webpack should lookup modules
9
+ # Additional paths webpack should look up modules
10
10
  # ['app/assets', 'engine/foo/app/assets']
11
11
  additional_paths:
12
12
  - app/assets
@@ -8,7 +8,7 @@ default: &default
8
8
  cache_path: tmp/cache/webpacker
9
9
  webpack_compile_output: false
10
10
 
11
- # Additional paths webpack should lookup modules
11
+ # Additional paths webpack should look up modules
12
12
  # ['app/assets', 'engine/foo/app/assets']
13
13
  additional_paths:
14
14
  - app/assets
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.beta.6
4
+ version: 6.0.0.beta.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-27 00:00:00.000000000 Z
12
+ date: 2021-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -126,7 +126,6 @@ files:
126
126
  - ".gitignore"
127
127
  - ".node-version"
128
128
  - ".rubocop.yml"
129
- - 6_0_upgrade.md
130
129
  - CHANGELOG.md
131
130
  - CONTRIBUTING.md
132
131
  - Gemfile
@@ -136,7 +135,9 @@ files:
136
135
  - Rakefile
137
136
  - config/README.md
138
137
  - config/webpacker.yml
138
+ - docs/deployment.md
139
139
  - docs/troubleshooting.md
140
+ - docs/v6_upgrade.md
140
141
  - gemfiles/Gemfile-rails-edge
141
142
  - gemfiles/Gemfile-rails.5.2.x
142
143
  - gemfiles/Gemfile-rails.6.0.x
@@ -253,8 +254,8 @@ homepage: https://github.com/rails/webpacker
253
254
  licenses:
254
255
  - MIT
255
256
  metadata:
256
- source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.6
257
- changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.6/CHANGELOG.md
257
+ source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.7
258
+ changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.7/CHANGELOG.md
258
259
  post_install_message:
259
260
  rdoc_options: []
260
261
  require_paths:
@@ -270,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
271
  - !ruby/object:Gem::Version
271
272
  version: 1.3.1
272
273
  requirements: []
273
- rubygems_version: 3.0.3
274
+ rubygems_version: 3.2.3
274
275
  signing_key:
275
276
  specification_version: 4
276
277
  summary: Use webpack to manage app-like JavaScript modules in Rails
data/6_0_upgrade.md DELETED
@@ -1,62 +0,0 @@
1
- # To webpacker v6 from v5
2
-
3
- This guide aims to help you migrating to webpacker 6. If you are using
4
- vanilla webpacker install then hopefully, the upgrade should be really
5
- straightforward.
6
-
7
- ## Preparation
8
-
9
- 1. If your `source_path` is `app/javascript`, rename it to `app/packs`
10
- 2. If your `source_entry_path` is `packs`, rename it to `entrypoints`
11
- 3. Rename `config/webpack` to `config/webpack_old`
12
- 4. Rename `config/webpacker.yml` to `config/webpacker_old.yml`
13
- 5. Uninstall the current version of `webpack-dev-server`: `yarn remove webpack-dev-server`
14
- 6. Upgrade webpacker
15
-
16
- ```ruby
17
- # Gemfile
18
- gem 'webpacker', '~> 6.0.0.pre.2'
19
- ```
20
-
21
- ```bash
22
- bundle install
23
- ```
24
-
25
- ```bash
26
- yarn add @rails/webpacker@next
27
- ```
28
-
29
- ```bash
30
- bundle exec rails webpacker:install
31
- ```
32
-
33
- - Change `javascript_packs_with_chunks_tag` and `stylesheet_packs_with_chunks_tag` to `javascript_pack_tag` and
34
- `stylesheet_pack_tag`.
35
-
36
- 7. If you are using any integrations like `css`, `React` or `TypeScript`. Please see https://github.com/rails/webpacker#integrations section on how they work in v6.0.
37
-
38
- 8. Copy over any custom webpack config from `config/webpack_old`
39
-
40
- - Common code previously called 'environment' changed to 'base'
41
- - import `environment` changed name to `webpackConfig`.
42
-
43
- ```js
44
- // config/webpack/base.js
45
- const { webpackConfig, merge } = require('@rails/webpacker')
46
- const customConfig = require('./custom')
47
-
48
- module.exports = merge(webpackConfig, customConfig)
49
- ```
50
-
51
- 9. Copy over custom browserlist config from `.browserlistrc` if it exists into the `"browserlist"` key in `package.json` and remove `.browserslistrc`.
52
-
53
- 10. `extensions` was removed from the webpacker.yml file. Move custom extensions to
54
- your configuration by by merging an object like this. For more details, see docs for
55
- [Webpack Configuration](https://github.com/rails/webpacker/blob/master/README.md#webpack-configuration)
56
- ```js
57
- {
58
- resolve: {
59
- extensions: ['.ts', '.tsx']
60
- }
61
- }
62
- ```