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

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

* Remove Webpacker remnants

* Replace webpacker with jsbundling-rails
This commit is contained in:
David Heinemeier Hansson 2021-09-06 16:44:44 +02:00 committed by GitHub
parent 532ef0d13c
commit 7595c922a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 39 deletions

View File

@ -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)

View File

@ -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)
@ -103,6 +102,7 @@ PATH
method_source
rake (>= 0.13)
thor (~> 1.0)
zeitwerk (~> 2.5.0.beta3)
GEM
remote: https://rubygems.org/
@ -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)
@ -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)
@ -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)
@ -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)
@ -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)
@ -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)
@ -543,6 +537,7 @@ DEPENDENCIES
hiredis
image_processing (~> 1.2)
importmap-rails
jsbundling-rails
json (>= 2.0.0)
kindlerb (~> 1.2.0)
libxml-ruby
@ -590,7 +585,6 @@ DEPENDENCIES
wdm (>= 0.1.0)
webdrivers
webmock
webpacker (~> 6.0.0.rc.5)
webrick
websocket-client-simple!

View File

@ -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|

View File

@ -296,12 +296,8 @@ module Rails
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
@ -381,10 +377,8 @@ module Rails
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

View File

@ -316,7 +316,6 @@ module Rails
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

View File

@ -24,7 +24,7 @@ class Rails::Engine::CommandsTest < ActiveSupport::TestCase
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
@ -68,7 +68,6 @@ class Rails::Engine::CommandsTest < ActiveSupport::TestCase
def spawn_command(command, fd)
Process.spawn(
{ "SKIP_REQUIRE_WEBPACKER" => "true" },
"#{plugin_path}/bin/rails #{command}",
in: fd, out: fd, err: fd
)

View File

@ -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
@ -791,7 +783,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
webpacker_called = 0
command_check = -> command, *_ do
case command
when "webpacker:install"
when "javascript:install:webpack"
webpacker_called += 1
end
end
@ -800,8 +792,8 @@ class AppGeneratorTest < Rails::Generators::TestCase
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