webpacker 4.0.0.rc.5 → 4.0.0.rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -3
- data/Gemfile.lock +1 -1
- data/docs/deployment.md +11 -0
- data/docs/v4-upgrade.md +94 -0
- data/lib/install/vue.rb +1 -1
- data/lib/webpacker/version.rb +1 -1
- data/package/environments/__tests__/base.js +2 -2
- data/package/environments/base.js +5 -5
- data/package/rules/file.js +2 -4
- data/package.json +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a8f0d941f2281fcab2e44fe0df01aebf7935d9db226b54c21064babf12ec777
|
4
|
+
data.tar.gz: b23475b4ab4655925d13f3653b9d11ec36616794da095e51df71eaf8a9f5b9eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
###
|
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
|
-
#
|
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
|
-
#
|
467
|
+
# Change to 1s
|
442
468
|
Webpacker.dev_server.connect_timeout = 1
|
443
469
|
```
|
444
470
|
|
data/Gemfile.lock
CHANGED
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
|
+
|
data/docs/v4-upgrade.md
ADDED
@@ -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 =
|
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,
|
data/lib/webpacker/version.rb
CHANGED
@@ -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
|
},
|
data/package/rules/file.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
const {
|
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: '[
|
11
|
-
context: join(sourcePath)
|
9
|
+
name: 'media/[name]-[hash:8].[ext]'
|
12
10
|
}
|
13
11
|
}
|
14
12
|
]
|
data/package.json
CHANGED
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.
|
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-
|
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.
|
256
|
-
changelog_uri: https://github.com/rails/webpacker/blob/v4.0.0.rc.
|
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:
|