FIX: 6to5 was renamed to Babel
I can't believe they just pulled the old gem and broke people deploying our site to production. I get it, your name changed, but don't break other people's apps with no deprecations.
This commit is contained in:
parent
aeb0fc7559
commit
4691fe35b3
2
Gemfile
2
Gemfile
|
@ -107,7 +107,7 @@ gem 'ember-rails'
|
|||
gem 'ember-source', '1.9.0.beta.4'
|
||||
gem 'handlebars-source', '2.0.0'
|
||||
gem 'barber'
|
||||
gem '6to5'
|
||||
gem 'babel-transpiler'
|
||||
|
||||
gem 'message_bus'
|
||||
gem 'rails_multisite', path: 'vendor/gems/rails_multisite'
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -6,10 +6,6 @@ PATH
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
6to5 (0.5.0)
|
||||
6to5-source (>= 1.14, < 4)
|
||||
execjs (~> 2.0)
|
||||
6to5-source (3.3.7)
|
||||
CFPropertyList (2.2.8)
|
||||
actionmailer (4.1.9)
|
||||
actionpack (= 4.1.9)
|
||||
|
@ -45,6 +41,10 @@ GEM
|
|||
activerecord (>= 2.3.0)
|
||||
rake (>= 0.8.7)
|
||||
arel (5.0.1.20140414130214)
|
||||
babel-source (4.6.6)
|
||||
babel-transpiler (0.6.0)
|
||||
babel-source (>= 4.0, < 5)
|
||||
execjs (~> 2.0)
|
||||
barber (0.5.0)
|
||||
ember-source
|
||||
execjs
|
||||
|
@ -456,10 +456,10 @@ PLATFORMS
|
|||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
6to5
|
||||
actionpack-action_caching
|
||||
active_model_serializers (~> 0.8.0)
|
||||
annotate
|
||||
babel-transpiler
|
||||
barber
|
||||
better_errors
|
||||
binding_of_caller
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
require 'execjs'
|
||||
require '6to5'
|
||||
require 'babel/transpiler'
|
||||
|
||||
module Tilt
|
||||
|
||||
class Console
|
||||
def initialize(prefix=nil)
|
||||
@prefix = prefix || ''
|
||||
end
|
||||
|
||||
def log(msg)
|
||||
Rails.logger.info("#{@prefix}#{msg}")
|
||||
end
|
||||
|
||||
def error(msg)
|
||||
Rails.logger.error("#{@prefix}#{msg}")
|
||||
end
|
||||
end
|
||||
|
||||
class ES6ModuleTranspilerTemplate < Tilt::Template
|
||||
self.default_mime_type = 'application/javascript'
|
||||
|
||||
|
@ -15,7 +30,7 @@ module Tilt
|
|||
|
||||
def self.create_new_context
|
||||
ctx = V8::Context.new(timeout: 5000)
|
||||
ctx.eval("var self = this; #{File.read(ES6to5::Source.path)}")
|
||||
ctx.eval("var self = this; #{File.read(Babel::Transpiler.script_path)}")
|
||||
ctx.eval("module = {}; exports = {};");
|
||||
ctx.load("#{Rails.root}/lib/es6_module_transpiler/support/es6-module-transpiler.js")
|
||||
ctx
|
||||
|
@ -64,6 +79,7 @@ module Tilt
|
|||
|
||||
klass = self.class
|
||||
klass.protect do
|
||||
klass.v8['console'] = Console.new("BABEL: #{scope.logical_path}: ")
|
||||
@output = klass.v8.eval(generate_source(scope))
|
||||
end
|
||||
|
||||
|
@ -118,7 +134,7 @@ module Tilt
|
|||
|
||||
def generate_source(scope)
|
||||
js_source = ::JSON.generate(data, quirks_mode: true)
|
||||
js_source = "to5.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping']})['code']"
|
||||
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping']})['code']"
|
||||
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue