Skip to content

Commit 901f58d

Browse files
author
Robert Mosolgo
authored
Merge pull request #777 from BookOfGreg/fix-776
Support singleton webpacker (3 and above)
2 parents 9ca9a46 + 83fbdaf commit 901f58d

File tree

450 files changed

+19385
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

450 files changed

+19385
-490
lines changed

Diff for: .gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
*.gem
22
Gemfile.lock
33
*.log
4-
test/dummy/tmp
5-
test/dummy/public/packs
4+
test/*/tmp
5+
test/*/public/packs
66
gemfiles/*.lock
77
*.swp
88
/vendor/react

Diff for: .rubocop.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
AllCops:
2+
TargetRubyVersion: 2.1
3+
DisplayCopNames: true
4+
Exclude:
5+
- test/dummy_sprockets/**/*
6+
- test/dummy_webpacker1/**/*
7+
- test/dummy_webpacker2/**/*
8+
- test/dummy_webpacker3/**/*
9+
- node_modules/**/*
10+
- react_ujs/**/*

Diff for: .travis.yml

+20-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ rvm:
1212
gemfile:
1313
# These have webpacker:
1414
- gemfiles/rails_4.2_sprockets_4.gemfile
15-
- gemfiles/rails_5_no_sprockets_webpacker.gemfile
15+
- gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
16+
- gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
17+
- gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
18+
- gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
1619
# These don't have webpacker:
1720
- gemfiles/rails_3.2.gemfile
1821
- gemfiles/rails_4.0.5.gemfile
@@ -39,7 +42,13 @@ matrix:
3942
- rvm: 2.1
4043
gemfile: gemfiles/rails_4.2_sprockets_4.gemfile
4144
- rvm: 2.1
42-
gemfile: gemfiles/rails_5_no_sprockets_webpacker.gemfile
45+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
46+
- rvm: 2.1
47+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
48+
- rvm: 2.1
49+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
50+
- rvm: 2.1
51+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
4352
- rvm: 2.1
4453
gemfile: gemfiles/rails_5_no_sprockets.gemfile
4554
- rvm: 2.1
@@ -53,7 +62,15 @@ matrix:
5362
- rvm: jruby-9.0.1.0
5463
gemfile: gemfiles/rails_4.2_sprockets_2.gemfile
5564
- rvm: jruby-9.0.1.0
56-
gemfile: gemfiles/rails_5_no_sprockets_webpacker.gemfile
65+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
66+
- rvm: jruby-9.0.1.0
67+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
68+
- rvm: jruby-9.0.1.0
69+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
70+
- rvm: jruby-9.0.1.0
71+
gemfile: gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
72+
- rvm: jruby-9.0.1.0
73+
gemfile: gemfiles/rails_5_no_sprockets.gemfile
5774

5875
allow_failures:
5976
- rvm: jruby-9.0.1.0

Diff for: Appraisals

+51-26
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,97 @@
1-
appraise "rails-3.2" do
1+
appraise 'rails-3.2' do
22
gem 'rails', '~> 3.2.21'
33
gem 'rack-cache', '~> 1.6.1'
44
# Modern turbolinks depends on `Rails.application.assets` which no-worky
55
gem 'turbolinks', '~> 2.0'
66
end
77

8-
appraise "rails-4.0.5" do
8+
appraise 'rails-4.0.5' do
99
# Depends on sprockets-rails ~> 2.0.0. Support for
1010
# `Rails.application.assets_manifest` which is used by
1111
# `ServerRendering::ManifestContainer` has only been added in
1212
# sprockets-rails 2.2.2. Ensure that server rendering falls back to
1313
# `ServerRendering::EnvironmentContainer`.`
1414
gem 'rails', '4.0.5'
15-
gem "turbolinks"
15+
gem 'turbolinks'
1616
end
1717

18-
appraise "rails-4.0-with-therubyracer" do
18+
appraise 'rails-4.0-with-therubyracer' do
1919
gem 'rails', '~> 4.0.13'
2020
gem 'therubyracer', '0.12.0', :platform => :mri
21-
gem "turbolinks"
21+
gem 'turbolinks'
2222
end
2323

24-
appraise "rails-4.1" do
24+
appraise 'rails-4.1' do
2525
gem 'rails', '~> 4.1.10'
2626
# Just to make sure we support old Turbolinks:
27-
gem "turbolinks", "~> 2.3.0"
27+
gem 'turbolinks', '~> 2.3.0'
2828
end
2929

30-
appraise "rails-4.2-sprockets_2" do
30+
appraise 'rails-4.2-sprockets_2' do
3131
gem 'rails', '~> 4.2.1'
32-
gem "sprockets", "~> 2.12"
33-
gem "turbolinks"
32+
gem 'sprockets', '~> 2.12'
33+
gem 'turbolinks'
3434
end
3535

36-
appraise "rails-4.2-sprockets_3" do
36+
appraise 'rails-4.2-sprockets_3' do
3737
gem 'rails', '~> 4.2.1'
38-
gem "sprockets", "~> 3.5"
39-
gem "turbolinks", "~> 2.5.0"
38+
gem 'sprockets', '~> 3.5'
39+
gem 'turbolinks', '~> 2.5.0'
4040
end
4141

42-
appraise "rails-4.2-sprockets_4" do
42+
appraise 'rails-4.2-sprockets_4' do
4343
gem 'rails', '~> 4.2.1'
44-
gem "sprockets", "~> 4.0.x"
45-
gem "turbolinks", "~> 2.5.0"
46-
gem "webpacker", github: "rails/webpacker"
44+
gem 'sprockets', '~> 4.0.x'
45+
gem 'turbolinks', '~> 2.5.0'
4746
# This ExecJS backend provides stateful context
4847
# which the default nodejs backend does not
49-
gem "mini_racer"
48+
gem 'mini_racer'
5049
end
5150

52-
appraise "rails-5_no_sprockets_webpacker" do
51+
# no_sprockets is a magical name from sprockets_helper.rb in test to
52+
# load in certain tests or not.
53+
appraise 'rails-5_no_sprockets_webpacker_1_1' do
5354
gem 'rails', '~> 5.0.0'
54-
gem "webpacker", github: "rails/webpacker"
55+
gem 'webpacker', '~> 1.1.0'
5556
# This ExecJS backend provides stateful context
5657
# which the default nodejs backend does not
57-
gem "therubyracer"
58+
gem 'therubyracer'
5859
end
5960

60-
appraise "rails-5-no_sprockets" do
61+
appraise 'rails-5_no_sprockets_webpacker_1_x' do
62+
gem 'rails', '~> 5.0.0'
63+
gem 'webpacker', '~> 1.2'
64+
# This ExecJS backend provides stateful context
65+
# which the default nodejs backend does not
66+
gem 'therubyracer'
67+
end
68+
69+
appraise 'rails-5_no_sprockets_webpacker_2' do
70+
gem 'rails', '~> 5.0.0'
71+
gem 'webpacker', '~> 2.0'
72+
# This ExecJS backend provides stateful context
73+
# which the default nodejs backend does not
74+
gem 'therubyracer'
75+
end
76+
77+
appraise 'rails-5_no_sprockets_webpacker_3' do
78+
gem 'rails', '~> 5.0.0'
79+
gem 'webpacker', '>= 3.0'
80+
# This ExecJS backend provides stateful context
81+
# which the default nodejs backend does not
82+
gem 'therubyracer'
83+
end
84+
85+
appraise 'rails-5-no_sprockets' do
6186
# Appraisal adds `turbolinks` to this gemfile because it is
6287
# present in `./Gemfile`.
6388
# But it causes this gemfile to break, so it must be removed
6489
# from `./gemfiles/rails_5_no_sprockets.gemfile` manually.
6590
gem 'rails', '~> 5.0.0'
6691
end
6792

68-
appraise "rails-5.1-sprockets_4" do
69-
gem "rails", "5.1.0.rc1"
70-
gem "sprockets", "~> 4.0.x"
71-
gem "turbolinks", "~> 5.0.0"
93+
appraise 'rails-5.1-sprockets_4' do
94+
gem 'rails', '~> 5.1'
95+
gem 'sprockets', '~> 4.0.x'
96+
gem 'turbolinks', '~> 5.0.0'
7297
end

Diff for: Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ source 'http://rubygems.org'
22

33
gemspec
44
# This is an optional dev-dependency, required whenever sprockets is required
5-
gem "turbolinks"

Diff for: Rakefile

+25-17
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def yarn_run_in(dirname, cmd)
2020
end
2121

2222
namespace :react do
23-
desc "Run the JS build process to put files in the gem source"
23+
desc 'Run the JS build process to put files in the gem source'
2424
task update: [:install, :build, :copy]
2525

26-
desc "Build the JS bundles with Webpack"
26+
desc 'Build the JS bundles with Webpack'
2727
task :build do
28-
yarn_run_in("react-builds", "build")
28+
yarn_run_in('react-builds', 'build')
2929
end
3030

3131
desc "Copy browser-ready JS files to the gem's asset paths"
3232
task :copy do
33-
environments = ["development", "production"]
33+
environments = ['development', 'production']
3434
environments.each do |environment|
3535
# Without addons:
3636
copy_react_asset("#{environment}/react-browser.js", "#{environment}/react.js")
@@ -42,37 +42,36 @@ namespace :react do
4242
end
4343
end
4444

45-
desc "Install the JavaScript dependencies"
45+
desc 'Install the JavaScript dependencies'
4646
task :install do
47-
yarn_run_in("react-builds", "upgrade")
47+
yarn_run_in('react-builds', 'upgrade')
4848
end
4949
end
5050

5151
namespace :ujs do
52-
desc "Run the JS build process to put files in the gem source"
52+
desc 'Run the JS build process to put files in the gem source'
5353
task update: [:install, :build, :copy]
5454

55-
desc "Install the JavaScript dependencies"
55+
desc 'Install the JavaScript dependencies'
5656
task :install do
57-
yarn_run_in("react_ujs", "upgrade")
57+
yarn_run_in('react_ujs', 'upgrade')
5858
end
5959

60-
61-
desc "Build the JS bundles with Webpack"
60+
desc 'Build the JS bundles with Webpack'
6261
task :build do
63-
yarn_run_in("react_ujs", "build")
62+
yarn_run_in('react_ujs', 'build')
6463
end
6564

6665
desc "Copy browser-ready JS files to the gem's asset paths"
6766
task :copy do
68-
full_webpack_path = File.expand_path("../react_ujs/dist/react_ujs.js", __FILE__)
69-
full_destination_path = File.expand_path("../lib/assets/javascripts/react_ujs.js", __FILE__)
67+
full_webpack_path = File.expand_path('../react_ujs/dist/react_ujs.js', __FILE__)
68+
full_destination_path = File.expand_path('../lib/assets/javascripts/react_ujs.js', __FILE__)
7069
FileUtils.cp(full_webpack_path, full_destination_path)
7170
end
7271

73-
desc "Publish the package in ./react_ujs/ to npm as `react_ujs`"
72+
desc 'Publish the package in ./react_ujs/ to npm as `react_ujs`'
7473
task publish: :update do
75-
Dir.chdir("react_ujs") do
74+
Dir.chdir('react_ujs') do
7675
`npm publish`
7776
end
7877
end
@@ -92,7 +91,16 @@ end
9291
task default: :test
9392

9493
task :test_setup do
95-
Dir.chdir("./test/dummy") do
94+
Dir.chdir('./test/dummy_sprockets') do
95+
`yarn install`
96+
end
97+
Dir.chdir('./test/dummy_webpacker1') do
98+
`yarn install`
99+
end
100+
Dir.chdir('./test/dummy_webpacker2') do
101+
`yarn install`
102+
end
103+
Dir.chdir('./test/dummy_webpacker3') do
96104
`yarn install`
97105
end
98106
end

Diff for: gemfiles/rails_3.2.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks", "~> 2.0"
65
gem "rails", "~> 3.2.21"
76
gem "rack-cache", "~> 1.6.1"
7+
gem "turbolinks", "~> 2.0"
88

99
gemspec :path => "../"

Diff for: gemfiles/rails_4.0.5.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks"
65
gem "rails", "4.0.5"
6+
gem "turbolinks"
77

88
gemspec :path => "../"

Diff for: gemfiles/rails_4.0_with_therubyracer.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks"
65
gem "rails", "~> 4.0.13"
76
gem "therubyracer", "0.12.0", :platform => :mri
7+
gem "turbolinks"
88

99
gemspec :path => "../"

Diff for: gemfiles/rails_4.1.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks", "~> 2.3.0"
65
gem "rails", "~> 4.1.10"
6+
gem "turbolinks", "~> 2.3.0"
77

88
gemspec :path => "../"

Diff for: gemfiles/rails_4.2_sprockets_2.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks"
65
gem "rails", "~> 4.2.1"
76
gem "sprockets", "~> 2.12"
7+
gem "turbolinks"
88

99
gemspec :path => "../"

Diff for: gemfiles/rails_4.2_sprockets_3.gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks", "~> 2.5.0"
65
gem "rails", "~> 4.2.1"
76
gem "sprockets", "~> 3.5"
7+
gem "turbolinks", "~> 2.5.0"
88

99
gemspec :path => "../"

Diff for: gemfiles/rails_4.2_sprockets_4.gemfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks", "~> 2.5.0"
65
gem "rails", "~> 4.2.1"
76
gem "sprockets", "~> 4.0.x"
8-
gem "webpacker", :github => "rails/webpacker"
7+
gem "turbolinks", "~> 2.5.0"
98
gem "mini_racer"
109

1110
gemspec :path => "../"

Diff for: gemfiles/rails_5.1_sprockets_4.gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
source "http://rubygems.org"
44

5-
gem "turbolinks", "~> 5.0.0"
6-
gem "rails", "5.1.0.rc1"
5+
gem "rails", "~> 5.1"
76
gem "sprockets", "~> 4.0.x"
7+
gem "turbolinks", "~> 5.0.0"
88

99
gemspec :path => "../"

Diff for: gemfiles/rails_5_no_sprockets.gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# This file was generated by Appraisal
2-
# This shouldn't have turbolinks or sprockets
32

43
source "http://rubygems.org"
54

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# This file was generated by Appraisal
2-
# This file shouldn't have turbolinks or sprockets in it
32

43
source "http://rubygems.org"
54

65
gem "rails", "~> 5.0.0"
7-
gem "webpacker", :github => "rails/webpacker"
6+
gem "webpacker", "~> 1.1.0"
87
gem "therubyracer"
98

109
gemspec :path => "../"

Diff for: gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This file was generated by Appraisal
2+
3+
source "http://rubygems.org"
4+
5+
gem "rails", "~> 5.0.0"
6+
gem "webpacker", "~> 1.2"
7+
gem "therubyracer"
8+
9+
gemspec :path => "../"

0 commit comments

Comments
 (0)