Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions lib/models/addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ var Addon = CoreObject.extend({
throw new SilentError('An addon must define a `name` property.');
}

this.options = defaultsDeep(this.options, {
this.__originalOptions = this.options = defaultsDeep(this.options, {
babel: DEFAULT_BABEL_CONFIG
});

var emberCLIBabelConfigKey = this._emberCLIBabelConfigKey();
this.options[emberCLIBabelConfigKey] = defaultsDeep(this.options[emberCLIBabelConfigKey], {
this.__originalOptions[emberCLIBabelConfigKey] = this.options[emberCLIBabelConfigKey] = defaultsDeep(this.options[emberCLIBabelConfigKey], {
compileModules: true
});
},
Expand Down Expand Up @@ -845,13 +845,38 @@ var Addon = CoreObject.extend({
compileAddon: function(tree) {
this._requireBuildPackages();

if (!this.options) {
this._warn(
'Ember CLI addons manage their own module transpilation during the `treeForAddon` processing. ' +
'`' + this.name + '` (found at `' + this.root + '`) has removed `this.options` ' +
'which conflicts with the addons ability to transpile its `addon/` files properly. ' +
'Falling back to default babel configuration options.'
);

this.options = {};
}

if (!this.options.babel) {
this._warn(
'Ember CLI addons manage their own module transpilation during the `treeForAddon` processing. ' +
'`' + this.name + '` (found at `' + this.root + '`) has overridden the `this.options.babel` ' +
'options which conflicts with the addons ability to transpile its `addon/` files properly. ' +
'Falling back to default babel configuration options.'
);

this.options.babel = this.__originalOptions.babel;
}

var emberCLIBabelConfigKey = this._emberCLIBabelConfigKey();
if (!this.options[emberCLIBabelConfigKey].compileModules) {
throw new SilentError(
if (!this.options[emberCLIBabelConfigKey] || !this.options[emberCLIBabelConfigKey].compileModules) {
this._warn(
'Ember CLI addons manage their own module transpilation during the `treeForAddon` processing. ' +
'`' + this.name + '` (found at `' + this.root + '`) has overridden the `this.options.' + emberCLIBabelConfigKey + '.compileModules` ' +
'value which conflicts with the addons ability to transpile its `addon/` files properly.'
);

this.options[emberCLIBabelConfigKey] = this.options[emberCLIBabelConfigKey] || {};
this.options[emberCLIBabelConfigKey].compileModules = true;
}

var addonJs = this.processedAddonJsFiles(tree);
Expand All @@ -860,6 +885,7 @@ var Addon = CoreObject.extend({
var trees = [addonJs, templatesTree].filter(Boolean);

var combinedJSAndTemplates = mergeTrees(trees, {
overwrite: true,
annotation: 'Addon#compileAddon(' + this.name + ') '
});

Expand Down Expand Up @@ -949,7 +975,9 @@ var Addon = CoreObject.extend({
'(most likely `ember-cli-babel`) to in `dependencies` (NOT `devDependencies`) in ' +
'`' + this.name + '`\'s `package.json`.');

processedJsFiles = processModulesOnly(processedJsFiles);
var options = defaultsDeep({}, DEFAULT_BABEL_CONFIG);

processedJsFiles = new Babel(processedJsFiles, options);
}

return processedJsFiles;
Expand Down