webpacker 4.0.0.rc.5 → 4.0.0.rc.6

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: ee04d7f5b912e098d9fc2a7916a40a91bfacc978f8a9882e09caa0f3f34b3c4a
4
- data.tar.gz: db1260bcf5cff15d865242d590a26dfbd0cae132d9884877e9f07256d680fa06
3
+ metadata.gz: 3a8f0d941f2281fcab2e44fe0df01aebf7935d9db226b54c21064babf12ec777
4
+ data.tar.gz: b23475b4ab4655925d13f3653b9d11ec36616794da095e51df71eaf8a9f5b9eb
5
5
  SHA512:
6
- metadata.gz: 0217edc000e62da86721ae4701ce4e3ce1606d7284395efc683375218ae50cd75bc86c3b401e3919aad5fc3d2e2bef322ac43862a5365c43913b3eb5d5628154
7
- data.tar.gz: e50577f9329c987630a9dc9e93a90952cad885caa3c744c7477b446524284e319430f508ce0cef6230fe5d488708df9b2da0cc6a68b985f0fc3dc5c072098d5b
6
+ metadata.gz: 14ad964b9007b208377b7284ba10382dab00782d043e530cf469928c5d5e41e730d8326c7146193bd0fcd4a84069eeede3202e5b87ccae86023fb1dc7ad923ae
7
+ data.tar.gz: 725755c1983b0a40485a278973ebe2bab58a5346a9fa8ab1d5d413a86a34939f8baf11ee2ff102f2e5a738ebc0a7b8e0deef71295ed61335255f64971a1240da
data/CHANGELOG.md CHANGED
@@ -1,8 +1,34 @@
1
1
  **Please note that Webpacker 3.1.0 and 3.1.1 have some serious bugs so please consider using either 3.0.2 or 3.2.0**
2
2
 
3
+ ## [4.0.0.rc.6] - 2019-01-25
4
+
5
+ ### Fixed
6
+
7
+ - Remove `context` from file loader in favour of simpler paths
8
+
9
+ ```rb
10
+ # before
11
+ "_/assets/images/avatar.png": "/packs/_/assets/images/avatar-057862c747f0fdbeae506bdd0516cad1.png"
12
+
13
+ # after
14
+ "media/avatar.png": "/packs/media/avatar-057862c747f0fdbeae506bdd0516cad1.png"
15
+ ```
16
+
17
+ ### Added
18
+
19
+ - Namespaces for compiled packs in the public directory
20
+
21
+ ```rb
22
+ # before
23
+ "runtime~hello_react" => "/packs/runtime~hello_react-da2baf7fd07b0e8b6d17.js"
24
+
25
+ # after
26
+ "runtime~hello_react" => "/packs/js/runtime~hello_react-da2baf7fd07b0e8b6d17.js"
27
+ ```
28
+
3
29
  ## [4.0.0.rc.5] - 2019-01-21
4
30
 
5
- ### Updated
31
+ ### Updated
6
32
 
7
33
  - Gems and node dependencies
8
34
 
@@ -28,7 +54,7 @@ helper otherwise you will get duplicated chunks on the page.
28
54
  <%# DO %>
29
55
  # <%= stylesheet_packs_with_chunks_tag 'calendar', 'map' %>
30
56
  <%# DON'T %>
31
- # <%= stylesheet_packs_with_chunks_tag 'calendar' %>
57
+ # <%= stylesheet_packs_with_chunks_tag 'calendar' %>
32
58
  # <%= stylesheet_packs_with_chunks_tag 'map' %>
33
59
  ```
34
60
 
@@ -438,7 +464,7 @@ without sprockets
438
464
  - Allow dev server connect timeout (in seconds) to be configurable, default: 0.01
439
465
 
440
466
  ```rb
441
- # Change to 1s
467
+ # Change to 1s
442
468
  Webpacker.dev_server.connect_timeout = 1
443
469
  ```
444
470
 
data/Gemfile.lock CHANGED
@@ -14,7 +14,7 @@ GIT
14
14
  PATH
15
15
  remote: .
16
16
  specs:
17
- webpacker (4.0.0.rc.5)
17
+ webpacker (4.0.0.rc.6)
18
18
  activesupport (>= 4.2)
19
19
  rack-proxy (>= 0.6.1)
20
20
  railties (>= 4.2)
data/docs/deployment.md CHANGED
@@ -72,3 +72,14 @@ server {
72
72
 
73
73
  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
74
74
  you don't need to do anything extra for Webpacker, it just works.
75
+
76
+ ## Capistrano
77
+
78
+ ### Assets compiling on every deployment even if JavaScript and CSS files are not changed
79
+
80
+ Make sure you have `public/packs` and `node_modules` in `:linked_dirs`
81
+
82
+ ```ruby
83
+ append :linked_dirs, "log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/packs", ".bundle", "node_modules"
84
+ ```
85
+
@@ -0,0 +1,94 @@
1
+ To update a Webpacker v3.5 app to v4, follow these steps:
2
+
3
+ 1. Update the `webpacker` gem and the `@rails/webpacker` package to v4. This will upgrade webpack itself from 3.x to 4.x, make sure you're aware of [any deprecations which might effect you](https://webpack.js.org/migrate/4/). Also make sure any other packages you depend on support webpack 4 and don't require any changes, e.g. if you explicitly include `webpack` you need to upgrade it to 4.x, and if you use `webpack-dev-server` you need to upgrade it to 3.x.
4
+ 1. Browser support definitions have been moved to [`.browserslistrc`](../lib/install/config/.browserslistrc) to `/`.
5
+ 1. Merge any differences between [`config/webpacker.yml`](../lib/install/config/webpacker.yml) and your `config/webpacker.yml`.
6
+ 1. Webpacker v4 upgrades Babel to [v7](https://babeljs.io/docs/en/v7-migration), see also [the release blog post](https://babeljs.io/blog/2018/08/27/7.0.0). Many packages were moved to the `@babel/` namespace, any babel plugins you have will need to be updated. It may be worth checking out [babel-upgrade](https://github.com/babel/babel-upgrade) if you have problems. ([#1564](https://github.com/rails/webpacker/pull/1564))
7
+ 1. `.babelrc` should be replaced with `babel.config.js` and `.postcssrc.yml` should be replaced with `postcss.config.js` ([#1822](https://github.com/rails/webpacker/pull/1822)). If you never changed these files from their defaults, the versions of [babel.config.js](../lib/install/config/babel.config.js) and [postcss.config.js](../lib/install/config/postcss.config.js) in the webpacker repository should be usable.
8
+ 1. Due to the change in [#1625](https://github.com/rails/webpacker/pull/1625), you'll want to make sure that `extract_css` is set to true for the `default` environment in `webpacker.yml` if you want to have Webpacker supply your CSS.
9
+
10
+ ### Add SplitChunks
11
+
12
+ If you used the `CommonsChunkPlugin` you'll need to upgrade to using the new `splitChunks`.
13
+
14
+ Originally, chunks (and modules imported inside them) were connected by a parent-child relationship in the internal webpack graph. The `CommonsChunkPlugin` was used to avoid duplicated dependencies across them, but further optimizations were not possible.
15
+
16
+ In webpack v4, `CommonsChunkPlugin` was removed in favor of `optimization.splitChunks`.
17
+
18
+ For the full configuration options of `splitChunks`, see the [Webpack documentation](https://webpack.js.org/plugins/split-chunks-plugin/).
19
+
20
+ ```js
21
+ // config/webpack/environment.js
22
+ const WebpackAssetsManifest = require('webpack-assets-manifest');
23
+
24
+ // Enable the default config
25
+ environment.splitChunks()
26
+
27
+ // or using custom config
28
+ environment.splitChunks((config) => Object.assign({}, config, { optimization: { splitChunks: false }}))
29
+ ```
30
+
31
+ Then use, `javascript_packs_with_chunks_tag` helper to include all the transpiled
32
+ packs with the chunks in your view, which creates html tags for all the chunks.
33
+
34
+ ```erb
35
+ <%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %>
36
+
37
+ <!-- would create the following: -->
38
+ <script src="/packs/vendor-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
39
+ <script src="/packs/calendar~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
40
+ <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
41
+ <script src="/packs/map~runtime-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
42
+ <script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload"></script>
43
+ ```
44
+
45
+ **Important:** Pass all your pack names when using this helper otherwise you will
46
+ get duplicated chunks on the page.
47
+
48
+ ```erb
49
+ <%# DO %>
50
+ <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
51
+
52
+ <%# DON'T %>
53
+ <%= javascript_packs_with_chunks_tag 'calendar' %>
54
+ <%= javascript_packs_with_chunks_tag 'map' %>
55
+ ```
56
+
57
+ ### Package-specific notes:
58
+
59
+ - If you're using React, you need to add `"@babel/preset-react"`, to the list of `presets` in your babel config.
60
+ - If you're using Vue Loader, you'll need to upgrade to [v15](https://vue-loader.vuejs.org/migrating.html) for webpack 4.
61
+ - To see what webpacker generates for a given framework with v4, you may want to re-run `bundle exec rake webpacker:install:FRAMEWORK` and let it override the files for your given JavaScript framework, and then compare them to see what changes you'll need to make.
62
+
63
+ ### Excluding node_modules from being transpiled by babel-loader
64
+
65
+ One change to take into consideration, is that Webpacker 4 transpiles the
66
+ `node_modules` folder with the `babel-loader`. This folder used to be ignored by
67
+ webpacker 3. The new behavior helps in case some library contains ES6 code, but in
68
+ some cases it can lead to issues. To avoid running `babel-loader` in the
69
+ `node_modules` folder, replicating the same behavior as Webpacker 3, the
70
+ following code can be added to `config/webpack/environment.js`:
71
+
72
+ ```javascript
73
+ environment.loaders.delete('nodeModules')
74
+ ```
75
+
76
+ Alternatively, in order to skip only a specific library in the `node_modules`
77
+ folder, this code can be added:
78
+
79
+ ```javascript
80
+ const nodeModulesLoader = environment.loaders.get('nodeModules')
81
+ if (!Array.isArray(nodeModulesLoader.exclude)) {
82
+ nodeModulesLoader.exclude = (nodeModulesLoader.exclude == null)
83
+ ? []
84
+ : [nodeModulesLoader.exclude]
85
+ }
86
+ nodeModulesLoader.exclude.push(/some-library/) // replace `some-library` with
87
+ // the actual path to exclude
88
+ ```
89
+
90
+ ### Example upgrades
91
+
92
+ This is what an upgrade to Webpacker 4 looked like for existing Rails apps (please contribute yours!):
93
+
94
+ - https://github.com/connorshea/ContinueFromCheckpoint/pull/77
data/lib/install/vue.rb CHANGED
@@ -14,7 +14,7 @@ insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
14
14
 
15
15
  say "Adding vue loader to config/webpack/environment.js"
16
16
  insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
17
- "const vue = require('./loaders/vue')\n",
17
+ "const vue = require('./loaders/vue')\n",
18
18
  after: "require('vue-loader')\n"
19
19
 
20
20
  insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "4.0.0.rc.5".freeze
3
+ VERSION = "4.0.0.rc.6".freeze
4
4
  end
@@ -31,8 +31,8 @@ describe('Environment', () => {
31
31
 
32
32
  test('should return output', () => {
33
33
  const config = environment.toWebpackConfig()
34
- expect(config.output.filename).toEqual('[name]-[chunkhash].js')
35
- expect(config.output.chunkFilename).toEqual('[name]-[chunkhash].chunk.js')
34
+ expect(config.output.filename).toEqual('js/[name]-[chunkhash].js')
35
+ expect(config.output.chunkFilename).toEqual('js/[name]-[chunkhash].chunk.js')
36
36
  })
37
37
 
38
38
  test('should return default loader rules for each file in config/loaders', () => {
@@ -36,8 +36,8 @@ const getPluginList = () => {
36
36
  result.append(
37
37
  'MiniCssExtract',
38
38
  new MiniCssExtractPlugin({
39
- filename: '[name]-[contenthash:8].css',
40
- chunkFilename: '[name]-[contenthash:8].chunk.css'
39
+ filename: 'css/[name]-[contenthash:8].css',
40
+ chunkFilename: 'css/[name]-[contenthash:8].chunk.css'
41
41
  })
42
42
  )
43
43
  result.append(
@@ -83,9 +83,9 @@ const getModulePaths = () => {
83
83
  const getBaseConfig = () => new ConfigObject({
84
84
  mode: 'production',
85
85
  output: {
86
- filename: '[name]-[chunkhash].js',
87
- chunkFilename: '[name]-[chunkhash].chunk.js',
88
- hotUpdateChunkFilename: '[id]-[hash].hot-update.js',
86
+ filename: 'js/[name]-[chunkhash].js',
87
+ chunkFilename: 'js/[name]-[chunkhash].chunk.js',
88
+ hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
89
89
  path: config.outputPath,
90
90
  publicPath: config.publicPath
91
91
  },
@@ -1,5 +1,4 @@
1
- const { join } = require('path')
2
- const { source_path: sourcePath, static_assets_extensions: fileExtensions } = require('../config')
1
+ const { static_assets_extensions: fileExtensions } = require('../config')
3
2
 
4
3
  module.exports = {
5
4
  test: new RegExp(`(${fileExtensions.join('|')})$`, 'i'),
@@ -7,8 +6,7 @@ module.exports = {
7
6
  {
8
7
  loader: 'file-loader',
9
8
  options: {
10
- name: '[path][name]-[hash].[ext]',
11
- context: join(sourcePath)
9
+ name: 'media/[name]-[hash:8].[ext]'
12
10
  }
13
11
  }
14
12
  ]
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rails/webpacker",
3
- "version": "4.0.0-rc.5",
3
+ "version": "4.0.0-rc.6",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
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: 4.0.0.rc.5
4
+ version: 4.0.0.rc.6
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: 2019-01-21 00:00:00.000000000 Z
12
+ date: 2019-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -102,6 +102,7 @@ files:
102
102
  - docs/testing.md
103
103
  - docs/troubleshooting.md
104
104
  - docs/typescript.md
105
+ - docs/v4-upgrade.md
105
106
  - docs/webpack-dev-server.md
106
107
  - docs/webpack.md
107
108
  - docs/yarn.md
@@ -252,8 +253,8 @@ homepage: https://github.com/rails/webpacker
252
253
  licenses:
253
254
  - MIT
254
255
  metadata:
255
- source_code_uri: https://github.com/rails/webpacker/tree/v4.0.0.rc.5
256
- changelog_uri: https://github.com/rails/webpacker/blob/v4.0.0.rc.5/CHANGELOG.md
256
+ source_code_uri: https://github.com/rails/webpacker/tree/v4.0.0.rc.6
257
+ changelog_uri: https://github.com/rails/webpacker/blob/v4.0.0.rc.6/CHANGELOG.md
257
258
  post_install_message:
258
259
  rdoc_options: []
259
260
  require_paths: