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

Support singleton webpacker (3 and above) #777

Merged
merged 50 commits into from
Sep 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
392ec00
Support singleton webpacker (3 and above)
BookOfGreg Aug 31, 2017
4531b1c
Support Specific versions of webpacker in appraisal
BookOfGreg Aug 31, 2017
14865d8
Update appraisal
BookOfGreg Aug 31, 2017
80c03d8
Simplify
BookOfGreg Aug 31, 2017
8c7dcd8
Pin to 3 or greater
BookOfGreg Aug 31, 2017
cd74273
Compatibility for Webpacker new
BookOfGreg Aug 31, 2017
2b7cf68
Reference correct constant
BookOfGreg Sep 1, 2017
d1e665e
Fixes #778
BookOfGreg Sep 5, 2017
ea8810e
Handle manifest load
BookOfGreg Sep 5, 2017
5a78e5d
WIP, trying to get webpacker3 config with webpacker1 and 2
BookOfGreg Sep 5, 2017
b960b9a
Extract out data
BookOfGreg Sep 5, 2017
cc8528f
Ruby 2.1 doesnt support twiddledocs
BookOfGreg Sep 5, 2017
54f95b7
Take on the configuration comment, also reduce the react regex as the…
BookOfGreg Sep 8, 2017
ed8a891
Split out dummy apps for the asset pipelines.
BookOfGreg Sep 8, 2017
488a840
Split out Webpacker dummy and sprockets dummy, then change to that di…
BookOfGreg Sep 8, 2017
2c8ec5e
ignore ruby 2.1 with Rails 5
BookOfGreg Sep 8, 2017
29c1d02
Add new dummy webpacker3 app
BookOfGreg Sep 8, 2017
ca48da9
Typo in appraisal gemfile name
BookOfGreg Sep 8, 2017
41b633f
Typo in appraisal gemfile name
BookOfGreg Sep 8, 2017
a5f3da5
Pin webpacker 1.1
BookOfGreg Sep 8, 2017
9b7af66
Set directory based on gem version
BookOfGreg Sep 8, 2017
2492053
Define methods based on which webpacker version is loaded to make con…
BookOfGreg Sep 11, 2017
f33976a
Update appraisals for each version of webpacker
BookOfGreg Sep 11, 2017
1b210b0
Each one seems to need turbolinks
BookOfGreg Sep 11, 2017
72285ce
Shouldnt need turbolinks
BookOfGreg Sep 11, 2017
8c88a3b
Turns out _no_sprockets_ name is actually executable code...
BookOfGreg Sep 11, 2017
4fad8b3
Reinitialize webpacker with default config except for the following d…
BookOfGreg Sep 11, 2017
c587945
Add new Webpacker 2 folder
BookOfGreg Sep 11, 2017
b6dc2aa
Regenerate webpacker configs for webpacker 2
BookOfGreg Sep 11, 2017
7b1b5ad
Tweaking configs and requires to sensible version
BookOfGreg Sep 11, 2017
6324185
Use local node_module
BookOfGreg Sep 11, 2017
77536cd
Dont test Rails 5 on ruby 2.1
BookOfGreg Sep 11, 2017
253ccde
Make it use localhost rather than 0.0.0.0, also React 15.4 so I do no…
BookOfGreg Sep 11, 2017
2805d9d
Add Webpacker 3 test app
BookOfGreg Sep 11, 2017
9390b09
Webpack 3 settings
BookOfGreg Sep 11, 2017
4aa297f
Tweak dev-server detector
BookOfGreg Sep 12, 2017
f15b255
Use Webpackers native dev_server detection
BookOfGreg Sep 12, 2017
c61f74d
properly scope config access
BookOfGreg Sep 12, 2017
0c0b9bc
Remove require pry references
BookOfGreg Sep 12, 2017
e3efcb8
Introduce rubocop to project
BookOfGreg Sep 15, 2017
0f75fe7
rubocop --only Layout/SpaceInsideHashLiteralBraces -a
BookOfGreg Sep 15, 2017
07afcb7
rubocop --only Style/StringLiterals -a
BookOfGreg Sep 15, 2017
384a406
Test scanned the file for specific quotes.
BookOfGreg Sep 18, 2017
579367f
rubocop --only Layout/SpaceInsideBlockBraces -a
BookOfGreg Sep 18, 2017
940f5dd
rubocop --only Style/NegatedIf -a
BookOfGreg Sep 18, 2017
9437671
rubocop --only Style/TrailingCommaInLiteral -a
BookOfGreg Sep 18, 2017
caf0827
rubocop --only Layout/SpaceInsideBrackets -a
BookOfGreg Sep 18, 2017
f2330d9
rubocop --only Layout/SpaceBeforeComment -a
BookOfGreg Sep 18, 2017
e5bbe14
rubocop --only Style/ParallelAssignment -a
BookOfGreg Sep 18, 2017
83fbdaf
rubocop --only Layout/EmptyLines -a
BookOfGreg Sep 18, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*.gem
Gemfile.lock
*.log
test/dummy/tmp
test/dummy/public/packs
test/*/tmp
test/*/public/packs
gemfiles/*.lock
*.swp
/vendor/react
Expand Down
10 changes: 10 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
AllCops:
TargetRubyVersion: 2.1
DisplayCopNames: true
Exclude:
- test/dummy_sprockets/**/*
- test/dummy_webpacker1/**/*
- test/dummy_webpacker2/**/*
- test/dummy_webpacker3/**/*
- node_modules/**/*
- react_ujs/**/*
23 changes: 20 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ rvm:
gemfile:
# These have webpacker:
- gemfiles/rails_4.2_sprockets_4.gemfile
- gemfiles/rails_5_no_sprockets_webpacker.gemfile
- gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
- gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
- gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
- gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
# These don't have webpacker:
- gemfiles/rails_3.2.gemfile
- gemfiles/rails_4.0.5.gemfile
Expand All @@ -39,7 +42,13 @@ matrix:
- rvm: 2.1
gemfile: gemfiles/rails_4.2_sprockets_4.gemfile
- rvm: 2.1
gemfile: gemfiles/rails_5_no_sprockets_webpacker.gemfile
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
- rvm: 2.1
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
- rvm: 2.1
gemfile: gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
- rvm: 2.1
gemfile: gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
- rvm: 2.1
gemfile: gemfiles/rails_5_no_sprockets.gemfile
- rvm: 2.1
Expand All @@ -53,7 +62,15 @@ matrix:
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_4.2_sprockets_2.gemfile
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_5_no_sprockets_webpacker.gemfile
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_1.gemfile
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_5_no_sprockets_webpacker_2.gemfile
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_5_no_sprockets_webpacker_3.gemfile
- rvm: jruby-9.0.1.0
gemfile: gemfiles/rails_5_no_sprockets.gemfile

allow_failures:
- rvm: jruby-9.0.1.0
Expand Down
77 changes: 51 additions & 26 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,72 +1,97 @@
appraise "rails-3.2" do
appraise 'rails-3.2' do
gem 'rails', '~> 3.2.21'
gem 'rack-cache', '~> 1.6.1'
# Modern turbolinks depends on `Rails.application.assets` which no-worky
gem 'turbolinks', '~> 2.0'
end

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

appraise "rails-4.0-with-therubyracer" do
appraise 'rails-4.0-with-therubyracer' do
gem 'rails', '~> 4.0.13'
gem 'therubyracer', '0.12.0', :platform => :mri
gem "turbolinks"
gem 'turbolinks'
end

appraise "rails-4.1" do
appraise 'rails-4.1' do
gem 'rails', '~> 4.1.10'
# Just to make sure we support old Turbolinks:
gem "turbolinks", "~> 2.3.0"
gem 'turbolinks', '~> 2.3.0'
end

appraise "rails-4.2-sprockets_2" do
appraise 'rails-4.2-sprockets_2' do
gem 'rails', '~> 4.2.1'
gem "sprockets", "~> 2.12"
gem "turbolinks"
gem 'sprockets', '~> 2.12'
gem 'turbolinks'
end

appraise "rails-4.2-sprockets_3" do
appraise 'rails-4.2-sprockets_3' do
gem 'rails', '~> 4.2.1'
gem "sprockets", "~> 3.5"
gem "turbolinks", "~> 2.5.0"
gem 'sprockets', '~> 3.5'
gem 'turbolinks', '~> 2.5.0'
end

appraise "rails-4.2-sprockets_4" do
appraise 'rails-4.2-sprockets_4' do
gem 'rails', '~> 4.2.1'
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 2.5.0"
gem "webpacker", github: "rails/webpacker"
gem 'sprockets', '~> 4.0.x'
gem 'turbolinks', '~> 2.5.0'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem "mini_racer"
gem 'mini_racer'
end

appraise "rails-5_no_sprockets_webpacker" do
# no_sprockets is a magical name from sprockets_helper.rb in test to
# load in certain tests or not.
appraise 'rails-5_no_sprockets_webpacker_1_1' do
gem 'rails', '~> 5.0.0'
gem "webpacker", github: "rails/webpacker"
gem 'webpacker', '~> 1.1.0'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem "therubyracer"
gem 'therubyracer'
end

appraise "rails-5-no_sprockets" do
appraise 'rails-5_no_sprockets_webpacker_1_x' do
gem 'rails', '~> 5.0.0'
gem 'webpacker', '~> 1.2'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem 'therubyracer'
end

appraise 'rails-5_no_sprockets_webpacker_2' do
gem 'rails', '~> 5.0.0'
gem 'webpacker', '~> 2.0'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem 'therubyracer'
end

appraise 'rails-5_no_sprockets_webpacker_3' do
gem 'rails', '~> 5.0.0'
gem 'webpacker', '>= 3.0'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem 'therubyracer'
end

appraise 'rails-5-no_sprockets' do
# Appraisal adds `turbolinks` to this gemfile because it is
# present in `./Gemfile`.
# But it causes this gemfile to break, so it must be removed
# from `./gemfiles/rails_5_no_sprockets.gemfile` manually.
gem 'rails', '~> 5.0.0'
end

appraise "rails-5.1-sprockets_4" do
gem "rails", "5.1.0.rc1"
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 5.0.0"
appraise 'rails-5.1-sprockets_4' do
gem 'rails', '~> 5.1'
gem 'sprockets', '~> 4.0.x'
gem 'turbolinks', '~> 5.0.0'
end
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ source 'http://rubygems.org'

gemspec
# This is an optional dev-dependency, required whenever sprockets is required
gem "turbolinks"
42 changes: 25 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ def yarn_run_in(dirname, cmd)
end

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

desc "Build the JS bundles with Webpack"
desc 'Build the JS bundles with Webpack'
task :build do
yarn_run_in("react-builds", "build")
yarn_run_in('react-builds', 'build')
end

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

desc "Install the JavaScript dependencies"
desc 'Install the JavaScript dependencies'
task :install do
yarn_run_in("react-builds", "upgrade")
yarn_run_in('react-builds', 'upgrade')
end
end

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

desc "Install the JavaScript dependencies"
desc 'Install the JavaScript dependencies'
task :install do
yarn_run_in("react_ujs", "upgrade")
yarn_run_in('react_ujs', 'upgrade')
end


desc "Build the JS bundles with Webpack"
desc 'Build the JS bundles with Webpack'
task :build do
yarn_run_in("react_ujs", "build")
yarn_run_in('react_ujs', 'build')
end

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

desc "Publish the package in ./react_ujs/ to npm as `react_ujs`"
desc 'Publish the package in ./react_ujs/ to npm as `react_ujs`'
task publish: :update do
Dir.chdir("react_ujs") do
Dir.chdir('react_ujs') do
`npm publish`
end
end
Expand All @@ -92,7 +91,16 @@ end
task default: :test

task :test_setup do
Dir.chdir("./test/dummy") do
Dir.chdir('./test/dummy_sprockets') do
`yarn install`
end
Dir.chdir('./test/dummy_webpacker1') do
`yarn install`
end
Dir.chdir('./test/dummy_webpacker2') do
`yarn install`
end
Dir.chdir('./test/dummy_webpacker3') do
`yarn install`
end
end
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.0"
gem "rails", "~> 3.2.21"
gem "rack-cache", "~> 1.6.1"
gem "turbolinks", "~> 2.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.0.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "4.0.5"
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.0_with_therubyracer.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "~> 4.0.13"
gem "therubyracer", "0.12.0", :platform => :mri
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.3.0"
gem "rails", "~> 4.1.10"
gem "turbolinks", "~> 2.3.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.2_sprockets_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 2.12"
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.2_sprockets_3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.5.0"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 3.5"
gem "turbolinks", "~> 2.5.0"

gemspec :path => "../"
3 changes: 1 addition & 2 deletions gemfiles/rails_4.2_sprockets_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.5.0"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 4.0.x"
gem "webpacker", :github => "rails/webpacker"
gem "turbolinks", "~> 2.5.0"
gem "mini_racer"

gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/rails_5.1_sprockets_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 5.0.0"
gem "rails", "5.1.0.rc1"
gem "rails", "~> 5.1"
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 5.0.0"

gemspec :path => "../"
1 change: 0 additions & 1 deletion gemfiles/rails_5_no_sprockets.gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file was generated by Appraisal
# This shouldn't have turbolinks or sprockets

source "http://rubygems.org"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# This file was generated by Appraisal
# This file shouldn't have turbolinks or sprockets in it

source "http://rubygems.org"

gem "rails", "~> 5.0.0"
gem "webpacker", :github => "rails/webpacker"
gem "webpacker", "~> 1.1.0"
gem "therubyracer"

gemspec :path => "../"
9 changes: 9 additions & 0 deletions gemfiles/rails_5_no_sprockets_webpacker_1_x.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "rails", "~> 5.0.0"
gem "webpacker", "~> 1.2"
gem "therubyracer"

gemspec :path => "../"
Loading