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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the combined jsbundling-rails gem instead of individual js bundler gems #43172

Merged
merged 3 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem "selenium-webdriver", ">= 4.0.0.alpha7"
gem "rack-cache", "~> 1.2"
gem "stimulus-rails"
gem "turbo-rails"
gem "webpacker", "~> 6.0.0.rc.5", require: ENV["SKIP_REQUIRE_WEBPACKER"] != "true"
gem "jsbundling-rails"
gem "importmap-rails"
# require: false so bcrypt is loaded only when has_secure_password is used.
# This is to avoid Active Model (and by extension the entire framework)
Expand Down
20 changes: 7 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ PATH
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.5.0.beta3)
rails (7.0.0.alpha)
actioncable (= 7.0.0.alpha)
actionmailbox (= 7.0.0.alpha)
Expand All @@ -103,6 +102,7 @@ PATH
method_source
rake (>= 0.13)
thor (~> 1.0)
zeitwerk (~> 2.5.0.beta3)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -286,9 +286,11 @@ GEM
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
importmap-rails (0.5.0)
importmap-rails (0.5.1)
rails (>= 6.0.0)
jmespath (1.4.0)
jsbundling-rails (0.1.0)
rails (>= 6.0.0)
json (2.5.1)
jwt (2.2.3)
kindlerb (1.2.0)
Expand Down Expand Up @@ -354,8 +356,6 @@ GEM
rack (>= 0.4)
rack-protection (2.1.0)
rack
rack-proxy (0.7.0)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
Expand Down Expand Up @@ -428,7 +428,6 @@ GEM
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2)
rubyzip (>= 1.2.2)
semantic_range (3.0.0)
sequel (5.45.0)
serverengine (2.0.7)
sigdump (~> 0.2.2)
Expand Down Expand Up @@ -467,7 +466,7 @@ GEM
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
stackprof (0.2.17)
stimulus-rails (0.4.0)
stimulus-rails (0.4.2)
rails (>= 6.0.0)
sucker_punch (3.0.1)
concurrent-ruby (~> 1.0)
Expand All @@ -480,7 +479,7 @@ GEM
thor (1.1.0)
tilt (2.0.10)
trailblazer-option (0.1.1)
turbo-rails (0.7.10)
turbo-rails (0.7.11)
rails (>= 6.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
Expand All @@ -501,11 +500,6 @@ GEM
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpacker (6.0.0.rc.5)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
webrick (1.7.0)
websocket (1.2.9)
websocket-driver (0.7.5)
Expand Down Expand Up @@ -543,6 +537,7 @@ DEPENDENCIES
hiredis
image_processing (~> 1.2)
importmap-rails
jsbundling-rails
json (>= 2.0.0)
kindlerb (~> 1.2.0)
libxml-ruby
Expand Down Expand Up @@ -590,7 +585,6 @@ DEPENDENCIES
wdm (>= 0.1.0)
webdrivers
webmock
webpacker (~> 6.0.0.rc.5)
webrick
websocket-client-simple!

Expand Down
1 change: 0 additions & 1 deletion activejob/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ namespace :test do

task "env:integration" do
ENV["AJ_INTEGRATION_TESTS"] = "1"
ENV["SKIP_REQUIRE_WEBPACKER"] = "true"
end

ACTIVEJOB_ADAPTERS.each do |adapter|
Expand Down
14 changes: 4 additions & 10 deletions railties/lib/rails/generators/app_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,8 @@ def javascript_gemfile_entry
case options[:javascript]
when "importmap"
GemfileEntry.version("importmap-rails", ">= 0.3.4", "Manage modern JavaScript using ESM without transpiling or bundling")
when "webpack"
GemfileEntry.version "webpacker", "~> 6.0.0.rc.5", "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
when "esbuild"
GemfileEntry.version "esbuild-rails", "~> 0.1.2", "Transpile app-like JavaScript. Read more: https://github.com/rails/esbuild-rails"
when "rollup"
GemfileEntry.version "rollupjs-rails", "~> 0.1.0", "Transpile app-like JavaScript. Read more: https://github.com/rails/rollupjs-rails"
when "webpack", "esbuild", "rollup"
GemfileEntry.version "jsbundling-rails", "~> 0.1.0", "Bundle and transpile JavaScript with esbuild, rollup.js, or Webpack. Read more: https://github.com/rails/jsbundling-rails"
else
raise "Unknown JavaScript approach: #{options[:javascript]} [options are: importmap, webpack, esbuild, rollup]"
end
Expand Down Expand Up @@ -381,10 +377,8 @@ def run_javascript
return if options[:skip_javascript] || !bundle_install?

case options[:javascript]
when "importmap" then rails_command "importmap:install"
when "webpack" then rails_command "webpacker:install"
when "esbuild" then rails_command "esbuild:install"
when "rollup" then rails_command "rollup:install"
when "importmap" then rails_command "importmap:install"
when "webpack", "esbuild", "rollup" then rails_command "javascript:install:#{options[:javascript]}"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ def create_dummy_app(path = nil)
mute do
build(:generate_test_dummy)
build(:test_dummy_config)
build(:test_dummy_webpacker_assets)
build(:test_dummy_sprocket_assets) unless options[:skip_sprockets]
build(:test_dummy_clean)
# ensure that bin/rails has proper dummy_path
Expand Down
3 changes: 1 addition & 2 deletions railties/test/engine/commands_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_help_command_work_inside_engine

def test_runner_command_work_inside_engine
output = capture(:stdout) do
Dir.chdir(plugin_path) { system({ "SKIP_REQUIRE_WEBPACKER" => "true" }, "bin/rails runner 'puts Rails.env'") }
Dir.chdir(plugin_path) { system("bin/rails runner 'puts Rails.env'") }
end

assert_equal "test", output.strip
Expand Down Expand Up @@ -68,7 +68,6 @@ def plugin_path

def spawn_command(command, fd)
Process.spawn(
{ "SKIP_REQUIRE_WEBPACKER" => "true" },
"#{plugin_path}/bin/rails #{command}",
in: fd, out: fd, err: fd
)
Expand Down
14 changes: 3 additions & 11 deletions railties/test/generators/app_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
# brings setup, teardown, and some tests
include SharedGeneratorTests

setup do
ENV["SKIP_REQUIRE_WEBPACKER"] = "true"
end

teardown do
ENV["SKIP_REQUIRE_WEBPACKER"] = nil
end

def default_files
::DEFAULT_APP_FILES
end
Expand Down Expand Up @@ -791,7 +783,7 @@ def test_webpack_option
webpacker_called = 0
command_check = -> command, *_ do
case command
when "webpacker:install"
when "javascript:install:webpack"
webpacker_called += 1
end
end
Expand All @@ -800,8 +792,8 @@ def test_webpack_option
run_generator_instance
end

assert_equal 1, webpacker_called, "`webpacker:install` expected to be called once, but was called #{webpacker_called} times."
assert_gem "webpacker"
assert_equal 1, webpacker_called, "`javascript:install:webpack` expected to be called once, but was called #{webpacker_called} times."
assert_gem "jsbundling-rails"
end

def test_hotwire
Expand Down