Skip to content

Commit

Permalink
Provide annotation to broccoli-babel-transpiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue committed Jun 1, 2017
1 parent 6f2fdc1 commit 4e523f5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Expand Up @@ -121,7 +121,7 @@ module.exports = {
return (this.parent && this.parent.options) || (this.app && this.app.options) || {};
},

_getAddonProvidedConfig: function(addonOptions) {
_parentName() {
let parentName;

if (this.parent) {
Expand All @@ -132,6 +132,10 @@ module.exports = {
}
}

return parentName;
},

_getAddonProvidedConfig(addonOptions) {
let babelOptions = clone(addonOptions.babel || {});

// used only to support using ember-cli-babel@6 at the
Expand Down Expand Up @@ -170,7 +174,12 @@ module.exports = {
let addonProvidedConfig = this._getAddonProvidedConfig(config);
let shouldCompileModules = this._shouldCompileModules(config);

let options = {};
let providedAnnotation = config['ember-cli-babel'] && config['ember-cli-babel'].annotation;

let options = {
annotation: providedAnnotation || `Babel: ${this._parentName()}`
};

let userPlugins = addonProvidedConfig.plugins;
let userPostTransformPlugins = addonProvidedConfig.postTransformPlugins;

Expand Down
27 changes: 27 additions & 0 deletions node-tests/addon-test.js
Expand Up @@ -505,6 +505,33 @@ describe('ember-cli-babel', function() {
expect(result.babelrc).to.be.false;
});

it('provides an annotation including parent name - addon', function() {
this.addon.parent = {
name: 'derpy-herpy'
};
let result = this.addon.buildBabelOptions();
expect(result.annotation).to.include('derpy-herpy');
});

it('provides an annotation including parent name - project', function() {
this.addon.parent = {
name() { return 'derpy-herpy'; }
};
let result = this.addon.buildBabelOptions();
expect(result.annotation).to.include('derpy-herpy');
});

it('uses provided annotation if specified', function() {
let options = {
'ember-cli-babel': {
annotation: 'Hello World!'
}
};

let result = this.addon.buildBabelOptions(options);
expect(result.annotation).to.equal('Hello World!');
});

it('does not include all provided options', function() {
let babelOptions = { blah: true };
let options = {
Expand Down

0 comments on commit 4e523f5

Please sign in to comment.