Skip to content

Commit

Permalink
Clean up duplicated yarn install (shakacode#238)
Browse files Browse the repository at this point in the history
1. Redefinition of yarn:install caused yarn to run twice ALWAYS as Rails
   already does trigger a yarn install
2. Removed code no longer needed as Rails 5.2 is the oldest version
   supported.
  • Loading branch information
justin808 authored Jan 16, 2023
1 parent 6c3ef9c commit d94ab9d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 55 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Changes since last non-beta release.

_Please add entries here for your pull requests that are not yet released._

## [6.5.6] - January 15, 2023
### Fixed
- Remove duplicate yarn installs. [PR 238](https://github.com/shakacode/shakapacker/pull/238) by [justin808](https://github/justin808).
- Remove unneeded code related to CSP config for generator. [PR 223](https://github.com/shakacode/shakapacker/pull/223) by [ahangarha](https://github/ahangarha).

## [v6.5.5] - December 28, 2022

### Improved
Expand Down Expand Up @@ -193,7 +198,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
## v5.4.3 and prior changes from rails/webpacker
See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)

[Unreleased]: https://github.com/shakacode/shakapacker/compare/v6.5.5...master
[Unreleased]: https://github.com/shakacode/shakapacker/compare/v6.5.6...master
[v6.5.6]: https://github.com/shakacode/shakapacker/compare/v6.5.5...v6.5.6
[v6.5.5]: https://github.com/shakacode/shakapacker/compare/v6.5.4...v6.5.5
[v6.5.4]: https://github.com/shakacode/shakapacker/compare/v6.5.3...v6.5.4
[v6.5.3]: https://github.com/shakacode/shakapacker/compare/v6.5.2...v6.5.3
Expand Down
15 changes: 5 additions & 10 deletions lib/tasks/webpacker/compile.rake
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
$stdout.sync = true

def yarn_install_available?
rails_major = Rails::VERSION::MAJOR
rails_minor = Rails::VERSION::MINOR

rails_major > 5 || (rails_major == 5 && rails_minor >= 1)
end

def enhance_assets_precompile
# yarn:install was added in Rails 5.1
deps = yarn_install_available? ? [] : ["webpacker:yarn_install"]
Rake::Task["assets:precompile"].enhance(deps) do |task|
Rake::Task["assets:precompile"].enhance do |task|
prefix = task.name.split(/#|assets:precompile/).first

Rake::Task["#{prefix}webpacker:compile"].invoke
Expand All @@ -35,8 +26,12 @@ end

if Webpacker.config.webpacker_precompile?
if Rake::Task.task_defined?("assets:precompile")
# Rails already adds `yarn install` after 5.2
# https://github.com/shakacode/shakapacker/issues/237
enhance_assets_precompile
else
# Only add `yarn install` if Rails was not doing it (precompile was not defined).
# TODO: Remove this in Shakapacker 7.0
Rake::Task.define_task("assets:precompile" => ["webpacker:yarn_install", "webpacker:compile"])
end
end
44 changes: 0 additions & 44 deletions lib/tasks/yarn.rake

This file was deleted.

0 comments on commit d94ab9d

Please sign in to comment.