shakapacker 6.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -5
- data/README.md +54 -50
- data/docs/v6_upgrade.md +1 -1
- data/lib/webpacker/version.rb +1 -1
- data/package.json +1 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ecb405340a0fa5b44d13390860eaccbaf8ec55524e1e7ce56189274abbd400c
|
4
|
+
data.tar.gz: '0288c90b0b9675d165aad967b0c9ae7d9b4af2a59d788f1dde34434db0e37c36'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccd9911ec6c1a53ddc173bb86d5d87e714c174c41a28c4d6211544c25b2e39a7b72c85ed19cd7306ec7bcdeece73435071a86c1ae905fb2a8f995a0da8650b78
|
7
|
+
data.tar.gz: db5eff828636edf6a341c1aa2e0f89a6e58e7a476da0b908d38fbabe5b967b7dd1cee5a7fca6771fc5bc0dfc544ddcd64dc5e0fc72765b1f9f0116614c159bbf
|
data/CHANGELOG.md
CHANGED
@@ -6,14 +6,17 @@
|
|
6
6
|
Changes since last non-beta release.
|
7
7
|
|
8
8
|
*Please add entries here for your pull requests that are not yet released.*
|
9
|
-
## [v6.0.
|
9
|
+
## [v6.0.1] - January 24, 2022
|
10
|
+
### Improved
|
11
|
+
- PR #21 removed pnp-webpack-plugin as a dev dependency but did not remove it from the peer dependency list. [PR 30](https://github.com/shakacode/shakapacker/pull/19) by [t27duck](https://github.com/t27duck].
|
12
|
+
|
13
|
+
## [v6.0.0 changes from v6.0.0.rc.6] - January 22, 2022
|
10
14
|
|
11
15
|
### Improved
|
12
16
|
- Raise on multiple invocations of javascript_pack_tag and stylesheet_pack_tag helpers. [PR 19](https://github.com/shakacode/shakapacker/pull/19) by [tomdracz](https://github.com/tomdracz].
|
13
17
|
- Remove automatic addition of node_modules into rails asset load path. [PR 20](https://github.com/shakacode/shakapacker/pull/20) by [tomdracz](https://github.com/tomdracz].
|
14
18
|
- Remove pnp-webpack-plugin. [PR 21](https://github.com/shakacode/shakapacker/pull/21) by [tomdracz](https://github.com/tomdracz].
|
15
19
|
|
16
|
-
## [v6.0.0.rc.13 changes from v6.0.0.rc.6]
|
17
20
|
|
18
21
|
### Merged from rails/webpacker
|
19
22
|
|
@@ -52,7 +55,7 @@ Changes since last non-beta release.
|
|
52
55
|
- CSS extraction enabled by default, except when devServer is configured and running
|
53
56
|
|
54
57
|
|
55
|
-
[Unreleased]: https://github.com/shakacode/shakapacker/compare/6.0.
|
56
|
-
[v6.0.
|
57
|
-
[v6.0.0
|
58
|
+
[Unreleased]: https://github.com/shakacode/shakapacker/compare/6.0.1...master
|
59
|
+
[v6.0.1]: https://github.com/shakacode/shakapacker/compare/v6.0.0...v6.0.1
|
60
|
+
[v6.0.0 changes from v6.0.0.rc.6]: https://github.com/shakacode/shakapacker/compare/aba79635e6ff6562ec04d3c446d57ef19a5fef7d...v6.0.0
|
58
61
|
[v6.0.0.rc.6 changes from v5.4]: https://github.com/rails/webpacker/compare/v5.4.3...aba79635e6ff6562ec04d3c446d57ef19a5fef7d
|
data/README.md
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
# Shakapacker
|
2
2
|
|
3
|
-
_Official, actively maintained fork of [rails/webpacker](https://github.com/rails/webpacker).
|
4
|
-
|
5
|
-
* Note, internal naming will continue to use `webpacker` where possible.
|
6
|
-
* See [V6 Upgrade](./docs/v6_upgrade.md) for upgrading from v5 or prior v6 releases. See this [PR from v6.0.0.rc.6 to shakapacker](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/pull/27).
|
7
|
-
* [Slack discussion channel](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
8
|
-
|
3
|
+
_Official, actively maintained fork of [rails/webpacker](https://github.com/rails/webpacker). Internal naming for `shakapacker` will continue to use `webpacker` where possible. Notably, the NPM package name is `shakapacker`._
|
4
|
+
* See [V6 Upgrade](./docs/v6_upgrade.md) for upgrading from v5 or prior v6 releases.
|
9
5
|
|
10
6
|
[![Ruby specs](https://github.com/shakacode/shakapacker/workflows/Ruby%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
|
11
7
|
[![Jest specs](https://github.com/shakacode/shakapacker/workflows/Jest%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
|
@@ -14,6 +10,7 @@ _Official, actively maintained fork of [rails/webpacker](https://github.com/rail
|
|
14
10
|
|
15
11
|
[![node.js](https://img.shields.io/badge/node-%3E%3D%2012.0.0-brightgreen.svg)](https://www.npmjs.com/package/shakapacker)
|
16
12
|
[![Gem](https://img.shields.io/gem/v/shakapacker.svg)](https://rubygems.org/gems/shakapacker)
|
13
|
+
[![npm version](https://badge.fury.io/js/shakapacker.svg)](https://badge.fury.io/js/shakapacker)
|
17
14
|
|
18
15
|
Webpacker makes it easy to use the JavaScript pre-processor and bundler
|
19
16
|
[Webpack v5](https://webpack.js.org/)
|
@@ -40,8 +37,9 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
|
|
40
37
|
- [Manual Installation Steps](#manual-installation-steps)
|
41
38
|
- [Note for Sprockets usage](#note-for-sprockets-usage)
|
42
39
|
- [Usage](#usage)
|
43
|
-
|
44
|
-
|
40
|
+
- [View Helpers](#view-helpers)
|
41
|
+
- [Defer for `javascript_pack_tag`](#defer-for-javascript_pack_tag)
|
42
|
+
- [Server-Side Rendering (SSR)](#server-side-rendering-ssr)
|
45
43
|
- [Development](#development)
|
46
44
|
- [Webpack Configuration](#webpack-configuration)
|
47
45
|
- [Babel configuration](#babel-configuration)
|
@@ -58,7 +56,7 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
|
|
58
56
|
- [Other frameworks](#other-frameworks)
|
59
57
|
- [Custom Rails environments](#custom-rails-environments)
|
60
58
|
- [Upgrading](#upgrading)
|
61
|
-
- [Paths](#paths)
|
59
|
+
- [Paths](#paths)
|
62
60
|
- [Additional paths](#additional-paths)
|
63
61
|
- [Deployment](#deployment)
|
64
62
|
- [Example Apps](#example-apps)
|
@@ -76,57 +74,40 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
|
|
76
74
|
- Yarn
|
77
75
|
|
78
76
|
## Features
|
79
|
-
|
77
|
+
- Rails view helpers that fully support webpack output
|
78
|
+
- Convenient but not required webpack configuration. The only requirement is that your webpack configuration create a manifest.
|
79
|
+
- HMR with the webpack-dev-server, such as for hot-reloading for React!
|
80
|
+
- Automatic code splitting using multiple entry points to optimize JavaScript downloads
|
80
81
|
- [Webpack v5](https://webpack.js.org/)
|
81
82
|
- ES6 with [babel](https://babeljs.io/)
|
82
|
-
- Automatic code splitting using multiple entry points
|
83
83
|
- Asset compression, source-maps, and minification
|
84
84
|
- CDN support
|
85
|
-
-
|
86
|
-
- Extensible and configurable
|
85
|
+
- Extensible and configurable. For example, all major dependencies are specified as peers, so you can upgrade easily.
|
87
86
|
|
88
87
|
### Optional support
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
- TypeScript
|
95
|
-
- React
|
88
|
+
_Requires extra packages to be installed._
|
89
|
+
- React
|
90
|
+
- TypeScript
|
91
|
+
- Stylesheets - Sass, Less, Stylus and Css, PostCSS
|
92
|
+
- CoffeeScript
|
96
93
|
|
97
94
|
## Installation
|
98
95
|
|
99
|
-
### Rails v6
|
100
|
-
With Rails v6, [rails/webpacker v5](https://github.com/rails/webpacker/tree/5-x-stable) is installed by default:
|
101
|
-
```bash
|
102
|
-
rails new myapp
|
103
|
-
```
|
104
96
|
|
105
|
-
|
106
|
-
|
107
|
-
Alternatively, you can skip the default webpacker installation and then follow the [Manual Installation Steps](#manual-installation-steps) below.
|
97
|
+
### Rails v6+
|
108
98
|
|
99
|
+
With Rails v6+, skip JavaScript for a new app and follow below Manual Installation Steps to manually add the `shakapacker` gem to your Gemfile.
|
109
100
|
```bash
|
110
101
|
rails new myapp --skip-javascript
|
111
102
|
```
|
112
103
|
|
113
|
-
|
114
|
-
|
115
|
-
With Rails v7, skip JavaScript for a new app and follow below Manual Installation Steps to manually add the `shakapacker` gem to your Gemfile.
|
116
|
-
```bash
|
117
|
-
rails new myapp --skip-javascript
|
118
|
-
```
|
104
|
+
_Note, Rails 6 installs the older v5 version of webpacker unless you specify `--skip-javascript`._
|
119
105
|
|
120
|
-
### Manual Installation Steps
|
121
106
|
Update your `Gemfile`:
|
122
107
|
|
123
108
|
```ruby
|
124
109
|
# Gemfile
|
125
110
|
gem 'shakapacker', '~> 6.0'
|
126
|
-
|
127
|
-
# OR if you prefer to use master
|
128
|
-
gem 'shakapacker', git: 'https://github.com/shakacode/shakapacker.git'
|
129
|
-
yarn add https://github.com/shakacode/shakapacker.git
|
130
111
|
```
|
131
112
|
|
132
113
|
Then running the following to install Webpacker:
|
@@ -164,6 +145,8 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
|
|
164
145
|
|
165
146
|
## Usage
|
166
147
|
|
148
|
+
### View Helpers
|
149
|
+
|
167
150
|
Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
|
168
151
|
|
169
152
|
```yml
|
@@ -201,7 +184,7 @@ The result looks like this:
|
|
201
184
|
<script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload" defer></script>
|
202
185
|
```
|
203
186
|
|
204
|
-
**Important:** Pass all your pack names as multiple arguments, not multiple calls, when using `javascript_pack_tag` and the
|
187
|
+
**Important:** Pass all your pack names as multiple arguments, not multiple calls, when using `javascript_pack_tag` and the `stylesheet_pack_tag`. Otherwise, you will get duplicated chunks on the page. Be especially careful if you might be calling these view helpers from your view, partials, and the layout for a page. You will need some logic to ensure you call the helpers only once with multiple arguments.
|
205
188
|
|
206
189
|
```erb
|
207
190
|
<%# DO %>
|
@@ -243,10 +226,10 @@ If you want to use images in your stylesheets:
|
|
243
226
|
background-image: url('../images/logo.svg')
|
244
227
|
}
|
245
228
|
```
|
246
|
-
|
229
|
+
### Defer for `javascript_pack_tag`
|
247
230
|
Note, the default of "defer" for the `javascript_pack_tag`. You can override that to `false`. If you expose jquery globally with `expose-loader,` by using `import $ from "expose-loader?exposes=$,jQuery!jquery"` in your `app/packs/entrypoints/application.js`, pass the option `defer: false` to your `javascript_pack_tag`.
|
248
231
|
|
249
|
-
|
232
|
+
### Server-Side Rendering (SSR)
|
250
233
|
|
251
234
|
Note, if you are using server-side rendering of JavaScript with dynamic code-splitting, as is often done with extensions to Webpacker, like [React on Rails](https://github.com/shakacode/react_on_rails), your JavaScript should create the link prefetch HTML tags that you will use, so you won't need to use to `asset_pack_path` in those circumstances.
|
252
235
|
|
@@ -307,11 +290,33 @@ end
|
|
307
290
|
|
308
291
|
### Webpack Configuration
|
309
292
|
|
310
|
-
|
293
|
+
First, you don't _need_ to use Shakapacker's webpack configuration. However, the `shakapacker` NPM package provides convenient access to configuration code that reads the `config/webpacker.yml` file which the view helpers also use. If you have your own customized webpack configuration, at the mininmum, you must ensure:
|
294
|
+
|
295
|
+
1. Your output files go the right directory
|
296
|
+
2. You provide a manifest, via package [`webpack-assets-manifest`](https://github.com/webdeveric/webpack-assets-manifest) that maps output names (your 'packs') to the fingerprinted versions, including bundle-splitting dependencies. That's the main secret sauce of webpacker!
|
311
297
|
|
312
|
-
|
298
|
+
The most practical webpack configuration is to take the default from Shakapacker and then use [webpack-merge](https://github.com/survivejs/webpack-merge) to merge your customizations with the default. For example, suppose you want to add some `resolve.extensions`:
|
299
|
+
|
300
|
+
```js
|
301
|
+
// use the new NPM package name, `shakapacker`.
|
302
|
+
// merge is webpack-merge from https://github.com/survivejs/webpack-merge
|
303
|
+
const { webpackConfig: baseWebpackConfig, merge } = require('shakapacker')
|
313
304
|
|
314
|
-
|
305
|
+
const options = {
|
306
|
+
resolve: {
|
307
|
+
extensions: ['.css', '.ts', '.tsx']
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
// Copy the object using merge b/c the baseClientWebpackConfig is a mutable global
|
312
|
+
// If you want to use this object for client and server rendering configurations,
|
313
|
+
// havaing a new object is essential.
|
314
|
+
module.exports = merge({}, baseWebpackConfig, options)
|
315
|
+
```
|
316
|
+
|
317
|
+
This example is based on [an example project](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/blob/master/config/webpack/webpack.config.js)
|
318
|
+
|
319
|
+
Webpacker gives you a default configuration file `config/webpack/webpack.config.js`, which, by default, you don't need to make any changes to `config/webpack/webpack.config.js` since it's a standard production-ready configuration. However, you will probably want to customize or add a new loader by modifying the webpack configuration, as shown above.
|
315
320
|
|
316
321
|
You might add separate files to keep your code more organized.
|
317
322
|
|
@@ -334,6 +339,7 @@ Then `require` this file in your `config/webpack/webpack.config.js`:
|
|
334
339
|
|
335
340
|
```js
|
336
341
|
// config/webpack/webpack.config.js
|
342
|
+
// use the new NPM package name, `shakapacker`.
|
337
343
|
const { webpackConfig, merge } = require('shakapacker')
|
338
344
|
const customConfig = require('./custom')
|
339
345
|
|
@@ -355,7 +361,7 @@ console.log(JSON.stringify(webpackConfig, undefined, 2))
|
|
355
361
|
|
356
362
|
### Babel configuration
|
357
363
|
|
358
|
-
By default, you will find the Webpacker preset in your `package.json`.
|
364
|
+
By default, you will find the Webpacker preset in your `package.json`. Note, you need to use the new NPM package name, `shakapacker`.
|
359
365
|
|
360
366
|
```json
|
361
367
|
"babel": {
|
@@ -542,7 +548,6 @@ const vueConfig = require('./rules/vue')
|
|
542
548
|
module.exports = merge(vueConfig, webpackConfig)
|
543
549
|
```
|
544
550
|
|
545
|
-
|
546
551
|
### Custom Rails environments
|
547
552
|
|
548
553
|
Out of the box Webpacker ships with - development, test and production environments in `config/webpacker.yml` however, in most production apps extra environments are needed as part of deployment workflow. Webpacker supports this out of the box from version 3.4.0+ onwards.
|
@@ -614,7 +619,7 @@ yarn add shakapacker@next
|
|
614
619
|
|
615
620
|
Also, consult the [CHANGELOG](./CHANGELOG.md) for additional upgrade links.
|
616
621
|
|
617
|
-
|
622
|
+
### Paths
|
618
623
|
|
619
624
|
By default, Webpacker ships with simple conventions for where the JavaScript app files and compiled webpack bundles will go in your Rails app. All these options are configurable from `config/webpacker.yml` file.
|
620
625
|
|
@@ -678,10 +683,9 @@ If you are using a CDN setup, webpacker will use the configured [asset host](htt
|
|
678
683
|
|
679
684
|
See the doc page for [Troubleshooting](./docs/troubleshooting.md).
|
680
685
|
|
681
|
-
|
682
686
|
## Contributing
|
683
687
|
|
684
|
-
We encourage you to contribute to Webpacker! See [CONTRIBUTING](CONTRIBUTING.md) for guidelines about how to proceed.
|
688
|
+
We encourage you to contribute to Shakapacker/Webpacker! See [CONTRIBUTING](CONTRIBUTING.md) for guidelines about how to proceed. We have a [Slack discussion channel](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE).
|
685
689
|
|
686
690
|
## License
|
687
691
|
|
data/docs/v6_upgrade.md
CHANGED
@@ -11,7 +11,7 @@ Webpacker used to configure Webpack indirectly, which lead to a [complicated sec
|
|
11
11
|
This means you have to configure integration with frameworks yourself, but webpack-merge helps with this. See this example for [Vue](https://github.com/shakacode/shakapacker#other-frameworks) and scroll to the bottom for [more examples](#examples-of-v5-to-v6).
|
12
12
|
|
13
13
|
## webpacker v6.0.0.rc.6 to shakapacker
|
14
|
-
See example migration
|
14
|
+
See an example migration here: [PR 27](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/pull/27).
|
15
15
|
|
16
16
|
### Update
|
17
17
|
1. Peer dependencies. Run `yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader compression-webpack-plugin terser-webpack-plugin webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server`
|
data/lib/webpacker/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "6.0.
|
3
|
+
"version": "6.0.1",
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
5
5
|
"main": "package/index.js",
|
6
6
|
"files": [
|
@@ -18,7 +18,6 @@
|
|
18
18
|
"@babel/runtime": "^7.15.4",
|
19
19
|
"babel-loader": "^8.2.2",
|
20
20
|
"compression-webpack-plugin": "^9.0.0",
|
21
|
-
"pnp-webpack-plugin": "^1.7.0",
|
22
21
|
"terser-webpack-plugin": "^5.2.4",
|
23
22
|
"webpack": "^5.53.0",
|
24
23
|
"webpack-assets-manifest": "^5.0.6",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shakapacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-01-
|
13
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -269,7 +269,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
269
269
|
licenses:
|
270
270
|
- MIT
|
271
271
|
metadata:
|
272
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v6.0.
|
272
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v6.0.1
|
273
273
|
post_install_message:
|
274
274
|
rdoc_options: []
|
275
275
|
require_paths:
|