Skip to content

Commit 7595c92

Browse files
author
David Heinemeier Hansson
authored
Use the combined jsbundling-rails gem instead of individual js bundler gems (rails#43172)
* Use the combined jsbundling-rails gem instead of individual js bundler gems * Remove Webpacker remnants * Replace webpacker with jsbundling-rails
1 parent 532ef0d commit 7595c92

File tree

7 files changed

+16
-39
lines changed

7 files changed

+16
-39
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ gem "selenium-webdriver", ">= 4.0.0.alpha7"
1515
gem "rack-cache", "~> 1.2"
1616
gem "stimulus-rails"
1717
gem "turbo-rails"
18-
gem "webpacker", "~> 6.0.0.rc.5", require: ENV["SKIP_REQUIRE_WEBPACKER"] != "true"
18+
gem "jsbundling-rails"
1919
gem "importmap-rails"
2020
# require: false so bcrypt is loaded only when has_secure_password is used.
2121
# This is to avoid Active Model (and by extension the entire framework)

Gemfile.lock

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ PATH
8181
i18n (>= 1.6, < 2)
8282
minitest (>= 5.1)
8383
tzinfo (~> 2.0)
84-
zeitwerk (~> 2.5.0.beta3)
8584
rails (7.0.0.alpha)
8685
actioncable (= 7.0.0.alpha)
8786
actionmailbox (= 7.0.0.alpha)
@@ -103,6 +102,7 @@ PATH
103102
method_source
104103
rake (>= 0.13)
105104
thor (~> 1.0)
105+
zeitwerk (~> 2.5.0.beta3)
106106

107107
GEM
108108
remote: https://rubygems.org/
@@ -286,9 +286,11 @@ GEM
286286
image_processing (1.12.1)
287287
mini_magick (>= 4.9.5, < 5)
288288
ruby-vips (>= 2.0.17, < 3)
289-
importmap-rails (0.5.0)
289+
importmap-rails (0.5.1)
290290
rails (>= 6.0.0)
291291
jmespath (1.4.0)
292+
jsbundling-rails (0.1.0)
293+
rails (>= 6.0.0)
292294
json (2.5.1)
293295
jwt (2.2.3)
294296
kindlerb (1.2.0)
@@ -354,8 +356,6 @@ GEM
354356
rack (>= 0.4)
355357
rack-protection (2.1.0)
356358
rack
357-
rack-proxy (0.7.0)
358-
rack
359359
rack-test (1.1.0)
360360
rack (>= 1.0, < 3)
361361
rails-dom-testing (2.0.3)
@@ -428,7 +428,6 @@ GEM
428428
childprocess (>= 0.5, < 5.0)
429429
rexml (~> 3.2)
430430
rubyzip (>= 1.2.2)
431-
semantic_range (3.0.0)
432431
sequel (5.45.0)
433432
serverengine (2.0.7)
434433
sigdump (~> 0.2.2)
@@ -467,7 +466,7 @@ GEM
467466
sprockets (>= 3.0.0)
468467
sqlite3 (1.4.2)
469468
stackprof (0.2.17)
470-
stimulus-rails (0.4.0)
469+
stimulus-rails (0.4.2)
471470
rails (>= 6.0.0)
472471
sucker_punch (3.0.1)
473472
concurrent-ruby (~> 1.0)
@@ -480,7 +479,7 @@ GEM
480479
thor (1.1.0)
481480
tilt (2.0.10)
482481
trailblazer-option (0.1.1)
483-
turbo-rails (0.7.10)
482+
turbo-rails (0.7.11)
484483
rails (>= 6.0.0)
485484
tzinfo (2.0.4)
486485
concurrent-ruby (~> 1.0)
@@ -501,11 +500,6 @@ GEM
501500
addressable (>= 2.3.6)
502501
crack (>= 0.3.2)
503502
hashdiff (>= 0.4.0, < 2.0.0)
504-
webpacker (6.0.0.rc.5)
505-
activesupport (>= 5.2)
506-
rack-proxy (>= 0.6.1)
507-
railties (>= 5.2)
508-
semantic_range (>= 2.3.0)
509503
webrick (1.7.0)
510504
websocket (1.2.9)
511505
websocket-driver (0.7.5)
@@ -543,6 +537,7 @@ DEPENDENCIES
543537
hiredis
544538
image_processing (~> 1.2)
545539
importmap-rails
540+
jsbundling-rails
546541
json (>= 2.0.0)
547542
kindlerb (~> 1.2.0)
548543
libxml-ruby
@@ -590,7 +585,6 @@ DEPENDENCIES
590585
wdm (>= 0.1.0)
591586
webdrivers
592587
webmock
593-
webpacker (~> 6.0.0.rc.5)
594588
webrick
595589
websocket-client-simple!
596590

activejob/Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ namespace :test do
2828

2929
task "env:integration" do
3030
ENV["AJ_INTEGRATION_TESTS"] = "1"
31-
ENV["SKIP_REQUIRE_WEBPACKER"] = "true"
3231
end
3332

3433
ACTIVEJOB_ADAPTERS.each do |adapter|

railties/lib/rails/generators/app_base.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,8 @@ def javascript_gemfile_entry
296296
case options[:javascript]
297297
when "importmap"
298298
GemfileEntry.version("importmap-rails", ">= 0.3.4", "Manage modern JavaScript using ESM without transpiling or bundling")
299-
when "webpack"
300-
GemfileEntry.version "webpacker", "~> 6.0.0.rc.5", "Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker"
301-
when "esbuild"
302-
GemfileEntry.version "esbuild-rails", "~> 0.1.2", "Transpile app-like JavaScript. Read more: https://github.com/rails/esbuild-rails"
303-
when "rollup"
304-
GemfileEntry.version "rollupjs-rails", "~> 0.1.0", "Transpile app-like JavaScript. Read more: https://github.com/rails/rollupjs-rails"
299+
when "webpack", "esbuild", "rollup"
300+
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"
305301
else
306302
raise "Unknown JavaScript approach: #{options[:javascript]} [options are: importmap, webpack, esbuild, rollup]"
307303
end
@@ -381,10 +377,8 @@ def run_javascript
381377
return if options[:skip_javascript] || !bundle_install?
382378

383379
case options[:javascript]
384-
when "importmap" then rails_command "importmap:install"
385-
when "webpack" then rails_command "webpacker:install"
386-
when "esbuild" then rails_command "esbuild:install"
387-
when "rollup" then rails_command "rollup:install"
380+
when "importmap" then rails_command "importmap:install"
381+
when "webpack", "esbuild", "rollup" then rails_command "javascript:install:#{options[:javascript]}"
388382
end
389383
end
390384

railties/lib/rails/generators/rails/plugin/plugin_generator.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ def create_dummy_app(path = nil)
316316
mute do
317317
build(:generate_test_dummy)
318318
build(:test_dummy_config)
319-
build(:test_dummy_webpacker_assets)
320319
build(:test_dummy_sprocket_assets) unless options[:skip_sprockets]
321320
build(:test_dummy_clean)
322321
# ensure that bin/rails has proper dummy_path

railties/test/engine/commands_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_help_command_work_inside_engine
2424

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

3030
assert_equal "test", output.strip
@@ -68,7 +68,6 @@ def plugin_path
6868

6969
def spawn_command(command, fd)
7070
Process.spawn(
71-
{ "SKIP_REQUIRE_WEBPACKER" => "true" },
7271
"#{plugin_path}/bin/rails #{command}",
7372
in: fd, out: fd, err: fd
7473
)

railties/test/generators/app_generator_test.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,6 @@ class AppGeneratorTest < Rails::Generators::TestCase
9494
# brings setup, teardown, and some tests
9595
include SharedGeneratorTests
9696

97-
setup do
98-
ENV["SKIP_REQUIRE_WEBPACKER"] = "true"
99-
end
100-
101-
teardown do
102-
ENV["SKIP_REQUIRE_WEBPACKER"] = nil
103-
end
104-
10597
def default_files
10698
::DEFAULT_APP_FILES
10799
end
@@ -791,7 +783,7 @@ def test_webpack_option
791783
webpacker_called = 0
792784
command_check = -> command, *_ do
793785
case command
794-
when "webpacker:install"
786+
when "javascript:install:webpack"
795787
webpacker_called += 1
796788
end
797789
end
@@ -800,8 +792,8 @@ def test_webpack_option
800792
run_generator_instance
801793
end
802794

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

807799
def test_hotwire

0 commit comments

Comments
 (0)