<commit_before># ES6ModuleTranspiler-Rails #

[![Build Status](https://secure.travis-ci.org/dockyard/es6_module_transpiler-rails.png?branch=master)](http://travis-ci.org/dockyard/es6_module_transpiler-rails)
[![Dependency Status](https://gemnasium.com/dockyard/es6_module_transpiler-rails.png?travis)](https://gemnasium.com/dockyard/es6_module_transpiler-rails)
[![Code Climate](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails.png)](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails)

Transpile ES6 Modules in the Rails Asset Pipeline

Uses [Square's ES6 Module Transpiler](https://github.com/square/es6-module-transpiler)

## Installation ##

**Node.js must be installed for the transpiling to happen**

```ruby
gem 'es6_module_transpiler-rails'
```

## Usage ##

Your modules will transpile and 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`

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

export default = fooController;
```

will compile to `/assets/controllers/fooController.js`

```js
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. You can also compile it to globals or CommonJS by making the following switch:

```ruby
ES6ModuleTranspiler.compile_to = :globals
# or
ES6ModuleTranspiler.compile_to = :cjs
```

### Custom Module Prefix ###

You can match module names based upon a pattern to apply a prefix to the
name:

```ruby
ES6ModuleTranspiler.prefix_pattern = [/^(controllers|models|views|helpers|routes|router|store)/, 'app']
```

This would match names that start with the pattern and prepend with
`app/`. For example, `controllers/fooController` would now be named
`app/controllers/fooController`.

Note the path is the *logical path* for the asset. For example, if the
path to your asset is
`app/assets/javascripts/controllers/fooController.js.es6` the logical
path is `controllers/fooController`.

## Authors ##

[<NAME>](http://twitter.com/bcardarella)

[We are very thankful for the many contributors](https://github.com/dockyard/es6_module_transpiler-rails/graphs/contributors)

## Versioning ##

This gem follows [Semantic Versioning](http://semver.org)

## Want to help? ##

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

## Legal ##

[DockYard](http://dockyard.com), LLC &copy; 2013

[@dockyard](http://twitter.com/dockyard)
<commit_msg>Update README for  API.<commit_after># ES6ModuleTranspiler-Rails #

[![Build Status](https://secure.travis-ci.org/dockyard/es6_module_transpiler-rails.png?branch=master)](http://travis-ci.org/dockyard/es6_module_transpiler-rails)
[![Dependency Status](https://gemnasium.com/dockyard/es6_module_transpiler-rails.png?travis)](https://gemnasium.com/dockyard/es6_module_transpiler-rails)
[![Code Climate](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails.png)](https://codeclimate.com/github/dockyard/es6_module_transpiler-rails)

Transpile ES6 Modules in the Rails Asset Pipeline

Uses [Square's ES6 Module Transpiler](https://github.com/square/es6-module-transpiler)

## Installation ##

**Node.js must be installed for the transpiling to happen**

```ruby
gem 'es6_module_transpiler-rails'
```

## Usage ##

Your modules will transpile and 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`

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

export default = fooController;
```

will compile to `/assets/controllers/fooController.js`

```js
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. You can also compile it to globals or CommonJS by making the following switch:

```ruby
ES6ModuleTranspiler.compile_to = :globals
# or
ES6ModuleTranspiler.compile_to = :cjs
```

### Custom Module Prefix ###

You can match module names based upon a pattern to apply a prefix to the
name. You can add multiple patterns (which can each have separate prefixes):

```ruby
ES6ModuleTranspiler.add_prefix_pattern /^(controllers|models|views|helpers|routes|router|store)/, 'app'
ES6ModuleTranspiler.add_prefix_pattern /^gui-helpers/, 'gui'
```

This would match names that start with the pattern and prepend with
`app/`. For example, `controllers/fooController` would now be named
`app/controllers/fooController`, and `gui-helpers/bar` would now be
named `gui/gui-helpers/bar`.

Note the path is the *logical path* for the asset. For example, if the
path to your asset is
`app/assets/javascripts/controllers/fooController.js.es6` the logical
path is `controllers/fooController`.

## Authors ##

[<NAME>](http://twitter.com/bcardarella)

[We are very thankful for the many contributors](https://github.com/dockyard/es6_module_transpiler-rails/graphs/contributors)

## Versioning ##

This gem follows [Semantic Versioning](http://semver.org)

## Want to help? ##

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

## Legal ##

[DockYard](http://dockyard.com), LLC &copy; 2013

[@dockyard](http://twitter.com/dockyard)

{'fraction_non_alphanumeric': 0.12917398945518455, 'fraction_numerical': 0.007908611599297012, 'mean_word_length': 5.253846153846154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '33995', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1810, 'n_words': 476}