No commit activity in last 3 years
No release in over 3 years
Ruby ES6 Module Transpiler is a bridge to the JS ES6 Module Transpiler
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
>= 0

Runtime

>= 0
 Project Readme

RubyEs6ModuleTranspiler

ES6 Module Transpiler Ruby Gem, a handy little gem to help convert your ES6 code into CommonJS, AMD or YUI formats using Square's ES6 Module Transpiler.

Installation

Add this line to your application's Gemfile:

gem 'ruby_es6_module_transpiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install ruby_es6_module_transpiler

Usage

Note that Node.js is required for the transpiling.

Add the necessary require to the file in which the gem is needed

require 'ruby_es6_module_transpiler'

Call transpile with ES6 code. By default, it will transpile to AMD. For example, calling

js_code = <<-JS
import { get, set } from 'ember';
JS

RubyES6ModuleTranspiler.transpile(js_code)

will return

define(
["ember"],
function(__dependency1__) {
  "use strict";
  var get = __dependency1__.get;
  var set = __dependency1__.set;
});

You can also add in extra options like so:

js_code = <<-JS
import { get, set } from 'ember';
JS

RubyES6ModuleTranspiler.transpile(js_code, { type: "Globals", global: "renamed"})

which returns

(function(__dependency1__) {
  "use strict";
  var get = __dependency1__.get;
  var set = __dependency1__.set;
})(renamed.ember);

Check out Square's ES6 Module Transpiler for more info on the various options available.

Contributing

Feedback and PRs always welcome!

To submit a PR:

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Legal

Licensed under the MIT license

Extra

Please also check out the the Rails gem and a rake pipeline filter that uses this gem!