Skip to content

Commit

Permalink
Merge pull request #165 from dfreeman/patch-1
Browse files Browse the repository at this point in the history
Include examples for where to put options
  • Loading branch information
rwjblue authored Jul 19, 2017
2 parents 4a04434 + eed8b03 commit 7a57e13
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var app = new EmberApp({
### Options

There are a few different options that may be provided to ember-cli-babel. These options
are typically set in an apps `ember-cli-build.js` file, or in an addons `index.js`.
are typically set in an apps `ember-cli-build.js` file, or in an addon or engine's `index.js`.

```ts
type BabelPlugin = string | [string, any] | [any, any];
Expand Down Expand Up @@ -91,6 +91,39 @@ interface EmberCLIBabelConfig {
}
```

The exact location you specify these options varies depending on the type of project you're working on. As a concrete example, to add `babel-plugin-transform-object-rest-spread` so that your project can use object rest/spread syntax, you would do something like this in an app:

```js
// ember-cli-build.js
var app = new EmberApp(defaults, {
babel: {
plugins: ['transform-object-rest-spread']
}
});
```

In an engine:
```js
// index.js
module.exports = EngineAddon.extend({
babel: {
plugins: ['transform-object-rest-spread']
}
});
```

In an addon:
```js
// index.js
module.exports = {
options: {
babel: {
plugins: ['transform-object-rest-spread']
}
}
};
```

#### Polyfill

Babel comes with a polyfill that includes a custom [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
Expand Down Expand Up @@ -160,24 +193,6 @@ You can add custom plugins to be used during transpilation of the `addon/` or `a
trees by ensuring that your addon's `options.babel` is properly populated (as mentioned above in the
`Options` section).

For example, to add `babel-plugin-transform-object-rest-spread` so that your addon can use object
rest/spread you would do something like this:

```js
module.exports = {
name: 'my-special-addon',

init() {
this._super && this._super.init.apply(this, arguments);

this.options = this.options || {};
this.options.babel = this.options.babel || {};
this.options.babel.plugins = this.options.babel.plugins || [];
this.options.babel.plugins.push('transform-object-rest-spread');
};
}
```

#### Additional Trees

For addons which want additional customizations, they are able to interact with
Expand Down

0 comments on commit 7a57e13

Please sign in to comment.