Skip to content

Commit 3e2f74c

Browse files
authored
Call yarn directly (#43641)
* Remove the assets:precompile dependency on yarn:install Since yarn isn't required for Rails 7, assets:precompile should not depend on it by default. Instead, tasks for webpacker, jsbundling-rails, cssbundling-rails, etc should depend on yarn:install on their own. * In yarn:install, call `yarn` instead of `bin/yarn` Change to calling `yarn` directly (via PATH) as `bin/yarn` is no longer a part of Rails 7.
1 parent 26e89c7 commit 3e2f74c

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎railties/lib/rails/tasks/yarn.rake‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,20 @@ namespace :yarn do
1010
end
1111

1212
yarn_flags =
13-
if `#{RbConfig.ruby} "#{Rails.root}/bin/yarn" --version`.start_with?("1")
13+
if `yarn --version`.start_with?("1")
1414
"--no-progress --frozen-lockfile"
1515
else
1616
"--immutable"
1717
end
1818

1919
system(
2020
{ "NODE_ENV" => node_env },
21-
"#{RbConfig.ruby} \"#{Rails.root}/bin/yarn\" install #{yarn_flags}",
21+
"yarn install #{yarn_flags}",
2222
exception: true
2323
)
2424
rescue Errno::ENOENT
25-
$stderr.puts "bin/yarn was not found."
26-
$stderr.puts "Please run `bundle exec rails app:update:bin` to create it."
25+
$stderr.puts "yarn install failed to execute."
26+
$stderr.puts "Ensure yarn is installed and `yarn --version` runs without errors."
2727
exit 1
2828
end
2929
end
30-
31-
# Run Yarn prior to Sprockets assets precompilation, so dependencies are available for use.
32-
if Rake::Task.task_defined?("assets:precompile") && File.exist?(Rails.root.join("bin", "yarn"))
33-
Rake::Task["assets:precompile"].enhance [ "yarn:install" ]
34-
end

0 commit comments

Comments
 (0)