shakapacker 6.0.0.rc.13 → 6.0.0.rc.14

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: 52b536f1a629b24f309e3b8fa5d12b4f00f3ab8d900072aef7a87310de40dbf2
4
+ data.tar.gz: aabac3cce21b2ebffd5cb89d250dcbd5adca8599d96dfe2ad6668bd05a81b5ad
5
5
  SHA512:
6
- metadata.gz: 3d2efc92056730fa4cd322aff21e9dc328dbf4d2e1699f2792dbab4b633445914c5f224e5aa322721570903cc3610cce6301dc83b46c0fa853606bbc225ab3ec
7
- data.tar.gz: 62a8fc9cfb3fec708e1dbd0bdb405c5b66edec87d818f5624d94e09acae73a0f558865b504f6cf3c506e230df9b47730712fa002f1d833bd88b8ae8060852cae
6
+ metadata.gz: 7ad0f3e841893c69bc92cb543ed5a96305904b8aa8cc7799c7380bed6979577b60b866ef9d197252d1bbd13ae98e11eae2f8e7e9a8eb22be7a68321389f1826d
7
+ data.tar.gz: 86396cb0725037f0153731ed203d8c3840116e8dd40fd1a1eb8eceace8f20e4f0fab7105956d466b49a86cb08b3c5ea9de40c06213c91801d3500ec18a0f973e
data/CHANGELOG.md CHANGED
@@ -1,13 +1,19 @@
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.0.rc.14] - January 20, 2022
10
+
11
+ ### Improved
12
+ - 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
+ - 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
+ - Remove pnp-webpack-plugin. [PR 21](https://github.com/shakacode/shakapacker/pull/21) by [tomdracz](https://github.com/tomdracz].
9
15
 
10
- ## [6.0.0.rc.12]
16
+ ## [v6.0.0.rc.13 changes from v6.0.0.rc.6]
11
17
 
12
18
  ### Merged from rails/webpacker
13
19
 
@@ -20,11 +26,9 @@ Changes since last non-beta release.
20
26
  to `config/webpack/#{NODE_ENV}.js`.
21
27
  - Changed all package.json dependencies to peerDependencies, so upgrading requires adding the dependencies, per the [UPGRADE GUIDE](./docs/v6_upgrade.md).
22
28
 
23
- ## [6.0.0.rc.6] - Forked January 16, 2022
29
+ ## [v6.0.0.rc.6 changes from v5.4] - Forked January 16, 2022
24
30
 
25
- Latest is rc.9.
26
31
 
27
- Please see [UPGRADE GUIDE](./docs/v6_upgrade.md) for more information.
28
32
  - `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
33
 
30
34
  ```js
@@ -48,6 +52,6 @@ Please see [UPGRADE GUIDE](./docs/v6_upgrade.md) for more information.
48
52
  - CSS extraction enabled by default, except when devServer is configured and running
49
53
 
50
54
 
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
55
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/6.0.0-rc.13...master
56
+ [v6.0.0.rc.13 changes from v6.0.0.rc.6]: https://github.com/shakacode/shakapacker/compare/aba79635e6ff6562ec04d3c446d57ef19a5fef7d...v6.0.0-rc.13
57
+ [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
@@ -3,7 +3,9 @@
3
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
4
 
5
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.
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
+
7
9
 
8
10
  [![Ruby specs](https://github.com/shakacode/shakapacker/workflows/Ruby%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
9
11
  [![Jest specs](https://github.com/shakacode/shakapacker/workflows/Jest%20specs/badge.svg)](https://github.com/shakacode/shakapacker/actions)
@@ -36,6 +38,7 @@ Discussion forums to discuss debugging and troubleshooting tips. Please open iss
36
38
  - [Rails v6](#rails-v6)
37
39
  - [Rails v7](#rails-v7)
38
40
  - [Manual Installation Steps](#manual-installation-steps)
41
+ - [Note for Sprockets usage](#note-for-sprockets-usage)
39
42
  - [Usage](#usage)
40
43
  - [Defer for `javascript_pack_tag`](#defer-for-javascript_pack_tag)
41
44
  - [Server-Side Rendering (SSR)](#server-side-rendering-ssr)
@@ -134,13 +137,22 @@ Note, in v6, most JS packages are peer dependencies. Thus, the installer will ad
134
137
 
135
138
  ```bash
136
139
  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 \
140
+ compression-webpack-plugin terser-webpack-plugin \
138
141
  webpack webpack-assets-manifest webpack-cli webpack-merge webpack-sources webpack-dev-server
139
142
  ```
140
143
 
141
144
  Previously, these "webpack" and "babel" packages were direct dependencies for `webpacker`. By
142
145
  making these peer dependencies, you have control over the versions used in your webpack and babel configs.
143
146
 
147
+ ### Note for Sprockets usage
148
+
149
+ 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.
150
+
151
+ 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`)
152
+ ```ruby
153
+ Rails.application.config.assets.paths << Rails.root.join('node_modules')
154
+ ```
155
+
144
156
  ## Usage
145
157
 
146
158
  Once installed, you can start writing modern ES6-flavored JavaScript apps right away:
data/docs/v6_upgrade.md CHANGED
@@ -14,7 +14,7 @@ This means you have to configure integration with frameworks yourself, but webpa
14
14
  See example migration, [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`
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
18
  2. Update your webpack config for a single config file, `config/webpack/webpack.config.js`.
19
19
  3. Update `babel.config.js` if you need JSX support.
20
20
 
@@ -41,13 +41,13 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
41
41
 
42
42
  1. Upgrade the Webpacker Ruby gem and the NPM package
43
43
 
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.)
44
+ 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
45
 
46
46
  Example going to a specific version:
47
47
 
48
48
  ```ruby
49
49
  # Gemfile
50
- gem 'shakapacker', '6.0.0.rc.13', require: 'webpacker'
50
+ gem 'shakapacker', '6.0.0.rc.13'
51
51
  ```
52
52
 
53
53
  ```bash
@@ -55,7 +55,7 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
55
55
  ```
56
56
 
57
57
  ```bash
58
- yarn add shakapacker@6.0.0-rc.7 --exact
58
+ yarn add shakapacker@6.0.0-rc.13 --exact
59
59
  ```
60
60
 
61
61
  ```bash
@@ -66,7 +66,7 @@ See example migration, [PR 27](https://github.com/shakacode/react_on_rails_tutor
66
66
 
67
67
  Note, the webpacker:install will install the peer dependencies:
68
68
  ```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
69
+ 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
70
  ```
71
71
 
72
72
  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|)
@@ -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.0.rc.14".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.0-rc.14",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "main": "package/index.js",
6
6
  "files": [
@@ -40,7 +40,6 @@
40
40
  "eslint-plugin-jsx-a11y": "^6.4.1",
41
41
  "eslint-plugin-react": "^7.26.0",
42
42
  "jest": "^27.2.1",
43
- "pnp-webpack-plugin": "^1.7.0",
44
43
  "webpack": "^5.53.0",
45
44
  "webpack-assets-manifest": "^5.0.6",
46
45
  "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.0.rc.14
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-21 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.0-rc.14
273
273
  post_install_message:
274
274
  rdoc_options: []
275
275
  require_paths: