From 545f0a3445de89bfb21ad960f2c3607704713aca Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Wed, 13 Apr 2016 15:22:13 -0400 Subject: [PATCH] [BUGFIX release] Only setup babel options once. `included` is called for each instance of `EmberApp` created within the consuming applicationm, which means that we would be adding the same plugins if the consuming application happened to be creating two `EmberApp` instances. For example, ember-cli-fastboot currently uses this technique to build both for fastboot AND the normal build. I know of a few other applications that use similar techniques to build two versions of the same `EmberApp` (i.e. a mobile version and a desktop one). This allows us to ensure that `this.options.babel` is only setup once (regardless of how many times `included` is being called) during init. --- index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e23683c1a8a..7850942618e 100644 --- a/index.js +++ b/index.js @@ -98,13 +98,23 @@ module.exports = { ])); }, - included: function(app) { - this._super.included.apply(this, arguments); + _setupBabelOptions() { + if (this._hasSetupBabelOptions) { + return; + } this.options.babel = this.options.babel || {}; add(this.options.babel, 'blacklist', ['es6.modules', 'useStrict']); add(this.options.babel, 'plugins', require('./lib/stripped-build-plugins')(process.env.EMBER_ENV)); + this._hasSetupBabelOptions = true; + }, + + included: function(app) { + this._super.included.apply(this, arguments); + + this._setupBabelOptions(); + if (this._forceBowerUsage) { this.app.import({ development: app.bowerDirectory + '/ember-data/ember-data.js',