diff options
author | Javan Makhmali <javan@javan.us> | 2017-03-11 12:33:11 -0500 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2017-03-11 16:12:36 -0500 |
commit | 2d2b3025ec6f2b68f0cea524ee97322b6e349e6c (patch) | |
tree | 9418faf009d7391c3f60c202b6638d47a06f61de | |
parent | 158a01e73f7120533d0ec4c589939b2c5099eb1b (diff) | |
download | rails-2d2b3025ec6f2b68f0cea524ee97322b6e349e6c.tar.gz rails-2d2b3025ec6f2b68f0cea524ee97322b6e349e6c.tar.bz2 rails-2d2b3025ec6f2b68f0cea524ee97322b6e349e6c.zip |
Restore action_cable.js UMD module support. Fixes #28366
-rw-r--r-- | Gemfile | 1 | ||||
-rw-r--r-- | Gemfile.lock | 2 | ||||
-rw-r--r-- | actioncable/Rakefile | 36 |
3 files changed, 38 insertions, 1 deletions
@@ -84,6 +84,7 @@ group :cable do gem "blade", require: false, platforms: [:ruby] gem "blade-sauce_labs_plugin", require: false, platforms: [:ruby] + gem "sprockets-export", require: false end # Add your own local bundler stuff. diff --git a/Gemfile.lock b/Gemfile.lock index 74f76f9e7c..68c69f75a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -319,6 +319,7 @@ GEM sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) + sprockets-export (0.9.1) sprockets-rails (3.2.0) actionpack (>= 4.0) activesupport (>= 4.0) @@ -414,6 +415,7 @@ DEPENDENCIES sequel sidekiq sneakers + sprockets-export sqlite3 (~> 1.3.6) stackprof sucker_punch diff --git a/actioncable/Rakefile b/actioncable/Rakefile index 87d443919c..bda8c7b6c8 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -1,12 +1,13 @@ require "rake/testtask" require "pathname" +require "open3" require "action_cable" dir = File.dirname(__FILE__) task default: :test -task package: "assets:compile" +task package: %w( assets:compile assets:verify ) Rake::TestTask.new do |t| t.libs << "test" @@ -37,6 +38,39 @@ namespace :assets do desc "Compile Action Cable assets" task :compile do require "blade" + require "sprockets" + require "sprockets/export" Blade.build end + + desc "Verify compiled Action Cable assets" + task :verify do + file = "lib/assets/compiled/action_cable.js" + pathname = Pathname.new("#{dir}/#{file}") + + print "[verify] #{file} exists " + if pathname.exist? + puts "[OK]" + else + $stderr.puts "[FAIL]" + fail + end + + print "[verify] #{file} is a UMD module " + if pathname.read =~ /module\.exports.*define\.amd/m + puts "[OK]" + else + $stderr.puts "[FAIL]" + fail + end + + print "[verify] #{dir} can be required as a module " + stdout, stderr, status = Open3.capture3("node", "--print", "window = {}; require('#{dir}');") + if status.success? + puts "[OK]" + else + $stderr.puts "[FAIL]\n#{stderr}" + fail + end + end end |