Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Yarn v3 for stable webpacker 5.x gem #3098

Merged
merged 11 commits into from Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions .github/workflows/ruby.yml
Expand Up @@ -29,14 +29,6 @@ jobs:
gemfile: gemfiles/Gemfile-rails.6.0.x
experimental: [false]
include:
- ruby: 2.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guillaumebriday Because Rails 7.0.0-alpha (edge) does not support ruby 2.5 and 2.6, only 2.7+ 馃憤

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so these removes can be done in other PR separately, only that change context to rails 7. What do you think about that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it's should not be in this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that branch 5-x-stable does not receive frequent changes, and that this PR is small enough to be understood well (despite CI fixes be together with adding of Yarn v3), can we merge it? 馃嵒

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrofurtado sounds like the preferred way forward is for you to pull the workflow changes out of this PR, focus it 馃挴 on just bringing yarn v3 support in for a quick merge....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR splitted in two: this that provides yarn 3 support, and other that fixes CI ( #3106 )

os: ubuntu-latest
gemfile: gemfiles/Gemfile-rails-edge
experimental: true
- ruby: 2.6
os: ubuntu-latest
gemfile: gemfiles/Gemfile-rails-edge
experimental: true
- ruby: 2.7
os: ubuntu-latest
gemfile: gemfiles/Gemfile-rails-edge
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/Gemfile-rails-edge
Expand Up @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

gemspec path: "../"

gem "rails", github: "rails/rails"
gem "rails", github: "rails/rails", branch: "main"
gem "arel", github: "rails/arel"
gem "rake", ">= 11.1"
gem "rack-proxy", require: false
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/webpacker/check_yarn.rake
Expand Up @@ -9,7 +9,7 @@ namespace :webpacker do
pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath
yarn_range = JSON.parse(pkg_path.read)["engines"]["yarn"]
is_valid = SemanticRange.satisfies?(yarn_version, yarn_range) rescue false
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=3.0.0") rescue false
is_unsupported = SemanticRange.satisfies?(yarn_version, ">=4.0.0") rescue false

unless is_valid
$stderr.puts "Webpacker requires Yarn \"#{yarn_range}\" and you are using #{yarn_version}"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
],
"engines": {
"node": ">=10.17.0",
"yarn": ">=1 <3"
"yarn": ">=1 <4"
},
"dependencies": {
"@babel/core": "^7.14.3",
Expand Down
30 changes: 21 additions & 9 deletions test/helper_test.rb
Expand Up @@ -117,29 +117,41 @@ def test_preload_pack_asset
end

def test_stylesheet_pack_tag_split_chunks
assert_equal \
%(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
assert_equal stylesheet_packs_with_chunks_tag("application", "hello_stimulus").in?([
%(<link rel="stylesheet" href="/packs/1-c20632e7baf2c81200d3.chunk.css" media="screen" />\n) +
%(<link rel="stylesheet" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" media="screen" />\n) +
%(<link rel="stylesheet" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" media="screen" />),

%(<link rel="stylesheet" media="screen" href="/packs/1-c20632e7baf2c81200d3.chunk.css" />\n) +
%(<link rel="stylesheet" media="screen" href="/packs/application-k344a6d59eef8632c9d1.chunk.css" />\n) +
%(<link rel="stylesheet" media="screen" href="/packs/hello_stimulus-k344a6d59eef8632c9d1.chunk.css" />),
stylesheet_packs_with_chunks_tag("application", "hello_stimulus")
]),
true
end

def test_stylesheet_pack_tag
assert_equal \
assert_equal stylesheet_pack_tag("bootstrap.css").in?([
%(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),

%(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
stylesheet_pack_tag("bootstrap.css")
]), true
end

def test_stylesheet_pack_tag_symbol
assert_equal \
assert_equal stylesheet_pack_tag(:bootstrap).in?([
%(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="screen" />),

%(<link rel="stylesheet" media="screen" href="/packs/bootstrap-c38deda30895059837cf.css" />),
stylesheet_pack_tag(:bootstrap)
]), true
end

def test_stylesheet_pack_tag_splat
assert_equal \
assert_equal stylesheet_pack_tag("bootstrap.css", "application.css", media: "all").in?([
%(<link rel="stylesheet" href="/packs/bootstrap-c38deda30895059837cf.css" media="all" />\n) +
%(<link rel="stylesheet" href="/packs/application-dd6b1cd38bfa093df600.css" media="all" />),

%(<link rel="stylesheet" media="all" href="/packs/bootstrap-c38deda30895059837cf.css" />\n) +
%(<link rel="stylesheet" media="all" href="/packs/application-dd6b1cd38bfa093df600.css" />),
stylesheet_pack_tag("bootstrap.css", "application.css", media: "all")
]), true
end
end