webpacker-pnpm 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yaml +4 -3
  3. data/.gitignore +3 -5
  4. data/.rubocop.yml +19 -0
  5. data/CHANGELOG.md +7 -0
  6. data/README.md +14 -3
  7. data/lib/webpacker/pnpm/patches.rb +25 -3
  8. data/lib/webpacker/pnpm/railtie.rb +2 -1
  9. data/lib/webpacker/pnpm/version.rb +1 -1
  10. data/test_app/.gitignore +6 -0
  11. data/test_app/Gemfile +5 -0
  12. data/test_app/Gemfile.lock +175 -0
  13. data/{Rakefile → test_app/Rakefile} +2 -1
  14. data/test_app/app/javascript/packs/application.js +10 -0
  15. data/{test/test_app → test_app}/app/javascript/packs/multi_entry.css +0 -0
  16. data/{test/test_app → test_app}/app/javascript/packs/multi_entry.js +0 -0
  17. data/{test/test_app → test_app}/bin/rails +0 -0
  18. data/{test/test_app → test_app}/bin/rake +0 -0
  19. data/{test/test_app → test_app}/bin/setup +0 -0
  20. data/{test/test_app → test_app}/bin/webpack +0 -0
  21. data/{test/test_app → test_app}/bin/webpack-dev-server +0 -0
  22. data/{test/test_app → test_app}/config/application.rb +0 -0
  23. data/{test/test_app → test_app}/config/boot.rb +0 -0
  24. data/{test/test_app → test_app}/config/environment.rb +0 -0
  25. data/{test/test_app → test_app}/config/webpack/development.js +0 -0
  26. data/{test/test_app → test_app}/config/webpack/environment.js +0 -0
  27. data/test_app/config/webpack/production.js +0 -0
  28. data/{test/test_app → test_app}/config/webpacker.yml +0 -0
  29. data/{test/test_app → test_app}/config/webpacker_public_root.yml +0 -0
  30. data/{test/test_app → test_app}/config.ru +0 -0
  31. data/{test/test_app → test_app}/package.json +3 -1
  32. data/test_app/pnpm-lock.yaml +6756 -0
  33. data/{test/test_app → test_app}/public/packs/manifest.json +0 -0
  34. data/test_app/src/index.js +0 -0
  35. data/{test → test_app/test}/rake_tasks_test.rb +14 -3
  36. data/{test → test_app/test}/test_helper.rb +1 -1
  37. data/webpacker-pnpm.gemspec +1 -1
  38. metadata +36 -56
  39. data/test/test_app/.gitignore +0 -7
  40. data/test/test_app/Rakefile +0 -5
  41. data/test/test_app/app/javascript/packs/application.js +0 -10
  42. data/test/test_app/pnpm-lock.yaml +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e158c9136e7684be56fce973c9272ec8ab16ff20d6c08c5949e0c9f13f2c0e3
4
- data.tar.gz: bf02dcac8a0165359548569f6fd73c44decd31a9cd05393d35ae0a81377f7bdf
3
+ metadata.gz: 85df72b48e172802a711481f7f54ea75410cde46e7df8a68e2dd8f1772faa711
4
+ data.tar.gz: b82b39eb173396c7bb03b49a934a1e9811d2c82a9d608a7ef00ea33565424dca
5
5
  SHA512:
6
- metadata.gz: '058a4834ac5ff8dd02fdc5dfab8253888500c06d0420dfe1643dab0cfc1cb7e50c3157556c34eb8b71b720f5a97e55b2f712be2f0d1d5a7125924024d0ebe885'
7
- data.tar.gz: 6ced6827e35f59e42f1f979dbadddb54d2eb54f039c7aff2fc25a0de2b0450c7149fe39c6f7a98abc224fb54245d001443280982f82020e163a00bc362cc0e49
6
+ metadata.gz: e121ebbbb865ba38282969ea40d278964ebfec79109e9287c90e2d8cc0898ceeef34a58cbc1906d341f032308f7958985183bfc4f0fc73a4a1ed3ffbd061ff3a
7
+ data.tar.gz: 95a7cf3b7e5b59e9db88aeacfedf98590e10cdf288029755925895107e06f6ec402292983533faf1cdd3d2058b870f8254bd8d9e21a9ebe23187e8817edb93a3
@@ -42,9 +42,10 @@ jobs:
42
42
  key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
43
43
  restore-keys: |
44
44
  ${{ runner.os }}-pnpm-store-
45
- - run: pnpm install --frozen-lockfile
46
- working-directory: ./test/test_app
47
45
  - name: Check formatting and syntax
48
46
  run: bundle exec rubocop
49
47
  - name: Run tests
50
- run: bundle exec rake test
48
+ working-directory: ./test_app
49
+ run: |
50
+ pnpm i --frozen-lockfile --shamefully-hoist
51
+ bundle exec rake test
data/.gitignore CHANGED
@@ -1,6 +1,4 @@
1
- /tmp/
2
- **/log
1
+ .pnpm-store
2
+
3
3
  Gemfile.lock
4
- **/*.gem
5
- gemfiles/vendor
6
- .bundle
4
+ *.gem
data/.rubocop.yml CHANGED
@@ -17,8 +17,27 @@ inherit_mode:
17
17
  # cop-specific excludes are not inherited for some reason (likely a bug in RuboCop) so
18
18
  # we need to manually re-omit the intended files and directories.
19
19
  Layout/LineLength:
20
+ Max: 88
20
21
  Exclude:
21
22
  - "**/config/initializers/**/*"
22
23
  Style/MethodCallWithArgsParentheses:
23
24
  Exclude:
24
25
  - "**/Gemfile"
26
+
27
+ # cops to backfill into practical pig
28
+ Performance/AncestorsInclude:
29
+ Enabled: false
30
+ Performance/BigDecimalWithNumericArgument:
31
+ Enabled: true
32
+ Performance/RedundantSortBlock:
33
+ Enabled: true
34
+ Performance/RedundantStringChars:
35
+ Enabled: true
36
+ Performance/ReverseFirst:
37
+ Enabled: true
38
+ Performance/SortReverse:
39
+ Enabled: true
40
+ Performance/Squeeze:
41
+ Enabled: true
42
+ Performance/StringInclude:
43
+ Enabled: true
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on Keep a Changelog (<https://keepachangelog.com/en/1.0.0/>). This project adheres to Semantic Versioning (<https://semver.org/spec/v2.0.0.html>).
6
6
 
7
+ ## [v1.2.3] - 2023-01-14
8
+
9
+ ### Fixed
10
+
11
+ - Actually fixed cross-version watched path compatibility.
12
+ - The previous v1.2.2 fix passed tests due to bad tests. Improved the test suite for real-life usage.
13
+
7
14
  ## [v1.2.2] - 2023-01-13
8
15
 
9
16
  ### Fixed
data/README.md CHANGED
@@ -13,21 +13,32 @@ You can read about the philosophy and technology behind `pnpm` in [this convinci
13
13
  ## Features
14
14
 
15
15
  - Production-ready
16
- - Drop-in seamless replacement for Yarn, no config required
16
+ - Drop-in replacement for Yarn
17
17
  - Supports Rails' Template API, including existing templates using Yarn
18
18
  - Provides code sanity without the migraines
19
19
  - Gives you more disk space
20
20
 
21
21
  ## Installation
22
22
 
23
- In order to use `webpacker-pnpm`, you must install `pnpm`. The official instructions are [here](https://pnpm.io/installation). After installing `pnpm`, simply add `webpacker-pnpm` to your app's `Gemfile`.
23
+ In order to use `webpacker-pnpm`, you must install `pnpm`. The official instructions are [here](https://pnpm.io/installation).
24
+
25
+ After installing `pnpm`, first add `webpacker-pnpm` to your app's `Gemfile`.
24
26
 
25
27
  ```ruby
26
28
  gem "webpacker-pnpm"
27
29
  ```
28
30
 
31
+ Secondly, add the following line to your `./bin/webpack` so it looks like below (the order matters). This step is required as Webpacker spawns a new process isolated from the Rails server (and thus all auto-loaded patches) when compilation happens live.
32
+
33
+ ```ruby
34
+ require "webpacker/webpack_runner"
35
+ require "webpacker/pnpm/patches" if ENV["RAILS_ENV"] != "production"
36
+ ```
37
+
38
+ > _If you know of an automatic way of achieving a similar result, please open an Issue or PR with your suggestion._
39
+
29
40
  ## License
30
41
 
31
42
  This software is licensed under the [BSD 3-Clause License](LICENSE).
32
43
 
33
- This package is Treeware. If you use it in production, consider buying the world a tree to thank me for my work. By contributing to my forest, you’ll be creating employment for local families and restoring wildlife habitats.
44
+ This package is Treeware. If you use it in production, consider buying the world a tree to thank me for my work. By contributing to my forest, you’ll be creating employment for local families and restoring wildlife habitats.
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails/generators"
4
- require "webpacker/runner"
5
3
  require "webpacker/compiler"
4
+ require "webpacker/webpack_runner"
5
+ require "rails/generators"
6
+ require "rails/engine"
6
7
 
7
8
  module Webpacker
8
9
  module PNPM
@@ -19,7 +20,7 @@ module Webpacker
19
20
  end
20
21
 
21
22
  def configured_paths
22
- if config.method_defined?(:additional_paths_globbed)
23
+ if config.respond_to?(:additional_paths_globbed)
23
24
  config.additional_paths_globbed
24
25
  else
25
26
  config.resolved_paths_globbed
@@ -27,6 +28,27 @@ module Webpacker
27
28
  end
28
29
  end
29
30
 
31
+ Webpacker::WebpackRunner.class_eval do
32
+ def run
33
+ env = Webpacker::Compiler.env
34
+ env["WEBPACKER_CONFIG"] = @webpacker_config
35
+
36
+ cmd = if node_modules_bin_exist?
37
+ ["#{@node_modules_bin_path}/webpack"]
38
+ else
39
+ ["pnpm", "webpack"]
40
+ end
41
+
42
+ cmd = ["node", "--inspect-brk"] + cmd if @argv.include?("--debug-webpacker")
43
+
44
+ cmd += ["--config", @webpack_config] + @argv
45
+
46
+ Dir.chdir(@app_path) do
47
+ Kernel.exec(env, *cmd)
48
+ end
49
+ end
50
+ end
51
+
30
52
  # intercept command execution via Thor to replace yarn with pnpm. this exists in
31
53
  # order to patch existing Webpacker installation templates that make direct
32
54
  # calls to install Yarn dependencies. as a result, this isn't a robust patch
@@ -16,7 +16,8 @@ module Webpacker
16
16
  # Webpack runner initialization
17
17
  config.before_configuration do
18
18
  begin
19
- ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.join(`pnpm root`.chomp, ".bin")
19
+ ENV["WEBPACKER_NODE_MODULES_BIN_PATH"] ||= File.join(`pnpm root`.chomp,
20
+ ".bin")
20
21
  rescue Errno::ENOENT
21
22
  # use abort instead of Rails' logger because it doesn't show up when
22
23
  # run within Rake tasks
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Webpacker
4
4
  module PNPM
5
- VERSION = "1.2.2"
5
+ VERSION = "1.2.3"
6
6
 
7
7
  public_constant :VERSION
8
8
  end
@@ -0,0 +1,6 @@
1
+ dist
2
+ log
3
+ node_modules
4
+ tmp
5
+
6
+ !Gemfile.lock
data/test_app/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "webpacker-pnpm", path: "../"
@@ -0,0 +1,175 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ webpacker-pnpm (1.2.3)
5
+ rails (>= 5.2)
6
+ rake (>= 12.3.3)
7
+ semantic_range (~> 2.3)
8
+ webpacker
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (6.1.7)
14
+ actionpack (= 6.1.7)
15
+ activesupport (= 6.1.7)
16
+ nio4r (~> 2.0)
17
+ websocket-driver (>= 0.6.1)
18
+ actionmailbox (6.1.7)
19
+ actionpack (= 6.1.7)
20
+ activejob (= 6.1.7)
21
+ activerecord (= 6.1.7)
22
+ activestorage (= 6.1.7)
23
+ activesupport (= 6.1.7)
24
+ mail (>= 2.7.1)
25
+ actionmailer (6.1.7)
26
+ actionpack (= 6.1.7)
27
+ actionview (= 6.1.7)
28
+ activejob (= 6.1.7)
29
+ activesupport (= 6.1.7)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ rails-dom-testing (~> 2.0)
32
+ actionpack (6.1.7)
33
+ actionview (= 6.1.7)
34
+ activesupport (= 6.1.7)
35
+ rack (~> 2.0, >= 2.0.9)
36
+ rack-test (>= 0.6.3)
37
+ rails-dom-testing (~> 2.0)
38
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
39
+ actiontext (6.1.7)
40
+ actionpack (= 6.1.7)
41
+ activerecord (= 6.1.7)
42
+ activestorage (= 6.1.7)
43
+ activesupport (= 6.1.7)
44
+ nokogiri (>= 1.8.5)
45
+ actionview (6.1.7)
46
+ activesupport (= 6.1.7)
47
+ builder (~> 3.1)
48
+ erubi (~> 1.4)
49
+ rails-dom-testing (~> 2.0)
50
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
51
+ activejob (6.1.7)
52
+ activesupport (= 6.1.7)
53
+ globalid (>= 0.3.6)
54
+ activemodel (6.1.7)
55
+ activesupport (= 6.1.7)
56
+ activerecord (6.1.7)
57
+ activemodel (= 6.1.7)
58
+ activesupport (= 6.1.7)
59
+ activestorage (6.1.7)
60
+ actionpack (= 6.1.7)
61
+ activejob (= 6.1.7)
62
+ activerecord (= 6.1.7)
63
+ activesupport (= 6.1.7)
64
+ marcel (~> 1.0)
65
+ mini_mime (>= 1.1.0)
66
+ activesupport (6.1.7)
67
+ concurrent-ruby (~> 1.0, >= 1.0.2)
68
+ i18n (>= 1.6, < 2)
69
+ minitest (>= 5.1)
70
+ tzinfo (~> 2.0)
71
+ zeitwerk (~> 2.3)
72
+ builder (3.2.4)
73
+ concurrent-ruby (1.1.10)
74
+ crass (1.0.6)
75
+ digest (3.1.1)
76
+ erubi (1.12.0)
77
+ globalid (1.0.0)
78
+ activesupport (>= 5.0)
79
+ i18n (1.12.0)
80
+ concurrent-ruby (~> 1.0)
81
+ io-wait (0.3.0)
82
+ loofah (2.19.1)
83
+ crass (~> 1.0.2)
84
+ nokogiri (>= 1.5.9)
85
+ mail (2.8.0.1)
86
+ mini_mime (>= 0.1.1)
87
+ net-imap
88
+ net-pop
89
+ net-smtp
90
+ marcel (1.0.2)
91
+ method_source (1.0.0)
92
+ mini_mime (1.1.2)
93
+ mini_portile2 (2.6.1)
94
+ minitest (5.15.0)
95
+ net-imap (0.2.2)
96
+ digest
97
+ net-protocol
98
+ strscan
99
+ net-pop (0.1.2)
100
+ net-protocol
101
+ net-protocol (0.1.2)
102
+ io-wait
103
+ timeout
104
+ net-smtp (0.3.0)
105
+ digest
106
+ net-protocol
107
+ timeout
108
+ nio4r (2.5.8)
109
+ nokogiri (1.12.5)
110
+ mini_portile2 (~> 2.6.1)
111
+ racc (~> 1.4)
112
+ racc (1.6.2)
113
+ rack (2.2.5)
114
+ rack-proxy (0.7.4)
115
+ rack
116
+ rack-test (2.0.2)
117
+ rack (>= 1.3)
118
+ rails (6.1.7)
119
+ actioncable (= 6.1.7)
120
+ actionmailbox (= 6.1.7)
121
+ actionmailer (= 6.1.7)
122
+ actionpack (= 6.1.7)
123
+ actiontext (= 6.1.7)
124
+ actionview (= 6.1.7)
125
+ activejob (= 6.1.7)
126
+ activemodel (= 6.1.7)
127
+ activerecord (= 6.1.7)
128
+ activestorage (= 6.1.7)
129
+ activesupport (= 6.1.7)
130
+ bundler (>= 1.15.0)
131
+ railties (= 6.1.7)
132
+ sprockets-rails (>= 2.0.0)
133
+ rails-dom-testing (2.0.3)
134
+ activesupport (>= 4.2.0)
135
+ nokogiri (>= 1.6)
136
+ rails-html-sanitizer (1.4.4)
137
+ loofah (~> 2.19, >= 2.19.1)
138
+ railties (6.1.7)
139
+ actionpack (= 6.1.7)
140
+ activesupport (= 6.1.7)
141
+ method_source
142
+ rake (>= 12.2)
143
+ thor (~> 1.0)
144
+ rake (13.0.6)
145
+ semantic_range (2.3.1)
146
+ sprockets (4.2.0)
147
+ concurrent-ruby (~> 1.0)
148
+ rack (>= 2.2.4, < 4)
149
+ sprockets-rails (3.4.2)
150
+ actionpack (>= 5.2)
151
+ activesupport (>= 5.2)
152
+ sprockets (>= 3.0.0)
153
+ strscan (3.0.5)
154
+ thor (1.2.1)
155
+ timeout (0.3.1)
156
+ tzinfo (2.0.5)
157
+ concurrent-ruby (~> 1.0)
158
+ webpacker (5.4.3)
159
+ activesupport (>= 5.2)
160
+ rack-proxy (>= 0.6.1)
161
+ railties (>= 5.2)
162
+ semantic_range (>= 2.3.0)
163
+ websocket-driver (0.7.5)
164
+ websocket-extensions (>= 0.1.0)
165
+ websocket-extensions (0.1.5)
166
+ zeitwerk (2.6.6)
167
+
168
+ PLATFORMS
169
+ ruby
170
+
171
+ DEPENDENCIES
172
+ webpacker-pnpm!
173
+
174
+ BUNDLED WITH
175
+ 1.17.3
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
3
+ require_relative "config/application"
4
4
  require "rake/testtask"
5
5
 
6
+ Rails.application.load_tasks
6
7
  Rake::TestTask.new do |t|
7
8
  t.libs << "test"
8
9
  t.test_files = FileList["test/**/*_test.rb"]
@@ -0,0 +1,10 @@
1
+ /* eslint no-console:0 */
2
+ // This file is automatically compiled by Webpack, along with any other files
3
+ // present in this directory. You're encouraged to place your actual application logic
4
+ // in a relevant structure within app/javascript and only use these pack files to
5
+ // reference that code so it'll be compiled.
6
+ //
7
+ // To reference this file, add <%= javascript_pack_tag 'application' %> to the
8
+ // appropriate layout file, like app/views/layouts/application.html.erb
9
+
10
+ console.log('"Hello Sanity" from webpacker-pnpm!');
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -5,7 +5,9 @@
5
5
  "license": "CC-BY-NC-SA-4.0",
6
6
  "private": true,
7
7
  "dependencies": {
8
- "left-pad": "^1.2.0"
8
+ "@rails/webpacker": "^5.4.3",
9
+ "left-pad": "^1.2.0",
10
+ "webpack": "^5.75.0"
9
11
  },
10
12
  "devDependencies": {
11
13
  "right-pad": "^1.0.1"