webpacker 6.0.0.beta.2 → 6.0.0.beta.3

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: 70198a585cf22360094497e860a23dcd172c7926820eaa905b00eaf15c997010
4
- data.tar.gz: a1ff9f0cc031d1fffc69813b071b10947aa1648fbedaee826be547bd03adcdc2
3
+ metadata.gz: ab62c5d5a1d4736592168baa8920743203529b76be71a5f551058ab20ee04204
4
+ data.tar.gz: e992911dd9c65cde8af17479b98b4efde3e12a98196ab586a09320fff9f1c00c
5
5
  SHA512:
6
- metadata.gz: 2e16cfe7311345f9e2af7e4b821ada9acdaff357ff64cbbbebf038a43199dcafa3b82c403bec1f9ab182ff456efd9ff14eb9756b4edbd76c68beba3cf8543cdc
7
- data.tar.gz: de893725da86a372346c6c552a49a4efb078e24343e16a173b6d51230dc2ccb8bc26d5fbf8726d6d8f8d1a7277eea81d3ed29a06c76998db98cb5970c040bcb0
6
+ metadata.gz: df861ac4efabed724387cd80542f4a1203b47ba93da1e15b232fd323345d9ed7ac7230ca51ffb20f30a046ad57a61dc1be4d45ae613fbfcb6ca3622de5775d7a
7
+ data.tar.gz: 7a728cb196c75ca876cf407a20e6d2ae1dbf149cbe1755bdf4a698300b0d2ecc7b8f5b827a2a35d07d8cd1ffcd5e8727573319bcb8982239bb04550e8b079776
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  os: [ubuntu-latest]
11
- node: [10.x, 12.x, 14.x]
11
+ node: [10.x, 12.x, 14.x, 15.x]
12
12
 
13
13
  runs-on: ${{ matrix.os }}
14
14
 
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  matrix:
11
11
  os: [ubuntu-latest]
12
- node: [12.x]
12
+ node: [14.x]
13
13
 
14
14
  runs-on: ${{ matrix.os }}
15
15
 
@@ -18,7 +18,8 @@ jobs:
18
18
  2.4,
19
19
  2.5,
20
20
  2.6,
21
- 2.7
21
+ 2.7,
22
+ 3.0
22
23
  ]
23
24
  gemfile: [
24
25
  "gemfiles/Gemfile-rails.5.2.x",
@@ -27,13 +28,11 @@ jobs:
27
28
  exclude:
28
29
  - ruby: "2.4"
29
30
  gemfile: gemfiles/Gemfile-rails.6.0.x
31
+ - ruby: "3.0"
32
+ gemfile: gemfiles/Gemfile-rails.5.2.x
30
33
  experimental: [false]
31
34
  include:
32
- - ruby: head
33
- os: ubuntu-latest
34
- gemfile: gemfiles/Gemfile-rails.6.0.x
35
- experimental: true
36
- - ruby: head
35
+ - ruby: 2.5
37
36
  os: ubuntu-latest
38
37
  gemfile: gemfiles/Gemfile-rails-edge
39
38
  experimental: true
@@ -45,6 +44,10 @@ jobs:
45
44
  os: ubuntu-latest
46
45
  gemfile: gemfiles/Gemfile-rails-edge
47
46
  experimental: true
47
+ - ruby: 3.0
48
+ os: ubuntu-latest
49
+ gemfile: gemfiles/Gemfile-rails-edge
50
+ experimental: true
48
51
 
49
52
  steps:
50
53
  - uses: actions/checkout@v2
@@ -6,17 +6,20 @@ straightforward.
6
6
 
7
7
  ## Preparation
8
8
 
9
- - Rename `config/webpack` to `config/webpack_old`
10
- - Rename `config/webpacker.yml` to `config/webpacker_old.yml`
11
- - Upgrade webpacker
9
+ 1. If your `source_path` is `app/javascript`, rename it to `app/packs`
10
+ 2. If your `source_entry_path` is `app/javascript/packs`, rename it to `app/packs/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
12
15
 
13
16
  ```ruby
14
17
  # Gemfile
15
- gem 'webpacker', '~> 6.x'
18
+ gem 'webpacker', '~> 6.0.0.pre.2'
16
19
  ```
17
20
 
18
- ```
19
- bundle
21
+ ```bash
22
+ bundle install
20
23
  ```
21
24
 
22
25
  ```bash
@@ -30,9 +33,9 @@ straightforward.
30
33
  - Change `javascript_pack_tag` and `stylesheet_pack_tag` to `javascript_packs_with_chunks_tag` and
31
34
  `stylesheet_packs_with_chunks_tag`
32
35
 
33
- - 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
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.
34
37
 
35
- - Copy over any custom webpack config from `config/webpack_old`
38
+ 8. Copy over any custom webpack config from `config/webpack_old`
36
39
 
37
40
  ```js
38
41
  // config/webpack/base.js
@@ -41,3 +44,5 @@ straightforward.
41
44
 
42
45
  module.exports = merge(webpackConfig, customConfig)
43
46
  ```
47
+
48
+ 9. Copy over custom browserlist config from `.browserlistrc` if it exists into the `"browserlist"` key in `package.json` and remove `.browserslistrc`.
@@ -17,6 +17,8 @@ environment.loaders.append('nodeModules', nodeModules)
17
17
  - Changes `@babel/preset-env` modules option to `'auto'` per recommendation in the Babel docs [#2709](https://github.com/rails/webpacker/pull/2709)
18
18
  - Adds experimental Yarn 2 support. Note you must manually set `nodeLinker: node-modules` in your `.yarnrc.yml`.
19
19
 
20
+ - Fixes dev server issues [#2898](https://github.com/rails/webpacker/pull/2898)
21
+
20
22
  ### Breaking changes
21
23
 
22
24
  - Simple webpack config
@@ -9,7 +9,7 @@ yarn
9
9
  ```
10
10
 
11
11
  ## Making sure your changes pass all tests
12
- There are a number of automated checks which run on Github Actions when a pull request is created.
12
+ There are a number of automated checks which run on GitHub Actions when a pull request is created.
13
13
  You can run those checks on your own locally to make sure that your changes would not break the CI build.
14
14
 
15
15
  ### 1. Check the code for JavaScript style violations
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webpacker (6.0.0.beta.2)
4
+ webpacker (6.0.0.beta.3)
5
5
  activesupport (>= 5.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 5.2)
@@ -85,14 +85,16 @@ GEM
85
85
  method_source (1.0.0)
86
86
  mimemagic (0.3.5)
87
87
  mini_mime (1.0.2)
88
- mini_portile2 (2.4.0)
89
- minitest (5.14.1)
88
+ mini_portile2 (2.5.0)
89
+ minitest (5.14.3)
90
90
  nio4r (2.5.2)
91
- nokogiri (1.10.10)
92
- mini_portile2 (~> 2.4.0)
91
+ nokogiri (1.11.1)
92
+ mini_portile2 (~> 2.5.0)
93
+ racc (~> 1.4)
93
94
  parallel (1.19.2)
94
95
  parser (2.7.2.0)
95
96
  ast (~> 2.4.1)
97
+ racc (1.5.2)
96
98
  rack (2.2.3)
97
99
  rack-proxy (0.6.5)
98
100
  rack
data/README.md CHANGED
@@ -63,9 +63,9 @@ in which case you may not even need the asset pipeline. This is mostly relevant
63
63
 
64
64
  _requires extra packages to be installed_
65
65
 
66
- - Stylesheets - SASS, LESS and CSS, PostCSS
67
- - Coffeescript
68
- - Typescript
66
+ - Stylesheets - Sass, Less, Stylus and Css, PostCSS
67
+ - CoffeeScript
68
+ - TypeScript
69
69
  - React
70
70
 
71
71
  ## Installation
@@ -116,9 +116,9 @@ yarn install
116
116
  Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
117
117
 
118
118
  ```yml
119
- app/javascript:
120
- ├── packs:
121
- │ # only webpack entry files here
119
+ app/packs:
120
+ ├── entrypoints:
121
+ │ # Only webpack entry files here
122
122
  │ └── application.js
123
123
  │ └── application.css
124
124
  └── src:
@@ -136,16 +136,37 @@ You can then link the JavaScript pack in Rails views using the `javascript_packs
136
136
  <%= stylesheet_packs_with_chunks_tag 'application' %>
137
137
  ```
138
138
 
139
- If you want to link a static asset for `<link rel="prefetch">` or `<img />` tag, you
140
- can use the `asset_pack_path` helper:
141
-
139
+ If you want to link a static asset for `<img />` tag, you can use the `asset_pack_path` helper:
142
140
  ```erb
143
- <link rel="prefetch" href="<%= asset_pack_path 'application.css' %>" />
144
141
  <img src="<%= asset_pack_path 'images/logo.svg' %>" />
145
142
  ```
146
143
 
144
+ Or use the dedicated helper:
145
+ ```erb
146
+ <%= image_pack_tag 'application.png', size: '16x10', alt: 'Edit Entry' %>
147
+ <%= image_pack_tag 'picture.png', srcset: { 'picture-2x.png' => '2x' } %>
148
+ ```
149
+
150
+ If you want to create a favicon:
151
+ ```erb
152
+ <%= favicon_pack_tag 'mb-icon.png', rel: 'apple-touch-icon', type: 'image/png' %>
153
+ ```
154
+
155
+ If you want to preload a static asset in your `<head>`, you can use the `preload_pack_asset` helper:
156
+ ```erb
157
+ <%= preload_pack_asset 'fonts/fa-regular-400.woff2' %>
158
+ ```
159
+
160
+ If you want to use images in your stylesheets:
161
+
162
+ ```css
163
+ .foo {
164
+ background-image: url('../images/logo.svg')
165
+ }
166
+ ```
167
+
147
168
  **Note:** In order for your styles or static assets files to be available in your view,
148
- you would need to link them in your "pack" or entry file.
169
+ you would need to link them in your `pack` or entry file.
149
170
 
150
171
  ### Development
151
172
 
@@ -161,7 +182,7 @@ to the standard Rails log.
161
182
 
162
183
  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`. Windows users will need to run these commands
163
184
  in a terminal separate from `bundle exec rails s`. This process will watch for changes
164
- in the `app/javascript/packs/*.js` files and automatically reload the browser to match.
185
+ in the `app/packs/entrypoints/*.js` files and automatically reload the browser to match.
165
186
 
166
187
  ```bash
167
188
  # webpack dev server
@@ -212,7 +233,7 @@ WEBPACKER_DEV_SERVER_HOST=0.0.0.0 ./bin/webpack-dev-server
212
233
  Webpacker gives you a default set of configuration files for test, development and
213
234
  production environments in `config/webpack/*.js`. You can configure each individual
214
235
  environment in their respective files or configure them all in the base
215
- `config/webpack/environment.js` file.
236
+ `config/webpack/base.js` file.
216
237
 
217
238
  By default, you don't need to make any changes to `config/webpack/*.js`
218
239
  files since it's all standard production-ready configuration. However,
@@ -261,18 +282,18 @@ console.log(webpackConfig.source_path)
261
282
  ### Integrations
262
283
 
263
284
  Webpacker out of the box supports JS and static assets (fonts, images etc.)
264
- compilation. To enable support for Coffeescript or Typescript install
285
+ compilation. To enable support for CoffeeScript or TypeScript install
265
286
  relevant packages,
266
287
 
267
- **Coffeescript**
288
+ #### CoffeeScript
268
289
 
269
- ```
290
+ ```bash
270
291
  yarn add coffeescript coffee-loader
271
292
  ```
272
293
 
273
- **Typescript**
294
+ #### TypeScript
274
295
 
275
- ```
296
+ ```bash
276
297
  yarn add typescript @babel/preset-typescript
277
298
  ```
278
299
 
@@ -289,7 +310,7 @@ Add tsconfig.json
289
310
  "moduleResolution": "node",
290
311
  "baseUrl": ".",
291
312
  "paths": {
292
- "*": ["node_modules/*", "app/javascript/*"]
313
+ "*": ["node_modules/*", "app/packs/*"]
293
314
  },
294
315
  "sourceMap": true,
295
316
  "target": "es5",
@@ -304,7 +325,7 @@ Add tsconfig.json
304
325
 
305
326
  To enable CSS support in your application, add following packages,
306
327
 
307
- ```
328
+ ```bash
308
329
  yarn add css-loader mini-css-extract-plugin css-minimizer-webpack-plugin
309
330
  ```
310
331
 
@@ -327,25 +348,25 @@ then add the relevant pre-processors:
327
348
 
328
349
  #### Postcss
329
350
 
330
- ```
351
+ ```bash
331
352
  yarn add postcss-loader
332
353
  ```
333
354
 
334
355
  #### Sass
335
356
 
336
- ```
357
+ ```bash
337
358
  yarn add sass sass-loader
338
359
  ```
339
360
 
340
361
  #### Less
341
362
 
342
- ```
363
+ ```bash
343
364
  yarn add less less-loader
344
365
  ```
345
366
 
346
- #### Less
367
+ #### Stylus
347
368
 
348
- ```
369
+ ```bash
349
370
  yarn add stylus stylus-loader
350
371
  ```
351
372
 
@@ -353,7 +374,7 @@ yarn add stylus stylus-loader
353
374
 
354
375
  React is supported and you just need to add relevant packages,
355
376
 
356
- ```
377
+ ```bash
357
378
  yarn add react react-dom @babel/preset-react
358
379
  ```
359
380
 
@@ -382,12 +403,11 @@ if you are using typescript, update your `tsconfig.json`
382
403
 
383
404
  Please follow webpack integration guide for relevant framework or library,
384
405
 
385
- 1. Svelte - https://github.com/sveltejs/svelte-loader#install
386
- 2. Angular - https://v2.angular.io/docs/ts/latest/guide/webpack.html#!#configure-webpack
387
- 3. Vue - https://vue-loader.vuejs.org/guide/
388
-
389
- For example to add Vue support,
406
+ 1. [Svelte](https://github.com/sveltejs/svelte-loader#install)
407
+ 2. [Angular](https://v2.angular.io/docs/ts/latest/guide/webpack.html#!#configure-webpack)
408
+ 3. [Vue](https://vue-loader.vuejs.org/guide/)
390
409
 
410
+ For example to add Vue support:
391
411
  ```js
392
412
  // config/webpack/rules/vue.js
393
413
  const VueLoaderPlugin = require('vue-loader/lib/plugin')
@@ -403,7 +423,9 @@ module.exports = {
403
423
  },
404
424
  plugins: [new VueLoaderPlugin()]
405
425
  }
426
+ ```
406
427
 
428
+ ```js
407
429
  // config/webpack/base.js
408
430
  const { webpackConfig, merge } = require('@rails/webpacker')
409
431
  const vueConfig = require('./rules/vue')
@@ -481,13 +503,13 @@ app files and compiled webpack bundles will go in your Rails app.
481
503
  All these options are configurable from `config/webpacker.yml` file.
482
504
 
483
505
  The configuration for what webpack is supposed to compile by default rests
484
- on the convention that every file in `app/javascript/packs/*`**(default)**
506
+ on the convention that every file in `app/packs/entrypoints/*`**(default)**
485
507
  or whatever path you set for `source_entry_path` in the `webpacker.yml` configuration
486
508
  is turned into their own output files (or entry points, as webpack calls it). Therefore you don't want to put anything inside `packs` directory that you do not want to be
487
509
  an entry file. As a rule of thumb, put all files you want to link in your views inside
488
- "packs" directory and keep everything else under `app/javascript`.
510
+ "packs" directory and keep everything else under `app/packs`.
489
511
 
490
- Suppose you want to change the source directory from `app/javascript`
512
+ Suppose you want to change the source directory from `app/packs`
491
513
  to `frontend` and output to `assets/packs`. This is how you would do it:
492
514
 
493
515
  ```yml
@@ -0,0 +1,3 @@
1
+ # Note
2
+
3
+ This directory exists for Jest specs that execute code expecting the Rails config directory at this path.
@@ -0,0 +1 @@
1
+ config/lib/install/config/webpacker.yml
@@ -1,8 +1,8 @@
1
1
  # Note: You must restart bin/webpack-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
- source_path: app/javascript
5
- source_entry_path: packs
4
+ source_path: app/packs
5
+ source_entry_path: entrypoints
6
6
  public_root_path: public
7
7
  public_output_path: packs
8
8
  cache_path: tmp/cache/webpacker
@@ -25,6 +25,8 @@ development:
25
25
  host: localhost
26
26
  port: 3035
27
27
  public: localhost:3035
28
+ # Inject browserside javascript that required by both HMR and Live(full) reload
29
+ inject_client: true
28
30
  # Hot Module Replacement updates modules while the application is running without a full reload
29
31
  hmr: false
30
32
  # Inline should be set to true if using HMR; it inserts a script to take care of live reloading
@@ -1,7 +1,7 @@
1
1
  /* eslint no-console:0 */
2
2
  // This file is automatically compiled by Webpack, along with any other files
3
3
  // present in this directory. You're encouraged to place your actual application logic in
4
- // a relevant structure within app/javascript and only use these pack files to reference
4
+ // a relevant structure within app/packs and only use these pack files to reference
5
5
  // that code so it'll be compiled.
6
6
  //
7
7
  // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
@@ -64,7 +64,8 @@ class Webpacker::Commands
64
64
 
65
65
  def current_version
66
66
  packs = manifest.refresh.values.map do |value|
67
- next if value.is_a?(Hash)
67
+ value = value["src"] if value.is_a?(Hash)
68
+ next unless value.is_a?(String)
68
69
 
69
70
  File.join(config.root_path, "public", "#{value}*")
70
71
  end.compact
@@ -35,7 +35,7 @@ class Webpacker::Compiler
35
35
 
36
36
  # Returns true if all the compiled packs are up to date with the underlying asset files.
37
37
  def fresh?
38
- watched_files_digest == last_compilation_digest
38
+ last_compilation_digest&.== watched_files_digest
39
39
  end
40
40
 
41
41
  # Returns true if the compiled packs are out of date with the underlying asset files.
@@ -69,7 +69,7 @@ class Webpacker::Compiler
69
69
  bin_webpack_path = config.root_path.join("bin/webpack")
70
70
  first_line = File.readlines(bin_webpack_path).first.chomp
71
71
  /ruby/.match?(first_line) ? RbConfig.ruby : ""
72
- end
72
+ end
73
73
 
74
74
  def run_webpack
75
75
  logger.info "Compiling..."
@@ -64,6 +64,7 @@ module Webpacker
64
64
  def execute_cmd
65
65
  env = Webpacker::Compiler.env
66
66
  env["WEBPACKER_CONFIG"] = @webpacker_config
67
+ env["WEBPACK_DEV_SERVER"] = "true"
67
68
 
68
69
  cmd = if node_modules_bin_exist?
69
70
  ["#{@node_modules_bin_path}/webpack", "serve"]
@@ -73,6 +74,7 @@ module Webpacker
73
74
 
74
75
  if @argv.include?("--debug-webpacker")
75
76
  cmd = [ "node", "--inspect-brk"] + cmd
77
+ @argv.delete "--debug-webpacker"
76
78
  end
77
79
 
78
80
  cmd += ["--config", @webpack_config]
@@ -74,7 +74,7 @@ module Webpacker::Helper
74
74
 
75
75
  # Creates a script tag that references the named pack file, as compiled by webpack per the entries list
76
76
  # in package/environments/base.js. By default, this list is auto-generated to match everything in
77
- # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
77
+ # app/packs/entrypoints/*.js. In production mode, the digested reference is automatically looked up.
78
78
  #
79
79
  # Example:
80
80
  #
@@ -87,7 +87,7 @@ module Webpacker::Helper
87
87
  # Creates script tags that reference the js chunks from entrypoints when using split chunks API,
88
88
  # as compiled by webpack per the entries list in package/environments/base.js.
89
89
  # By default, this list is auto-generated to match everything in
90
- # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
90
+ # app/packs/entrypoints/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
91
91
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
92
92
  #
93
93
  # Example:
@@ -129,7 +129,7 @@ module Webpacker::Helper
129
129
 
130
130
  # Creates a link tag that references the named pack file, as compiled by webpack per the entries list
131
131
  # in package/environments/base.js. By default, this list is auto-generated to match everything in
132
- # app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
132
+ # app/packs/entrypoints/*.js. In production mode, the digested reference is automatically looked up.
133
133
  #
134
134
  # Note: If the development server is running and hot module replacement is active, this will return nothing.
135
135
  # In that setup you need to configure your styles to be inlined in your JavaScript for hot reloading.
@@ -145,7 +145,7 @@ module Webpacker::Helper
145
145
  # Creates link tags that reference the css chunks from entrypoints when using split chunks API,
146
146
  # as compiled by webpack per the entries list in package/environments/base.js.
147
147
  # By default, this list is auto-generated to match everything in
148
- # app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
148
+ # app/packs/entrypoints/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
149
149
  # See: https://webpack.js.org/plugins/split-chunks-plugin/
150
150
  #
151
151
  # Examples:
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "6.0.0.beta.2".freeze
3
+ VERSION = "6.0.0.beta.3".freeze
4
4
  end
@@ -15,6 +15,7 @@ module Webpacker
15
15
 
16
16
  if @argv.include?("--debug-webpacker")
17
17
  cmd = [ "node", "--inspect-brk"] + cmd
18
+ @argv.delete "--debug-webpacker"
18
19
  end
19
20
 
20
21
  if @argv.include?("--trace-deprecation")
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "6.0.0-beta.2",
3
+ "version": "6.0.0-beta.3",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -22,7 +22,8 @@ describe('Development environment', () => {
22
22
  expect(webpackConfig).toMatchObject({
23
23
  devServer: {
24
24
  host: 'localhost',
25
- port: 3035
25
+ port: 3035,
26
+ injectClient: true
26
27
  }
27
28
  })
28
29
  })
@@ -0,0 +1,9 @@
1
+ const index = require('../index')
2
+
3
+ describe('index', () => {
4
+ test('exports webpack-merge v5 functions', () => {
5
+ expect(index.merge).toBeInstanceOf(Function)
6
+ expect(index.mergeWithRules).toBeInstanceOf(Function)
7
+ expect(index.mergeWithCustomize).toBeInstanceOf(Function)
8
+ })
9
+ })
@@ -17,14 +17,14 @@ describe('Base config', () => {
17
17
  describe('config', () => {
18
18
  test('should return entry', () => {
19
19
  expect(baseConfig.entry.application).toEqual(
20
- resolve('app', 'javascript', 'packs', 'application.js')
20
+ resolve('app', 'packs', 'entrypoints', 'application.js')
21
21
  )
22
22
  })
23
23
 
24
24
  test('should return multi file entry points', () => {
25
25
  expect(baseConfig.entry.multi_entry.sort()).toEqual([
26
- resolve('app', 'javascript', 'packs', 'multi_entry.css'),
27
- resolve('app', 'javascript', 'packs', 'multi_entry.js')
26
+ resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
27
+ resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
28
28
  ])
29
29
  })
30
30
 
@@ -53,7 +53,7 @@ describe('Base config', () => {
53
53
 
54
54
  test('should return default resolve.modules with additions', () => {
55
55
  expect(baseConfig.resolve.modules).toEqual([
56
- resolve('app', 'javascript'),
56
+ resolve('app', 'packs'),
57
57
  resolve('app/assets'),
58
58
  resolve('/etc/yarn'),
59
59
  resolve('some.config.js'),
@@ -91,7 +91,7 @@ module.exports = {
91
91
  },
92
92
  entry: getEntryObject(),
93
93
  resolve: {
94
- extensions: ['.js', '.mjs', '.ts', '.coffee'],
94
+ extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.coffee'],
95
95
  modules: getModulePaths(),
96
96
  plugins: [PnpWebpackPlugin]
97
97
  },
@@ -34,6 +34,7 @@ if (
34
34
  hot: devServer.hmr,
35
35
  contentBase,
36
36
  inline: devServer.inline,
37
+ injectClient: devServer.inject_client,
37
38
  useLocalIp: devServer.use_local_ip,
38
39
  public: devServer.public,
39
40
  publicPath,
@@ -1,7 +1,7 @@
1
1
  /* eslint global-require: 0 */
2
2
  /* eslint import/no-dynamic-require: 0 */
3
3
 
4
- const { merge } = require('webpack-merge')
4
+ const webpackMerge = require('webpack-merge')
5
5
  const { resolve } = require('path')
6
6
  const { existsSync } = require('fs')
7
7
  const baseConfig = require('./environments/base')
@@ -23,7 +23,7 @@ module.exports = {
23
23
  webpackConfig: webpackConfig(),
24
24
  baseConfig,
25
25
  rules,
26
- merge,
27
26
  moduleExists,
28
- canProcess
27
+ canProcess,
28
+ ...webpackMerge
29
29
  }
@@ -10,12 +10,12 @@ class ConfigurationTest < Webpacker::Test
10
10
  end
11
11
 
12
12
  def test_source_path
13
- source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript").to_s
13
+ source_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs").to_s
14
14
  assert_equal source_path, @config.source_path.to_s
15
15
  end
16
16
 
17
17
  def test_source_entry_path
18
- source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/javascript", "packs").to_s
18
+ source_entry_path = File.expand_path File.join(File.dirname(__FILE__), "test_app/app/packs", "entrypoints").to_s
19
19
  assert_equal @config.source_entry_path.to_s, source_entry_path
20
20
  end
21
21
 
@@ -43,19 +43,27 @@ class DevServerRunnerTest < Webpacker::Test
43
43
  end
44
44
  end
45
45
 
46
+ def test_environment_variables
47
+ cmd = ["#{test_app_path}/node_modules/.bin/webpack", "serve", "--config", "#{test_app_path}/config/webpack/development.js"]
48
+ env = Webpacker::Compiler.env.dup
49
+ env["WEBPACKER_CONFIG"] = "#{test_app_path}/config/webpacker.yml"
50
+ env["WEBPACK_DEV_SERVER"] = "true"
51
+ verify_command(cmd, env: env)
52
+ end
53
+
46
54
  private
47
55
  def test_app_path
48
56
  File.expand_path("test_app", __dir__)
49
57
  end
50
58
 
51
- def verify_command(cmd, use_node_modules: true, argv: [])
59
+ def verify_command(cmd, use_node_modules: true, argv: [], env: Webpacker::Compiler.env)
52
60
  cwd = Dir.pwd
53
61
  Dir.chdir(test_app_path)
54
62
 
55
63
  klass = Webpacker::DevServerRunner
56
64
  instance = klass.new(argv)
57
65
  mock = Minitest::Mock.new
58
- mock.expect(:call, nil, [Webpacker::Compiler.env, *cmd])
66
+ mock.expect(:call, nil, [env, *cmd])
59
67
 
60
68
  klass.stub(:new, instance) do
61
69
  instance.stub(:node_modules_bin_exist?, use_node_modules) do
@@ -1,8 +1,8 @@
1
1
  # Note: You must restart bin/webpack-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
- source_path: app/javascript
5
- source_entry_path: packs
4
+ source_path: app/packs
5
+ source_entry_path: entrypoints
6
6
  public_output_path: packs
7
7
  cache_path: tmp/cache/webpacker
8
8
 
@@ -1,7 +1,7 @@
1
1
  /* eslint no-console:0 */
2
2
  // This file is automatically compiled by Webpack, along with any other files
3
3
  // present in this directory. You're encouraged to place your actual application logic in
4
- // a relevant structure within app/javascript and only use these pack files to reference
4
+ // a relevant structure within app/packs and only use these pack files to reference
5
5
  // that code so it'll be compiled.
6
6
  //
7
7
  // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
@@ -1,8 +1,8 @@
1
1
  # Note: You must restart bin/webpack-dev-server for changes to take effect
2
2
 
3
3
  default: &default
4
- source_path: app/javascript
5
- source_entry_path: packs
4
+ source_path: app/packs
5
+ source_entry_path: entrypoints
6
6
  public_root_path: public
7
7
  public_output_path: packs
8
8
  cache_path: tmp/cache/webpacker
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.2
4
+ version: 6.0.0.beta.3
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: 2020-12-24 00:00:00.000000000 Z
12
+ date: 2021-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -134,6 +134,8 @@ files:
134
134
  - MIT-LICENSE
135
135
  - README.md
136
136
  - Rakefile
137
+ - config/README.md
138
+ - config/webpacker.yml
137
139
  - gemfiles/Gemfile-rails-edge
138
140
  - gemfiles/Gemfile-rails.5.2.x
139
141
  - gemfiles/Gemfile-rails.6.0.x
@@ -145,7 +147,6 @@ files:
145
147
  - lib/install/config/webpack/production.js
146
148
  - lib/install/config/webpack/test.js
147
149
  - lib/install/config/webpacker.yml
148
- - lib/install/javascript/packs/application.css
149
150
  - lib/install/javascript/packs/application.js
150
151
  - lib/install/template.rb
151
152
  - lib/tasks/webpacker.rake
@@ -180,6 +181,7 @@ files:
180
181
  - package/__tests__/dev_server.js
181
182
  - package/__tests__/development.js
182
183
  - package/__tests__/env.js
184
+ - package/__tests__/index.js
183
185
  - package/__tests__/production.js
184
186
  - package/__tests__/staging.js
185
187
  - package/__tests__/test.js
@@ -226,9 +228,9 @@ files:
226
228
  - test/mounted_app/test/dummy/package.json
227
229
  - test/rake_tasks_test.rb
228
230
  - test/test_app/Rakefile
229
- - test/test_app/app/javascript/packs/application.js
230
- - test/test_app/app/javascript/packs/multi_entry.css
231
- - test/test_app/app/javascript/packs/multi_entry.js
231
+ - test/test_app/app/packs/entrypoints/application.js
232
+ - test/test_app/app/packs/entrypoints/multi_entry.css
233
+ - test/test_app/app/packs/entrypoints/multi_entry.js
232
234
  - test/test_app/bin/webpack
233
235
  - test/test_app/bin/webpack-dev-server
234
236
  - test/test_app/config.ru
@@ -250,8 +252,8 @@ homepage: https://github.com/rails/webpacker
250
252
  licenses:
251
253
  - MIT
252
254
  metadata:
253
- source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.2
254
- changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.2/CHANGELOG.md
255
+ source_code_uri: https://github.com/rails/webpacker/tree/v6.0.0.beta.3
256
+ changelog_uri: https://github.com/rails/webpacker/blob/v6.0.0.beta.3/CHANGELOG.md
255
257
  post_install_message:
256
258
  rdoc_options: []
257
259
  require_paths:
@@ -292,9 +294,9 @@ test_files:
292
294
  - test/mounted_app/test/dummy/package.json
293
295
  - test/rake_tasks_test.rb
294
296
  - test/test_app/Rakefile
295
- - test/test_app/app/javascript/packs/application.js
296
- - test/test_app/app/javascript/packs/multi_entry.css
297
- - test/test_app/app/javascript/packs/multi_entry.js
297
+ - test/test_app/app/packs/entrypoints/application.js
298
+ - test/test_app/app/packs/entrypoints/multi_entry.css
299
+ - test/test_app/app/packs/entrypoints/multi_entry.js
298
300
  - test/test_app/bin/webpack
299
301
  - test/test_app/bin/webpack-dev-server
300
302
  - test/test_app/config.ru
@@ -1,9 +0,0 @@
1
- /*
2
- Any CSS added to this file or imported from this file, e.g. `@import '../stylesheets/my-css.css'`,
3
- will be included in the "application" pack. Any CSS imported from application.js or as part of the
4
- application.js dependency graph, e.g. `import '../stylesheets/my-css.css'` will also be included
5
- in the "application" pack.
6
-
7
- To reference this file, add <%= stylesheet_pack_tag 'application' %> to the appropriate
8
- layout file, like app/views/layouts/application.html.erb
9
- */