webpacker-pnpm 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +0 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/workflows/ci.yaml +51 -0
- data/.gitignore +3 -5
- data/.rubocop.yml +23 -5
- data/CHANGELOG.md +76 -63
- data/Gemfile +8 -8
- data/LICENSE +29 -0
- data/README.md +44 -37
- data/bin/console +15 -15
- data/bin/setup +8 -8
- data/gemfiles/Gemfile-rails.5.2.x +0 -0
- data/gemfiles/Gemfile-rails.6.0.x +0 -0
- data/lib/webpacker/pnpm/patches.rb +83 -53
- data/lib/webpacker/pnpm/railtie.rb +34 -33
- data/lib/webpacker/pnpm/version.rb +9 -9
- data/lib/webpacker/pnpm.rb +5 -5
- data/lib/webpacker/tasks/check_pnpm.rake +42 -42
- data/lib/webpacker/tasks/env.rake +22 -22
- data/lib/webpacker/tasks/pnpm_install.rake +14 -14
- data/test_app/.gitignore +6 -0
- data/test_app/Gemfile +5 -0
- data/test_app/Gemfile.lock +175 -0
- data/{Rakefile → test_app/Rakefile} +12 -11
- data/test_app/app/javascript/packs/application.js +10 -0
- data/{test/test_app → test_app}/app/javascript/packs/multi_entry.css +3 -3
- data/{test/test_app → test_app}/app/javascript/packs/multi_entry.js +4 -4
- data/{test/test_app → test_app}/bin/rails +0 -0
- data/{test/test_app → test_app}/bin/rake +0 -0
- data/{test/test_app → test_app}/bin/setup +0 -0
- data/{test/test_app → test_app}/bin/webpack +15 -15
- data/{test/test_app → test_app}/bin/webpack-dev-server +15 -15
- data/{test/test_app → test_app}/config/application.rb +13 -13
- data/{test/test_app → test_app}/config/boot.rb +5 -5
- data/{test/test_app → test_app}/config/environment.rb +6 -6
- data/{test/test_app → test_app}/config/webpack/development.js +0 -0
- data/{test/test_app → test_app}/config/webpack/environment.js +0 -0
- data/test_app/config/webpack/production.js +0 -0
- data/{test/test_app → test_app}/config/webpacker.yml +0 -0
- data/{test/test_app → test_app}/config/webpacker_public_root.yml +19 -19
- data/{test/test_app → test_app}/config.ru +7 -7
- data/{test/test_app → test_app}/package.json +3 -1
- data/test_app/pnpm-lock.yaml +6756 -0
- data/{test/test_app → test_app}/public/packs/manifest.json +31 -31
- data/test_app/src/index.js +0 -0
- data/{test → test_app/test}/rake_tasks_test.rb +108 -97
- data/{test → test_app/test}/test_helper.rb +61 -61
- data/webpacker-pnpm.gemspec +44 -44
- metadata +41 -59
- data/.travis.yml +0 -42
- data/test/test_app/.gitignore +0 -7
- data/test/test_app/Rakefile +0 -5
- data/test/test_app/app/javascript/packs/application.js +0 -10
- data/test/test_app/pnpm-lock.yaml +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85df72b48e172802a711481f7f54ea75410cde46e7df8a68e2dd8f1772faa711
|
4
|
+
data.tar.gz: b82b39eb173396c7bb03b49a934a1e9811d2c82a9d608a7ef00ea33565424dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e121ebbbb865ba38282969ea40d278964ebfec79109e9287c90e2d8cc0898ceeef34a58cbc1906d341f032308f7958985183bfc4f0fc73a4a1ed3ffbd061ff3a
|
7
|
+
data.tar.gz: 95a7cf3b7e5b59e9db88aeacfedf98590e10cdf288029755925895107e06f6ec402292983533faf1cdd3d2058b870f8254bd8d9e21a9ebe23187e8817edb93a3
|
data/.gitattributes
CHANGED
File without changes
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
fail-fast: false
|
9
|
+
matrix:
|
10
|
+
ruby: [ '2.4', '2.5', '2.6', '2.7' ]
|
11
|
+
gemfile: [ '5.2.x', '6.0.x' ]
|
12
|
+
exclude:
|
13
|
+
- ruby: '2.4'
|
14
|
+
gemfile: '6.0.x'
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
env:
|
17
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/Gemfile-rails.${{ matrix.gemfile }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v3
|
20
|
+
- name: Setup Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- name: Setup Node
|
26
|
+
uses: actions/setup-node@v3
|
27
|
+
with:
|
28
|
+
node-version: 14
|
29
|
+
- name: Setup pnpm
|
30
|
+
uses: pnpm/action-setup@v2
|
31
|
+
id: pnpm-install
|
32
|
+
with:
|
33
|
+
version: 7
|
34
|
+
run_install: false
|
35
|
+
- name: Define pnpm cache
|
36
|
+
id: pnpm-cache
|
37
|
+
shell: bash
|
38
|
+
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
39
|
+
- uses: actions/cache@v3
|
40
|
+
with:
|
41
|
+
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
42
|
+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
43
|
+
restore-keys: |
|
44
|
+
${{ runner.os }}-pnpm-store-
|
45
|
+
- name: Check formatting and syntax
|
46
|
+
run: bundle exec rubocop
|
47
|
+
- name: Run tests
|
48
|
+
working-directory: ./test_app
|
49
|
+
run: |
|
50
|
+
pnpm i --frozen-lockfile --shamefully-hoist
|
51
|
+
bundle exec rake test
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# RuboCop is a Ruby static code analyzer and code formatter that tries to enforce many
|
3
|
-
# the guidelines outlined in the community Ruby and Rails
|
4
|
-
# style guides.
|
2
|
+
# RuboCop is a Ruby static code analyzer and code formatter that tries to enforce many
|
3
|
+
# of the guidelines outlined in the community Ruby and Rails style guides.
|
5
4
|
#
|
6
5
|
# https://docs.rubocop.org/en/latest/
|
7
6
|
# https://rubystyle.guide/
|
@@ -15,11 +14,30 @@ inherit_mode:
|
|
15
14
|
- IgnoredMethods
|
16
15
|
- AllowedMethods
|
17
16
|
|
18
|
-
# cop-specific excludes are not inherited for some reason (likely a bug in RuboCop) so
|
19
|
-
# need to manually re-omit the intended files and directories.
|
17
|
+
# cop-specific excludes are not inherited for some reason (likely a bug in RuboCop) so
|
18
|
+
# we need to manually re-omit the intended files and directories.
|
20
19
|
Layout/LineLength:
|
20
|
+
Max: 88
|
21
21
|
Exclude:
|
22
22
|
- "**/config/initializers/**/*"
|
23
23
|
Style/MethodCallWithArgsParentheses:
|
24
24
|
Exclude:
|
25
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
@@ -1,63 +1,76 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
|
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
|
-
|
7
|
-
## [v1.2.
|
8
|
-
|
9
|
-
###
|
10
|
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
###
|
35
|
-
|
36
|
-
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
-
|
53
|
-
-
|
54
|
-
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
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
|
+
|
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
|
+
|
14
|
+
## [v1.2.2] - 2023-01-13
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- Watched paths for cross-version compatibility. (credit: [HipsterBrown](https://github.com/thearchitector/webpacker-pnpm/pull/4))
|
19
|
+
|
20
|
+
## [v1.2.1] - 2020-05-16
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- Informative error messages when pnpm is not installed.
|
25
|
+
- Pessimistic gem dependency version specifications to avoid installation conflicts.
|
26
|
+
- Full-length gem description.
|
27
|
+
- Forced shameful hoisting of installed pnpm dependencies via `webpacker:pnpm_install`.
|
28
|
+
- Practical Pig development dependency for external RuboCop linting.
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
- Commented and adjusted RuboCop formatting rules to clarify design decisions.
|
33
|
+
|
34
|
+
### Removed
|
35
|
+
|
36
|
+
- Testing configs for bleeding-edge Rails.
|
37
|
+
|
38
|
+
## [v1.2.0] - 2020-05-14
|
39
|
+
|
40
|
+
### Added
|
41
|
+
|
42
|
+
- Compatibility with Rails' Template API via command execution hooks and keyword substitution.
|
43
|
+
- Support for existing Yarn Rake task dependence through task aliasing and redirection.
|
44
|
+
- Additional Rake tasks to test injection and interception logic.
|
45
|
+
- Utility method for concurrent and scoped `chdir` calls.
|
46
|
+
|
47
|
+
### Changed
|
48
|
+
|
49
|
+
- Gem dependencies to reflect up-to-date versions.
|
50
|
+
- RuboCop formatting rules to support latest versions of Ruby.
|
51
|
+
- Test application structure to allow application booting.
|
52
|
+
- Rake task tests to utilize concurrent `chdir` calls.
|
53
|
+
- Tests to support Rails <6.x `[bugfix]`.
|
54
|
+
- Tests to support Ruby 2.4.9 `[bugfix]`.
|
55
|
+
|
56
|
+
### Removed
|
57
|
+
|
58
|
+
- Webpacker git submodule as method for replacing default Rails' rake tasks.
|
59
|
+
- Dependence on a specific version of Webpacker.
|
60
|
+
|
61
|
+
## [v1.1.0] - 2020-04-19
|
62
|
+
|
63
|
+
### Changed
|
64
|
+
|
65
|
+
- RuboCop formatting rules to more align with Rails' style guide.
|
66
|
+
- TypeScript installation tasks based on Webpacker v5.1.0.
|
67
|
+
- Rake tasks to extend ActiveSupport and utilize concurrent threading.
|
68
|
+
|
69
|
+
## [v1.0.0] - 2020-04-17
|
70
|
+
|
71
|
+
### Added
|
72
|
+
|
73
|
+
- Gem specifications and foundational files, generated by Bundler v2.0.2, for defining a Ruby gem.
|
74
|
+
- Hook into Rails' engine loader for conditional task loading.
|
75
|
+
- Tasks replacing Yarn with pnpm for Webpacker v5.0.1, included as a submodule.
|
76
|
+
- Test suite with dummy application.
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
install_if -> { Gem.win_platform? } do
|
7
|
-
gem "tzinfo-data"
|
8
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
install_if -> { Gem.win_platform? } do
|
7
|
+
gem "tzinfo-data"
|
8
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
BSD 3-Clause License
|
2
|
+
|
3
|
+
Copyright (c) 2023, Elias Gabriel
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
8
|
+
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
10
|
+
list of conditions and the following disclaimer.
|
11
|
+
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
14
|
+
and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
17
|
+
contributors may be used to endorse or promote products derived from
|
18
|
+
this software without specific prior written permission.
|
19
|
+
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,37 +1,44 @@
|
|
1
|
-
# webpacker-pnpm
|
2
|
-
|
3
|
-
[![version](https://img.shields.io/gem/v/webpacker-pnpm?label=version&style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
|
4
|
-
[![status](https://img.shields.io/
|
5
|
-
[![downloads](https://img.shields.io/gem/dt/webpacker-pnpm?style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
|
6
|
-
[![license](https://img.shields.io/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
-
|
18
|
-
- Provides code sanity without the migraines
|
19
|
-
- Gives you more disk space
|
20
|
-
|
21
|
-
## Installation
|
22
|
-
|
23
|
-
In order to use `webpacker-pnpm`, you must install `pnpm`. The official instructions are [here](https://pnpm.
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
```
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
```
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
1
|
+
# webpacker-pnpm
|
2
|
+
|
3
|
+
[![version](https://img.shields.io/gem/v/webpacker-pnpm?label=version&style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
|
4
|
+
[![status](https://img.shields.io/github/actions/workflow/status/thearchitector/webpacker-pnpm/ci.yaml?label=tests&style=flat-square)](https://travis-ci.org/github/thearchitector/webpacker-pnpm)
|
5
|
+
[![downloads](https://img.shields.io/gem/dt/webpacker-pnpm?style=flat-square)](https://rubygems.org/gems/webpacker-pnpm)
|
6
|
+
[![license](https://img.shields.io/github/license/thearchitector/webpacker-pnpm?style=flat-square)](LICENSE)
|
7
|
+
[![Buy a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen?style=flat-square)](https://ecologi.com/eliasgabriel?r=6128126916bfab8bd051026c)
|
8
|
+
|
9
|
+
`webpacker-pnpm` replaces Rails' Yarn environment with [pnpm](https://pnpm.io), a better, smarter, and more efficient Node.js package manager. As a result, applications become less prone to dependency hell, more functional, more stable, and more flexible. And as an added bonus, dependency resolution times and `node_modules` folder sizes reduce to within reasonable ranges (not 45 seconds and 10 GiB).
|
10
|
+
|
11
|
+
You can read about the philosophy and technology behind `pnpm` in [this convincing blog post](https://www.kochan.io/nodejs/why-should-we-use-pnpm) by Zoltan Kochan (<https://www.kochan.io/nodejs/why-should-we-use-pnpm>).
|
12
|
+
|
13
|
+
## Features
|
14
|
+
|
15
|
+
- Production-ready
|
16
|
+
- Drop-in replacement for Yarn
|
17
|
+
- Supports Rails' Template API, including existing templates using Yarn
|
18
|
+
- Provides code sanity without the migraines
|
19
|
+
- Gives you more disk space
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
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`.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem "webpacker-pnpm"
|
29
|
+
```
|
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
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
This software is licensed under the [BSD 3-Clause License](LICENSE).
|
43
|
+
|
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.
|
data/bin/console
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "webpacker/pnpm"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "webpacker/pnpm"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
File without changes
|
File without changes
|
@@ -1,53 +1,83 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "
|
4
|
-
require "webpacker/
|
5
|
-
require "
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
"
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "webpacker/compiler"
|
4
|
+
require "webpacker/webpack_runner"
|
5
|
+
require "rails/generators"
|
6
|
+
require "rails/engine"
|
7
|
+
|
8
|
+
module Webpacker
|
9
|
+
module PNPM
|
10
|
+
# remove Yarn's lockfile from and add pnpm's lockfile to the default list of
|
11
|
+
# watched paths
|
12
|
+
Webpacker::Compiler.class_eval do
|
13
|
+
def default_watched_paths
|
14
|
+
[
|
15
|
+
*configured_paths,
|
16
|
+
config.source_path_globbed,
|
17
|
+
"pnpm-lock.yaml", "package.json",
|
18
|
+
"config/webpack/**/*"
|
19
|
+
].freeze
|
20
|
+
end
|
21
|
+
|
22
|
+
def configured_paths
|
23
|
+
if config.respond_to?(:additional_paths_globbed)
|
24
|
+
config.additional_paths_globbed
|
25
|
+
else
|
26
|
+
config.resolved_paths_globbed
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
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
|
+
|
52
|
+
# intercept command execution via Thor to replace yarn with pnpm. this exists in
|
53
|
+
# order to patch existing Webpacker installation templates that make direct
|
54
|
+
# calls to install Yarn dependencies. as a result, this isn't a robust patch
|
55
|
+
Rails::Generators::Actions.module_eval do
|
56
|
+
def run(command, config = {})
|
57
|
+
cmd = command.to_s
|
58
|
+
|
59
|
+
if cmd.include?("yarn")
|
60
|
+
cmd.gsub!("yarn", "pnpm")
|
61
|
+
cmd.gsub!("--dev", "--save-dev")
|
62
|
+
end
|
63
|
+
|
64
|
+
super(cmd, config)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# intercept generic task loading to clear and alias Yarn tasks
|
69
|
+
Rails::Engine.class_eval do
|
70
|
+
alias_method :unfiltered_tasks, :load_tasks
|
71
|
+
|
72
|
+
def load_tasks(_app = self)
|
73
|
+
unfiltered_tasks
|
74
|
+
# rather than clear the tasks, alias them to the new pnpm tasks so
|
75
|
+
# that any external code will still run
|
76
|
+
Rake::Task["webpacker:check_yarn"].clear.enhance(["webpacker:check_pnpm"])
|
77
|
+
Rake::Task["webpacker:yarn_install"].clear.enhance(["webpacker:pnpm_install"])
|
78
|
+
Rake::Task["webpacker:info"].clear.enhance(["webpacker:env"])
|
79
|
+
Rake::Task["yarn:install"].clear.enhance(["webpacker:pnpm_install"])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|