Module: RubyES6ModuleTranspiler

Defined in:
lib/ruby_es6_module_transpiler.rb

Constant Summary collapse

Node =
::ExecJS::ExternalRuntime.new(
  name: 'Node.js (V8)',
  command: ['nodejs', 'node'],
  runner_path: File.expand_path('../support/es6-node-runner.js', __FILE__),
  encoding: 'UTF-8'
)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.js_codeObject

Returns the value of attribute js_code.



8
9
10
# File 'lib/ruby_es6_module_transpiler.rb', line 8

def js_code
  @js_code
end

Class Method Details

.transpile(code, options = {}) ⇒ Object

accepts amd, cjs, yui, or global. defaults to amd.



18
19
20
21
# File 'lib/ruby_es6_module_transpiler.rb', line 18

def transpile(code, options = {})
  @js_code = code
  Node.exec(generate_source(options))
end