diff --git a/index.js b/index.js index c3ca5e9fd52..c08fda0e063 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,11 @@ var path = require('path'); var SilentError = require('silent-error'); +function add(options, name, array) { + var option = options[name] = options[name] || []; + option.push.apply(option, array); +} + module.exports = { name: 'ember-data', @@ -22,7 +27,9 @@ module.exports = { init: function() { var bowerDeps = this.project.bowerDependencies(); + var VersionChecker = require('ember-cli-version-checker'); + var options = this.options = this.options || {}; var checker = new VersionChecker(this); // prevent errors when ember-cli-shims is no longer required @@ -84,28 +91,21 @@ module.exports = { var version = require('./lib/version'); var merge = require('broccoli-merge-trees'); - var addonTree = merge([version(), dir]); - - if (process.env.EMBER_ENV === 'production') { - var strippedBuild = require('./lib/stripped-build'); - - // blacklist es6.modules so the modules are not compiled but simply the - // debug statements / features are stripped; this is taken from - // ember-cli-babel: - // https://github.com/babel/ember-cli-babel/blob/master/index.js#L71 - var strippedAddon = strippedBuild('ember-data', addonTree, { - blacklist: ['es6.modules', 'useStrict'] - }); - return this._super.treeForAddon.call(this, strippedAddon); - } - - return this._super.treeForAddon.call(this, addonTree); + return this._super.treeForAddon.call(this, merge([ + version(), + dir + ])); }, included: function(app) { this._super.included.apply(this, arguments); + if (process.env.EMBER_ENV === 'production') { + add(this.options.babel, 'blacklist', ['es6.modules', 'useStrict']); + add(this.options.babel, 'plugins', require('./lib/stripped-build-plugins')()); + } + if (this._forceBowerUsage) { this.app.import({ development: app.bowerDirectory + '/ember-data/ember-data.js', diff --git a/lib/stripped-build-plugins.js b/lib/stripped-build-plugins.js new file mode 100644 index 00000000000..49afe181683 --- /dev/null +++ b/lib/stripped-build-plugins.js @@ -0,0 +1,39 @@ +var fs = require('fs'); +var path = require('path'); +var filterImports = require('babel-plugin-filter-imports'); +var featureFlags = require('babel-plugin-feature-flags'); + +module.exports = function() { + var featuresJsonPath = __dirname + '/../config/features.json'; + var featuresJson = fs.readFileSync(featuresJsonPath, { encoding: 'utf8' }); + var features = JSON.parse(featuresJson); + + // TODO explicitly set all features which are not enabled to `false`, so + // they are stripped --> make this configurable or pass features + // + // for (var feature in features) { + // if (features[feature] !== true) { + // features[feature] = false; + // } + // } + + return [ + featureFlags({ + import: { module: 'ember-data/-private/features' }, + features: features + }), + + filterImports({ + 'ember-data/-private/debug': [ + 'assert', + 'assertPolymorphicType', + 'debug', + 'deprecate', + 'info', + 'runInDebug', + 'warn', + 'debugSeal' + ] + }) + ]; +}; diff --git a/lib/stripped-build.js b/lib/stripped-build.js index 282e93bd9a3..ddb9a0d39db 100644 --- a/lib/stripped-build.js +++ b/lib/stripped-build.js @@ -3,43 +3,11 @@ var path = require('path'); var filterImports = require('babel-plugin-filter-imports'); var featureFlags = require('babel-plugin-feature-flags'); var babelBuild = require('./babel-build'); +var strippedBuildPlugins = require('./stripped-build-plugins'); module.exports = function(packageName, tree, _options) { - var featuresJsonPath = path.join(__dirname, '../config/features.json'); - var featuresJson = fs.readFileSync(featuresJsonPath, { encoding: 'utf8' }); - var features = JSON.parse(featuresJson); - - // TODO explicitly set all features which are not enabled to `false`, so - // they are stripped --> make this configurable or pass features - // - // for (var feature in features) { - // if (features[feature] !== true) { - // features[feature] = false; - // } - // } - - var plugins = [ - featureFlags({ - import: { module: 'ember-data/-private/features' }, - features: features - }), - - filterImports({ - 'ember-data/-private/debug': [ - 'assert', - 'assertPolymorphicType', - 'debug', - 'deprecate', - 'info', - 'runInDebug', - 'warn', - 'debugSeal' - ] - }) - ]; - var options = _options || {}; - options.plugins = plugins; + options.plugins = strippedBuildPlugins(); return babelBuild(packageName, tree, options); }; diff --git a/package.json b/package.json index 8e56d6f973d..e82485b09be 100644 --- a/package.json +++ b/package.json @@ -54,10 +54,10 @@ "broccoli-yuidoc": "^2.1.0", "ember-ajax": "0.7.1", "ember-cli": "2.3.0", - "ember-cli-app-version": "0.5.0", + "ember-cli-app-version": "^1.0.0", "ember-cli-blueprint-test-helpers": "^0.9.0", "ember-cli-dependency-checker": "^1.2.0", - "ember-cli-htmlbars": "0.7.9", + "ember-cli-htmlbars": "^1.0.3", "ember-cli-htmlbars-inline-precompile": "^0.2.0", "ember-cli-inject-live-reload": "^1.3.1", "ember-cli-internal-test-helpers": "^0.8.1",