Skip to content

Commit 8a00131

Browse files
justin808claude
andcommitted
Remove webpacker support and require Shakapacker 8.2+
- Delete rakelib/webpacker_examples.rake and webpacker example generation - Remove adapt_for_older_shakapacker_generator.rb (Shakapacker 6/7 compatibility) - Remove webpacker binaries from dummy app (bin/webpacker, bin/webpacker-dev-server) - Simplify PackerUtils to only support Shakapacker 8.2+ (remove webpacker logic) - Update all tests to use Shakapacker instead of Webpacker mocks - Remove webpacker references from rake tasks and configuration - Fix pack_generator_spec.rb to use targeted stubs and proper output expectations BREAKING CHANGE: Webpacker is no longer supported. Shakapacker 8.2+ is now required. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b602d66 commit 8a00131

File tree

11 files changed

+12
-247
lines changed

11 files changed

+12
-247
lines changed

lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb

Lines changed: 0 additions & 47 deletions
This file was deleted.

lib/react_on_rails/packer_utils.rb

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,27 @@
33
module ReactOnRails
44
module PackerUtils
55
def self.using_packer?
6-
using_shakapacker_const? || using_webpacker_const?
6+
using_shakapacker_const?
77
end
88

99
def self.using_shakapacker_const?
1010
return @using_shakapacker_const if defined?(@using_shakapacker_const)
1111

1212
@using_shakapacker_const = ReactOnRails::Utils.gem_available?("shakapacker") &&
13-
shakapacker_version_requirement_met?("7.0.0")
14-
end
15-
16-
def self.using_webpacker_const?
17-
return @using_webpacker_const if defined?(@using_webpacker_const)
18-
19-
@using_webpacker_const = (ReactOnRails::Utils.gem_available?("shakapacker") &&
20-
shakapacker_version_as_array[0] <= 6) ||
21-
ReactOnRails::Utils.gem_available?("webpacker")
13+
shakapacker_version_requirement_met?("8.2.0")
2214
end
2315

2416
def self.packer_type
2517
return "shakapacker" if using_shakapacker_const?
26-
return "webpacker" if using_webpacker_const?
2718

2819
nil
2920
end
3021

3122
def self.packer
3223
return nil unless using_packer?
3324

34-
if using_shakapacker_const?
35-
require "shakapacker"
36-
return ::Shakapacker
37-
end
38-
require "webpacker"
39-
::Webpacker
25+
require "shakapacker"
26+
::Shakapacker
4027
end
4128

4229
def self.dev_server_running?
@@ -106,7 +93,6 @@ def self.asset_uri_from_packer(asset_name)
10693
end
10794

10895
def self.precompile?
109-
return ::Webpacker.config.webpacker_precompile? if using_webpacker_const?
11096
return ::Shakapacker.config.shakapacker_precompile? if using_shakapacker_const?
11197

11298
false

rakelib/example_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module ReactOnRails
1010
module TaskHelpers
1111
class ExampleType
1212
def self.all
13-
@all ||= { webpacker_examples: [], shakapacker_examples: [] }
13+
@all ||= { shakapacker_examples: [] }
1414
end
1515

1616
attr_reader :packer_type, :name, :generator_options

rakelib/release.rake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ task :release, %i[gem_version dry_run tools_install] do |_t, args|
5050

5151
# Having the examples prevents publishing
5252
Rake::Task["shakapacker_examples:clobber"].invoke
53-
Rake::Task["webpacker_examples:clobber"].invoke
5453
# Delete any react_on_rails.gemspec except the root one
5554
sh_in_dir(gem_root, "find . -mindepth 2 -name 'react_on_rails.gemspec' -delete")
5655

rakelib/run_rspec.rake

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ namespace :run_rspec do
1616
examples_config = symbolize_keys(YAML.safe_load_file(examples_config_file))
1717
examples_config[:example_type_data].each do |example_type_data|
1818
ExampleType.new(packer_type: "shakapacker_examples", **symbolize_keys(example_type_data))
19-
ExampleType.new(packer_type: "webpacker_examples", **symbolize_keys(example_type_data))
2019
end
2120

2221
spec_dummy_dir = File.join("spec", "dummy")
@@ -38,15 +37,6 @@ namespace :run_rspec do
3837
command_name: "dummy_no_turbolinks")
3938
end
4039

41-
# Dynamically define Rake tasks for each example app found in the examples directory
42-
ExampleType.all[:webpacker_examples].each do |example_type|
43-
puts "Creating #{example_type.rspec_task_name} task"
44-
desc "Runs RSpec for #{example_type.name_pretty} only"
45-
task example_type.rspec_task_name_short => example_type.gen_task_name do
46-
run_tests_in(File.join(examples_dir, example_type.name)) # have to use relative path
47-
end
48-
end
49-
5040
# Dynamically define Rake tasks for each example app found in the examples directory
5141
ExampleType.all[:shakapacker_examples].each do |example_type|
5242
puts "Creating #{example_type.rspec_task_name} task"
@@ -56,11 +46,6 @@ namespace :run_rspec do
5646
end
5747
end
5848

59-
desc "Runs Rspec for webpacker example apps only"
60-
task webpacker_examples: "webpacker_examples:gen_all" do
61-
ExampleType.all[:webpacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }
62-
end
63-
6449
desc "Runs Rspec for shakapacker example apps only"
6550
task shakapacker_examples: "shakapacker_examples:gen_all" do
6651
ExampleType.all[:shakapacker_examples].each { |example_type| Rake::Task[example_type.rspec_task_name].invoke }

rakelib/webpacker_examples.rake

Lines changed: 0 additions & 59 deletions
This file was deleted.

spec/dummy/bin/webpacker

Lines changed: 0 additions & 25 deletions
This file was deleted.

spec/dummy/bin/webpacker-dev-server

Lines changed: 0 additions & 22 deletions
This file was deleted.

spec/react_on_rails/configuration_spec.rb

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module ReactOnRails
3232
.and_return(packer_public_output_path)
3333
end
3434

35-
it "does not throw if the generated assets dir is blank with webpacker" do
35+
it "does not throw if the generated assets dir is blank with shakapacker" do
3636
expect do
3737
ReactOnRails.configure do |config|
3838
config.generated_assets_dir = ""
@@ -76,45 +76,7 @@ module ReactOnRails
7676
end
7777

7878
describe ".build_production_command" do
79-
context "when using Shakapacker 6", if: ReactOnRails::PackerUtils.packer_type != "shakapacker" do
80-
it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do
81-
allow(Webpacker).to receive_message_chain("config.webpacker_precompile?")
82-
.and_return(true)
83-
expect do
84-
ReactOnRails.configure do |config|
85-
config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker"
86-
end
87-
end.to raise_error(ReactOnRails::Error, /webpacker_precompile: false/)
88-
end
89-
90-
it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is truly" do
91-
allow(Webpacker).to receive_message_chain("config.webpacker_precompile?")
92-
.and_return(false)
93-
expect do
94-
ReactOnRails.configure do |config|
95-
config.build_production_command = "RAILS_ENV=production NODE_ENV=production bin/shakapacker"
96-
end
97-
end.not_to raise_error
98-
end
99-
100-
it "doesn't fail when \"shakapacker_precompile\" is truly and \"build_production_command\" is falsy" do
101-
allow(Webpacker).to receive_message_chain("config.webpacker_precompile?")
102-
.and_return(true)
103-
expect do
104-
ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock
105-
end.not_to raise_error
106-
end
107-
108-
it "doesn't fail when \"shakapacker_precompile\" is falsy and \"build_production_command\" is falsy" do
109-
allow(Webpacker).to receive_message_chain("config.webpacker_precompile?")
110-
.and_return(false)
111-
expect do
112-
ReactOnRails.configure {} # rubocop:disable-line Lint/EmptyBlock
113-
end.not_to raise_error
114-
end
115-
end
116-
117-
context "when using Shakapacker 8", if: ReactOnRails::PackerUtils.packer_type == "shakapacker" do
79+
context "when using Shakapacker 8" do
11880
it "fails when \"shakapacker_precompile\" is truly and \"build_production_command\" is truly" do
11981
allow(Shakapacker).to receive_message_chain("config.shakapacker_precompile?")
12082
.and_return(true)

spec/react_on_rails/dev/pack_generator_spec.rb

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,23 @@
55

66
RSpec.describe ReactOnRails::Dev::PackGenerator do
77
describe ".generate" do
8-
before do
9-
# Stub the global system method to prevent actual command execution
10-
allow_any_instance_of(Object).to receive(:system).and_return(true)
11-
end
12-
138
it "runs pack generation successfully in verbose mode" do
149
command = "bundle exec rake react_on_rails:generate_packs"
15-
allow_any_instance_of(Object).to receive(:system).with(command).and_return(true)
10+
allow(described_class).to receive(:system).with(command).and_return(true)
1611

17-
expect { described_class.generate(verbose: true) }.to output.to_stdout_from_any_process
12+
expect { described_class.generate(verbose: true) }.to output(/📦 Generating React on Rails packs.../).to_stdout_from_any_process
1813
end
1914

2015
it "runs pack generation successfully in quiet mode" do
2116
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
22-
allow_any_instance_of(Object).to receive(:system).with(command).and_return(true)
17+
allow(described_class).to receive(:system).with(command).and_return(true)
2318

24-
# Suppress the print and puts output for quiet mode
25-
allow_any_instance_of(Object).to receive(:print)
26-
allow_any_instance_of(Object).to receive(:puts)
27-
28-
expect { described_class.generate(verbose: false) }.not_to output.to_stdout_from_any_process
19+
expect { described_class.generate(verbose: false) }.to output(/📦 Generating packs\.\.\. ✅/).to_stdout_from_any_process
2920
end
3021

3122
it "exits with error when pack generation fails" do
3223
command = "bundle exec rake react_on_rails:generate_packs > /dev/null 2>&1"
33-
allow_any_instance_of(Object).to receive(:system).with(command).and_return(false)
34-
35-
# Suppress the puts output
36-
allow_any_instance_of(Object).to receive(:puts)
24+
allow(described_class).to receive(:system).with(command).and_return(false)
3725

3826
expect { described_class.generate(verbose: false) }.to raise_error(SystemExit)
3927
end

0 commit comments

Comments
 (0)