Skip to content

Commit

Permalink
Transpile ES6 even without node, just using rubyracer
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed May 8, 2014
1 parent dddb2e1 commit c3ccc3e
Show file tree
Hide file tree
Showing 8 changed files with 7,378 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/application.rb
Expand Up @@ -32,6 +32,7 @@ class Application < Rails::Application
# -- all .rb files in that directory are automatically loaded.

require 'discourse'
require 'es6_module_transpiler/rails'
require 'js_locale_helper'

# mocha hates us, active_support/testing/mochaing.rb line 2 is requiring the wrong
Expand Down
39 changes: 39 additions & 0 deletions lib/es6_module_transpiler/rails.rb
@@ -0,0 +1,39 @@
require 'es6_module_transpiler/rails/version'
require 'es6_module_transpiler/tilt'
require 'es6_module_transpiler/sprockets'

module ES6ModuleTranspiler
def self.compile_to
@compile_to || :amd
end

def self.compile_to=(target)
@compile_to = target
end

def self.prefix_patterns
@prefix_patterns ||= []
end

def self.add_prefix_pattern(pattern, prefix)
prefix_patterns << [pattern, prefix]
end

def self.lookup_prefix(path)
_, prefix = prefix_patterns.detect {|pattern, prefix| pattern =~ path }

prefix
end

def self.transform=(transform)
@transform = transform
end

def self.transform
@transform
end

def self.compiler_options
@compiler_options ||= {}
end
end
5 changes: 5 additions & 0 deletions lib/es6_module_transpiler/rails/version.rb
@@ -0,0 +1,5 @@
module ES6ModuleTranspiler
module Rails
VERSION = '0.4.0'
end
end
3 changes: 3 additions & 0 deletions lib/es6_module_transpiler/sprockets.rb
@@ -0,0 +1,3 @@
require 'sprockets'

Sprockets.register_engine '.es6', Tilt::ES6ModuleTranspilerTemplate

0 comments on commit c3ccc3e

Please sign in to comment.