shakapacker 6.0.0.rc.13 → 6.0.2

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: d56f3bf25f84819a60ea5e8ad408d654eec2a208886d7ebb6b84e27dd09af4a0
4
- data.tar.gz: f71bf10af00c11400e4fc2edd43e60d6dee2be79ca79cbdd6202c9cc9442e36d
3
+ metadata.gz: 92baeec1396c0616c20a1aad6d7b45f81776c825c684cf585ca2511602b9f60e
4
+ data.tar.gz: 91f7b0d550b5334d6284636b984bdb55f9feb5cd72211254be5c50b4afae2b27
5
5
  SHA512:
6
- metadata.gz: 3d2efc92056730fa4cd322aff21e9dc328dbf4d2e1699f2792dbab4b633445914c5f224e5aa322721570903cc3610cce6301dc83b46c0fa853606bbc225ab3ec
7
- data.tar.gz: 62a8fc9cfb3fec708e1dbd0bdb405c5b66edec87d818f5624d94e09acae73a0f558865b504f6cf3c506e230df9b47730712fa002f1d833bd88b8ae8060852cae
6
+ metadata.gz: 5ccc02bd10d28bf68b1b38fba51769c71c23aa874f5922516c9804088d179163fd25b8ac5e2da48325d5fbdffe65467c409848ef5086551ffee60c8021fcb444
7
+ data.tar.gz: e035005d2e37ccad4a0bdd7cde26059fc1dd00d840d8d487866de0f175c083d26a6c427eb663065d4190a47608bf7572c29752c2d1ce52a50986504bee0c8970
data/CHANGELOG.md CHANGED
@@ -1,17 +1,30 @@
1
- For versions prior to v6, see the [5.x stable branch of rails/webpacker](https://github.com/rails/webpacker/tree/5-x-stable).
2
-
1
+ * For versions prior to v6, see the [5.x stable branch of rails/webpacker](https://github.com/rails/webpacker/tree/5-x-stable).
2
+ * Please see [UPGRADE GUIDE](./docs/v6_upgrade.md).
3
3
 
4
4
  ## Versions
5
5
  ### [Unreleased]
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.2] - January 25, 2022
10
+ ### Improved
11
+ - Fix incorrect command name in warning. [PR 33](https://github.com/shakacode/shakapacker/pull/33) by [tricknotes](https://github.com/tricknotes).
12
+
13
+ ## [v6.0.1] - January 24, 2022
14
+ ### Improved
15
+ - 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/30) by [t27duck](https://github.com/t27duck).
16
+
17
+ ## [v6.0.0 changes from v6.0.0.rc.6] - January 22, 2022
18
+
19
+ ### Improved
20
+ - 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).
21
+ - 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).
22
+ - Remove pnp-webpack-plugin. [PR 21](https://github.com/shakacode/shakapacker/pull/21) by [tomdracz](https://github.com/tomdracz).
9
23
 
10
- ## [6.0.0.rc.12]
11
24
 
12
25
  ### Merged from rails/webpacker
13
26
 
14
- - Make watched_files_digest thread safe. [rails/webpacker #3233](https://github.com/rails/webpacker/pull/3233)
27
+ - Make watched_files_digest thread safe. [rails/webpacker #3233](https://github.com/rails/webpacker/pull/3233)
15
28
  - Use single webpack config webpack.config.js. [rails/webpacker #3240](https://github.com/rails/webpacker/pull/3240)
16
29
  - Switch to peer dependencies. [rails/webpacker #3234](https://github.com/rails/webpacker/pull/3234)
17
30
 
@@ -20,11 +33,9 @@ Changes since last non-beta release.
20
33
  to `config/webpack/#{NODE_ENV}.js`.
21
34
  - Changed all package.json dependencies to peerDependencies, so upgrading requires adding the dependencies, per the [UPGRADE GUIDE](./docs/v6_upgrade.md).
22
35
 
23
- ## [6.0.0.rc.6] - Forked January 16, 2022
36
+ ## [v6.0.0.rc.6 changes from v5.4] - Forked January 16, 2022
24
37
 
25
- Latest is rc.9.
26
38
 
27
- Please see [UPGRADE GUIDE](./docs/v6_upgrade.md) for more information.
28
39
  - `node_modules` will no longer be babel transfomed 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:
29
40
 
30
41
  ```js
@@ -48,6 +59,8 @@ Please see [UPGRADE GUIDE](./docs/v6_upgrade.md) for more information.
48
59
  - CSS extraction enabled by default, except when devServer is configured and running
49
60
 
50
61
 
51
- [Unreleased]: https://github.com/shakacode/shakapacker/compare/6.0.0-rc.11...master
52
- [6.0.0.rc.12]: https://github.com/shakacode/shakapacker/compare/aba79635e6ff6562ec04d3c446d57ef19a5fef7d...v6.0.0-rc.12
53
- [6.0.0.rc.6]: https://github.com/rails/webpacker/compare/v5.4.3...aba79635e6ff6562ec04d3c446d57ef19a5fef7d
62
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/6.0.2...master
63
+ [v6.0.2]: https://github.com/shakacode/shakapacker/compare/v6.0.1...v6.0.2
64
+ [v6.0.1]: https://github.com/shakacode/shakapacker/compare/v6.0.0...v6.0.1
65
+ [v6.0.0 changes from v6.0.0.rc.6]: https://github.com/shakacode/shakapacker/compare/aba79635e6ff6562ec04d3c446d57ef19a5fef7d...v6.0.0
66
+ [v6.0.0.rc.6 changes from v5.4]: https://github.com/rails/webpacker/compare/v5.4.3...aba79635e6ff6562ec04d3c446d57ef19a5fef7d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (6.0.0.rc.6)
4
+ shakapacker (6.0.0.rc.13)
5
5
  activesupport (>= 5.2)
6
6
  rack-proxy (>= 0.6.1)
7
7
  railties (>= 5.2)
data/README.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # Shakapacker
2
2
 
3
- _Official, actively maintained fork of [rails/webpacker](https://github.com/rails/webpacker). For pre v6, see [rails/webpacker 5-x-stable](https://github.com/rails/webpacker/tree/5-x-stable). Be sure to see the [CHANGELOG](./CHANGELOG.md)._
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.
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.
7
5
 
8
6
  [![Ruby specs](https://github.com/shakacode/shakapacker/workflows/Ruby%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
9
7
  [![Jest specs](https://github.com/shakacode/shakapacker/workflows/Jest%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
@@ -12,6 +10,7 @@ _Official, actively maintained fork of [rails/webpacker](https://github.com/rail
12
10
 
13
11
  [![node.js](https://img.shields.io/badge/node-%3E%3D%2012.0.0-brightgreen.svg)](https://www.npmjs.com/package/shakapacker)
14
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)
15
14
 
16
15
  Webpacker makes it easy to use the JavaScript pre-processor and bundler
17
16
  [Webpack v5](https://webpack.js.org/)
@@ -33,12 +32,12 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
33
32
  - [Features](#features)
34
33
  - [Optional support](#optional-support)
35
34
  - [Installation](#installation)
36
- - [Rails v6](#rails-v6)
37
- - [Rails v7](#rails-v7)
38
- - [Manual Installation Steps](#manual-installation-steps)
35
+ - [Rails v6+](#rails-v6)
36
+ - [Note for Sprockets usage](#note-for-sprockets-usage)
39
37
  - [Usage](#usage)
40
- - [Defer for `javascript_pack_tag`](#defer-for-javascript_pack_tag)
41
- - [Server-Side Rendering (SSR)](#server-side-rendering-ssr)
38
+ - [View Helpers](#view-helpers)
39
+ - [Defer for `javascript_pack_tag`](#defer-for-javascript_pack_tag)
40
+ - [Server-Side Rendering (SSR)](#server-side-rendering-ssr)
42
41
  - [Development](#development)
43
42
  - [Webpack Configuration](#webpack-configuration)
44
43
  - [Babel configuration](#babel-configuration)
@@ -55,9 +54,10 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
55
54
  - [Other frameworks](#other-frameworks)
56
55
  - [Custom Rails environments](#custom-rails-environments)
57
56
  - [Upgrading](#upgrading)
58
- - [Paths](#paths)
57
+ - [Paths](#paths)
59
58
  - [Additional paths](#additional-paths)
60
59
  - [Deployment](#deployment)
60
+ - [Example Apps](#example-apps)
61
61
  - [Troubleshooting](#troubleshooting)
62
62
  - [Contributing](#contributing)
63
63
  - [License](#license)
@@ -72,49 +72,40 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
72
72
  - Yarn
73
73
 
74
74
  ## Features
75
-
75
+ - Rails view helpers that fully support webpack output
76
+ - Convenient but not required webpack configuration. The only requirement is that your webpack configuration create a manifest.
77
+ - HMR with the webpack-dev-server, such as for hot-reloading for React!
78
+ - Automatic code splitting using multiple entry points to optimize JavaScript downloads
76
79
  - [Webpack v5](https://webpack.js.org/)
77
80
  - ES6 with [babel](https://babeljs.io/)
78
- - Automatic code splitting using multiple entry points
79
81
  - Asset compression, source-maps, and minification
80
82
  - CDN support
81
- - Rails view helpers
82
- - Extensible and configurable
83
+ - Extensible and configurable. For example, all major dependencies are specified as peers, so you can upgrade easily.
83
84
 
84
85
  ### Optional support
85
-
86
- _requires extra packages to be installed_
87
-
88
- - Stylesheets - Sass, Less, Stylus and Css, PostCSS
89
- - CoffeeScript
90
- - TypeScript
91
- - React
86
+ _Requires extra packages to be installed._
87
+ - React
88
+ - TypeScript
89
+ - Stylesheets - Sass, Less, Stylus and Css, PostCSS
90
+ - CoffeeScript
92
91
 
93
92
  ## Installation
94
93
 
95
- ### Rails v6
96
- With Rails v6, webpacker is installed by default:
97
- ```bash
98
- rails new myapp
99
- ```
100
94
 
101
- ### Rails v7
95
+ ### Rails v6+
102
96
 
103
- With Rails v7, skip JavaScript for a new app and follow below Manual Installation Steps to manually add the `webpacker` gem to your Gemfile.
97
+ With Rails v6+, skip JavaScript for a new app and follow below Manual Installation Steps to manually add the `shakapacker` gem to your Gemfile.
104
98
  ```bash
105
99
  rails new myapp --skip-javascript
106
100
  ```
107
101
 
108
- ### Manual Installation Steps
102
+ _Note, Rails 6 installs the older v5 version of webpacker unless you specify `--skip-javascript`._
103
+
109
104
  Update your `Gemfile`:
110
105
 
111
106
  ```ruby
112
107
  # Gemfile
113
108
  gem 'shakapacker', '~> 6.0'
114
-
115
- # OR if you prefer to use master
116
- gem 'shakapacker', git: 'https://github.com/shakacode/shakapacker.git'
117
- yarn add https://github.com/shakacode/shakapacker.git
118
109
  ```
119
110
 
120
111
  Then running the following to install Webpacker:
@@ -134,15 +125,26 @@ Note, in v6, most JS packages are peer dependencies. Thus, the installer will ad
134
125
 
135
126
  ```bash
136
127
  yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader \
137
- compression-webpack-plugin pnp-webpack-plugin terser-webpack-plugin \
128
+ compression-webpack-plugin terser-webpack-plugin \
138
129
  webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server
139
130
  ```
140
131
 
141
132
  Previously, these "webpack" and "babel" packages were direct dependencies for `webpacker`. By
142
133
  making these peer dependencies, you have control over the versions used in your webpack and babel configs.
143
134
 
135
+ ### Note for Sprockets usage
136
+
137
+ If you are still using Sprockets for some of your assets, you might want to include files from `node_modules` directory in your asset pipeline. This is useful, for example, if you want to reference a stylesheet from a node package in your `.scss` stylesheet.
138
+
139
+ In order to enable this, make sure you add `node_modules` to the asset load path by adding the following in an initializer (for example `config/initializers/assets.rb`)
140
+ ```ruby
141
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
142
+ ```
143
+
144
144
  ## Usage
145
145
 
146
+ ### View Helpers
147
+
146
148
  Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
147
149
 
148
150
  ```yml
@@ -180,7 +182,7 @@ The result looks like this:
180
182
  <script src="/packs/map-16838bab065ae1e314.js" data-turbolinks-track="reload" defer></script>
181
183
  ```
182
184
 
183
- **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.
185
+ **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.
184
186
 
185
187
  ```erb
186
188
  <%# DO %>
@@ -222,10 +224,10 @@ If you want to use images in your stylesheets:
222
224
  background-image: url('../images/logo.svg')
223
225
  }
224
226
  ```
225
- ##### Defer for `javascript_pack_tag`
227
+ ### Defer for `javascript_pack_tag`
226
228
  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`.
227
229
 
228
- #### Server-Side Rendering (SSR)
230
+ ### Server-Side Rendering (SSR)
229
231
 
230
232
  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.
231
233
 
@@ -286,11 +288,33 @@ end
286
288
 
287
289
  ### Webpack Configuration
288
290
 
289
- Webpacker gives you a default configuration file for your test, development, and production environments in `config/webpack/*.js`.
291
+ 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:
290
292
 
291
- By default, you don't need to make any changes to `config/webpack/webpack.config.js` files since it's all standard production-ready configuration. However, if you do need to customize or add a new loader, this is where you would go.
293
+ 1. Your output files go the right directory
294
+ 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!
292
295
 
293
- Here is how you can modify webpack configuration:
296
+ 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`:
297
+
298
+ ```js
299
+ // use the new NPM package name, `shakapacker`.
300
+ // merge is webpack-merge from https://github.com/survivejs/webpack-merge
301
+ const { webpackConfig: baseWebpackConfig, merge } = require('shakapacker')
302
+
303
+ const options = {
304
+ resolve: {
305
+ extensions: ['.css', '.ts', '.tsx']
306
+ }
307
+ }
308
+
309
+ // Copy the object using merge b/c the baseClientWebpackConfig is a mutable global
310
+ // If you want to use this object for client and server rendering configurations,
311
+ // havaing a new object is essential.
312
+ module.exports = merge({}, baseWebpackConfig, options)
313
+ ```
314
+
315
+ 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)
316
+
317
+ 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.
294
318
 
295
319
  You might add separate files to keep your code more organized.
296
320
 
@@ -313,6 +337,7 @@ Then `require` this file in your `config/webpack/webpack.config.js`:
313
337
 
314
338
  ```js
315
339
  // config/webpack/webpack.config.js
340
+ // use the new NPM package name, `shakapacker`.
316
341
  const { webpackConfig, merge } = require('shakapacker')
317
342
  const customConfig = require('./custom')
318
343
 
@@ -334,7 +359,7 @@ console.log(JSON.stringify(webpackConfig, undefined, 2))
334
359
 
335
360
  ### Babel configuration
336
361
 
337
- By default, you will find the Webpacker preset in your `package.json`.
362
+ By default, you will find the Webpacker preset in your `package.json`. Note, you need to use the new NPM package name, `shakapacker`.
338
363
 
339
364
  ```json
340
365
  "babel": {
@@ -521,7 +546,6 @@ const vueConfig = require('./rules/vue')
521
546
  module.exports = merge(vueConfig, webpackConfig)
522
547
  ```
523
548
 
524
-
525
549
  ### Custom Rails environments
526
550
 
527
551
  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.
@@ -574,7 +598,7 @@ You can run following commands to upgrade Webpacker to the latest stable version
574
598
 
575
599
  ```bash
576
600
  # check your Gemfile for version restrictions
577
- bundle update webpacker
601
+ bundle update shakapacker
578
602
 
579
603
  # overwrite your changes to the default install files and revert any unwanted changes from the install
580
604
  rails webpacker:install
@@ -593,7 +617,7 @@ yarn add shakapacker@next
593
617
 
594
618
  Also, consult the [CHANGELOG](./CHANGELOG.md) for additional upgrade links.
595
619
 
596
- ## Paths
620
+ ### Paths
597
621
 
598
622
  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.
599
623
 
@@ -649,18 +673,17 @@ When compiling assets for production on a remote server, such as a continuous in
649
673
 
650
674
  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.
651
675
 
676
+ ## Example Apps
677
+ * [React on Rails Tutorial With SSR, HMR fast refresh, and TypeScript](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh)
678
+
652
679
 
653
680
  ## Troubleshooting
654
681
 
655
682
  See the doc page for [Troubleshooting](./docs/troubleshooting.md).
656
683
 
657
-
658
684
  ## Contributing
659
685
 
660
- [![Code Helpers](https://www.codetriage.com/shakacode/shakapacker/badges/users.svg)](https://www.codetriage.com/shakacode/shakapacker)
661
-
662
- We encourage you to contribute to Webpacker! See [CONTRIBUTING](CONTRIBUTING.md) for guidelines about how to proceed.
663
-
686
+ 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).
664
687
 
665
688
  ## License
666
689
 
@@ -39,14 +39,14 @@ module.exports = function (api) {
39
39
  development: isDevelopmentEnv || isTestEnv,
40
40
  useBuiltIns: true
41
41
  }
42
- ],
42
+ ]
43
+ ].filter(Boolean),
44
+ plugins: [
43
45
  isProductionEnv && ['babel-plugin-transform-react-remove-prop-types',
44
46
  {
45
47
  removeImport: true
46
48
  }
47
- ]
48
- ].filter(Boolean),
49
- plugins: [
49
+ ],
50
50
  process.env.WEBPACK_SERVE && 'react-refresh/babel'
51
51
  ].filter(Boolean),
52
52
  }
data/docs/v6_upgrade.md CHANGED
@@ -11,12 +11,13 @@ 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, [PR 27](https://github.com/shakacode/react_on_rails_tutorial_with_ssr_and_hmr_fast_refresh/pull/27).
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
- 1. Peer dependencies. Run `yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader compression-webpack-plugin pnp-webpack-plugin terser-webpack-plugin webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server`
18
- 2. Update your webpack config for a single config file, `config/webpack/webpack.config.js`.
19
- 3. Update `babel.config.js` if you need JSX support.
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`
18
+ 1. Update any scripts that called `bin/webpack` or `bin/webpack-dev-server` to `bin/webpacker` or `bin/webpacker-dev-server`
19
+ 1. Update your webpack config for a single config file, `config/webpack/webpack.config.js`.
20
+ 1. Update `babel.config.js` if you need JSX support.
20
21
 
21
22
  ## How to upgrade to Webpacker v6 from v5
22
23
  1. Ensure you have a clean working git branch. You will be overwriting all your files and reverting the changes that you don't want.
@@ -41,13 +42,13 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
41
42
 
42
43
  1. Upgrade the Webpacker Ruby gem and the NPM package
43
44
 
44
- Note: [Check the releases page to verify the latest version](https://github.com/rails/webpacker/releases), and make sure to install identical version numbers of webpacker gem and `shakapacker` npm package. (Gems use a period and packages use a dot between the main version number and the beta version.)
45
+ Note: [Check the gem page to verify the latest version](https://rubygems.org/gems/shakapacker), and make sure to install identical version numbers of `shakapacker` gem and package. (Gems use a period and packages use a dot between the main version number and the beta version.)
45
46
 
46
47
  Example going to a specific version:
47
48
 
48
49
  ```ruby
49
50
  # Gemfile
50
- gem 'shakapacker', '6.0.0.rc.13', require: 'webpacker'
51
+ gem 'shakapacker', '6.0.0.rc.13'
51
52
  ```
52
53
 
53
54
  ```bash
@@ -55,7 +56,7 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
55
56
  ```
56
57
 
57
58
  ```bash
58
- yarn add shakapacker@6.0.0-rc.7 --exact
59
+ yarn add shakapacker@6.0.0-rc.13 --exact
59
60
  ```
60
61
 
61
62
  ```bash
@@ -66,7 +67,7 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
66
67
 
67
68
  Note, the webpacker:install will install the peer dependencies:
68
69
  ```bash
69
- yarn add @babel/core @babel/plugin-transform-runtime @babel/preset-env @babel/runtime babel-loader compression-webpack-plugin pnp-webpack-plugin terser-webpack-plugin webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server
70
+ 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
70
71
  ```
71
72
 
72
73
  1. There is now a single default configuration file of `config/webpack/webpack.config.js`. Previously, the config file was set
@@ -45,15 +45,6 @@ if (setup_path = Rails.root.join("bin/setup")).exist?
45
45
  RUBY
46
46
  end
47
47
 
48
- if (asset_config_path = Rails.root.join("config/initializers/assets.rb")).exist?
49
- say "Add node_modules to the asset load path"
50
- append_to_file asset_config_path, <<-RUBY
51
-
52
- # Add node_modules folder to the asset load path.
53
- Rails.application.config.assets.paths << Rails.root.join("node_modules")
54
- RUBY
55
- end
56
-
57
48
  if (csp_config_path = Rails.root.join("config/initializers/content_security_policy.rb")).exist?
58
49
  say "Make note of webpack-dev-server exemption needed to csp"
59
50
  insert_into_file csp_config_path, <<-RUBY, after: %(# Rails.application.config.content_security_policy do |policy|)
@@ -57,8 +57,8 @@ class Webpacker::Compiler
57
57
  Webpacker::Compiler - Slow setup for development
58
58
 
59
59
  Prepare JS assets with either:
60
- 1. Running `bin/webpack-dev-server`
61
- 2. Set `compile` to false in webpacker.yml and run `bin/webpack -w`
60
+ 1. Running `bin/webpacker-dev-server`
61
+ 2. Set `compile` to false in webpacker.yml and run `bin/webpacker -w`
62
62
  MSG
63
63
  end
64
64
 
@@ -96,6 +96,13 @@ module Webpacker::Helper
96
96
  # <%= javascript_pack_tag 'calendar' %>
97
97
  # <%= javascript_pack_tag 'map' %>
98
98
  def javascript_pack_tag(*names, defer: true, **options)
99
+ if @javascript_pack_tag_loaded
100
+ raise "To prevent duplicated chunks on the page, you should call javascript_pack_tag only once on the page. " \
101
+ "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#usage for the usage guide"
102
+ end
103
+
104
+ @javascript_pack_tag_loaded = true
105
+
99
106
  javascript_include_tag(*sources_from_manifest_entrypoints(names, type: :javascript), **options.tap { |o| o[:defer] = defer })
100
107
  end
101
108
 
@@ -141,6 +148,13 @@ module Webpacker::Helper
141
148
  # <%= stylesheet_pack_tag 'calendar' %>
142
149
  # <%= stylesheet_pack_tag 'map' %>
143
150
  def stylesheet_pack_tag(*names, **options)
151
+ if @stylesheet_pack_tag_loaded
152
+ raise "To prevent duplicated chunks on the page, you should call stylesheet_pack_tag only once on the page. " \
153
+ "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#usage for the usage guide"
154
+ end
155
+
156
+ @stylesheet_pack_tag_loaded = true
157
+
144
158
  return "" if Webpacker.inlining_css?
145
159
 
146
160
  stylesheet_link_tag(*sources_from_manifest_entrypoints(names, type: :stylesheet), **options)
@@ -1,4 +1,4 @@
1
1
  module Webpacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "6.0.0.rc.13".freeze
3
+ VERSION = "6.0.2".freeze
4
4
  end
@@ -3,7 +3,6 @@
3
3
 
4
4
  const { basename, dirname, join, relative, resolve } = require('path')
5
5
  const extname = require('path-complete-extname')
6
- const PnpWebpackPlugin = require('pnp-webpack-plugin')
7
6
  const { sync: globSync } = require('glob')
8
7
  const WebpackAssetsManifest = require('webpack-assets-manifest')
9
8
  const webpack = require('webpack')
@@ -92,15 +91,13 @@ module.exports = {
92
91
  entry: getEntryObject(),
93
92
  resolve: {
94
93
  extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.coffee'],
95
- modules: getModulePaths(),
96
- plugins: [PnpWebpackPlugin]
94
+ modules: getModulePaths()
97
95
  },
98
96
 
99
97
  plugins: getPlugins(),
100
98
 
101
99
  resolveLoader: {
102
- modules: ['node_modules'],
103
- plugins: [PnpWebpackPlugin.moduleLoader(module)]
100
+ modules: ['node_modules']
104
101
  },
105
102
 
106
103
  optimization: {
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shakapacker",
3
- "version": "6.0.0-rc.13",
3
+ "version": "6.0.2",
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",
@@ -40,7 +39,6 @@
40
39
  "eslint-plugin-jsx-a11y": "^6.4.1",
41
40
  "eslint-plugin-react": "^7.26.0",
42
41
  "jest": "^27.2.1",
43
- "pnp-webpack-plugin": "^1.7.0",
44
42
  "webpack": "^5.53.0",
45
43
  "webpack-assets-manifest": "^5.0.6",
46
44
  "webpack-merge": "^5.8.0"
data/test/helper_test.rb CHANGED
@@ -12,6 +12,9 @@ class HelperTest < ActionView::TestCase
12
12
  "https://example.com"
13
13
  end
14
14
  end.new
15
+
16
+ @javascript_pack_tag_loaded = nil
17
+ @stylesheet_pack_tag_loaded = nil
15
18
  end
16
19
 
17
20
  def test_asset_pack_path
@@ -129,6 +132,18 @@ class HelperTest < ActionView::TestCase
129
132
  javascript_pack_tag(:application)
130
133
  end
131
134
 
135
+ def test_javascript_pack_tag_multiple_invocations
136
+ error = assert_raises do
137
+ javascript_pack_tag(:application)
138
+ javascript_pack_tag(:bootstrap)
139
+ end
140
+
141
+ assert_equal \
142
+ "To prevent duplicated chunks on the page, you should call javascript_pack_tag only once on the page. " +
143
+ "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#usage for the usage guide",
144
+ error.message
145
+ end
146
+
132
147
  def application_stylesheet_chunks
133
148
  %w[/packs/1-c20632e7baf2c81200d3.chunk.css /packs/application-k344a6d59eef8632c9d1.chunk.css]
134
149
  end
@@ -156,4 +171,16 @@ class HelperTest < ActionView::TestCase
156
171
  (application_stylesheet_chunks).map { |chunk| stylesheet_link_tag(chunk, media: "all") }.join("\n"),
157
172
  stylesheet_pack_tag("application", media: "all")
158
173
  end
174
+
175
+ def test_stylesheet_pack_tag_multiple_invocations
176
+ error = assert_raises do
177
+ stylesheet_pack_tag(:application)
178
+ stylesheet_pack_tag(:hello_stimulus)
179
+ end
180
+
181
+ assert_equal \
182
+ "To prevent duplicated chunks on the page, you should call stylesheet_pack_tag only once on the page. " +
183
+ "Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#usage for the usage guide",
184
+ error.message
185
+ end
159
186
  end
data/yarn.lock CHANGED
@@ -3215,13 +3215,6 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0:
3215
3215
  dependencies:
3216
3216
  find-up "^4.0.0"
3217
3217
 
3218
- pnp-webpack-plugin@^1.7.0:
3219
- version "1.7.0"
3220
- resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.7.0.tgz#65741384f6d8056f36e2255a8d67ffc20866f5c9"
3221
- integrity sha512-2Rb3vm+EXble/sMXNSu6eoBx8e79gKqhNq9F5ZWW6ERNCTE/Q0wQNne5541tE5vKjfM8hpNCYL+LGc1YTfI0dg==
3222
- dependencies:
3223
- ts-pnp "^1.1.6"
3224
-
3225
3218
  prelude-ls@^1.2.1:
3226
3219
  version "1.2.1"
3227
3220
  resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
@@ -3730,11 +3723,6 @@ tr46@^2.1.0:
3730
3723
  dependencies:
3731
3724
  punycode "^2.1.1"
3732
3725
 
3733
- ts-pnp@^1.1.6:
3734
- version "1.2.0"
3735
- resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
3736
- integrity sha512-csd+vJOb/gkzvcCHgTGSChYpy5f1/XKNsmvBGO4JXS+z1v2HobugDz4s1IeFXM3wZB44uczs+eazB5Q/ccdhQw==
3737
-
3738
3726
  tsconfig-paths@^3.12.0:
3739
3727
  version "3.12.0"
3740
3728
  resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz#19769aca6ee8f6a1a341e38c8fa45dd9fb18899b"
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.0.rc.13
4
+ version: 6.0.2
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-19 00:00:00.000000000 Z
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.0-rc.13
272
+ source_code_uri: https://github.com/shakacode/shakapacker/tree/v6.0.2
273
273
  post_install_message:
274
274
  rdoc_options: []
275
275
  require_paths:
@@ -281,9 +281,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
281
  version: 2.7.0
282
282
  required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  requirements:
284
- - - ">"
284
+ - - ">="
285
285
  - !ruby/object:Gem::Version
286
- version: 1.3.1
286
+ version: '0'
287
287
  requirements: []
288
288
  rubygems_version: 3.2.32
289
289
  signing_key: