Es6ModuleTranspiler-Rails

Transpile ES6 Modules in the Rails Asset Pipeline

Installation

Node.js must be installed for the transpiling to happen

gem 'es6_module_transpiler-rails'

Usage

Your modules will transpile are named based upon their directory nesting + filename, as long as the file has the .es6 extension. For example, app/assets/javascripts/controllers/fooController.js.es6

var fooController = function() {
  console.log('fooController is in the house!')
};

export default = fooController;

will compile to

define("controllers/fooController", 
  ["exports"],
  function(__exports__) {
    "use strict";
    var fooController = function() {
      console.log('fooController is in the house!')
    };

    __exports__["default"] = fooController;
  });

Compiling

By default your module will compile to an AMD. If you wish to compile it as a global just make the following switch:

ES6ModuleTranspiler.compile_to = :global

Authors

Brian Cardarella

We are very thankful for the many contributors

Versioning

This gem follows Semantic Versioning

Want to help?

Please do! We are always looking to improve this gem.

DockYard, LLC © 2013

@dockyard

Licensed under the MIT license