Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup feature flagging infrastructure. #4320

Merged
merged 2 commits into from
Apr 12, 2016
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions config/features.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"ds-boolean-transform-allow-null": null,
"ds-finder-include": null,
"ds-finder-include": true,
"ds-improved-ajax": null,
"ds-references": null,
"ds-transform-pass-options": null,
"ds-references": true,
"ds-transform-pass-options": true,
"ds-pushpayload-return": null,
"ds-serialize-ids-and-types": null,
"ds-serialize-ids-and-types": true,
"ds-extended-errors": null,
"ds-links-in-record-array": null
}
8 changes: 3 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ module.exports = {
included: function(app) {
this._super.included.apply(this, arguments);

if (process.env.EMBER_ENV === 'production') {
this.options.babel = this.options.babel || {};
add(this.options.babel, 'blacklist', ['es6.modules', 'useStrict']);
add(this.options.babel, 'plugins', require('./lib/stripped-build-plugins')());
}
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));

if (this._forceBowerUsage) {
this.app.import({
Expand Down
5 changes: 2 additions & 3 deletions lib/javascripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ var path = require('path');
var Funnel = require('broccoli-funnel');
var versionReplace = require('./version-replace');
var fileCreator = require('broccoli-file-creator');
var babelBuild = require('./babel-build');
var strippedBuild = require('./stripped-build');

function debugBuild(packageName, tree) {
var compiled = babelBuild(packageName, tree);
var compiled = strippedBuild(packageName, tree, 'development');

return stew.mv(compiled, packageName);
}
Expand All @@ -24,7 +23,7 @@ function makeStrippedBuild(packageName, tree) {
exclude: ['ember-data/-private/debug.js']
});

var stripped = strippedBuild(packageName, withoutDebug);
var stripped = strippedBuild(packageName, withoutDebug, 'production');

return stew.mv(stripped, packageName);
}
Expand Down
37 changes: 21 additions & 16 deletions lib/stripped-build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var filterImports = require('babel-plugin-filter-imports');
var featureFlags = require('babel-plugin-feature-flags');

module.exports = function() {
module.exports = function(environment) {
var featuresJsonPath = __dirname + '/../config/features.json';
var featuresJson = fs.readFileSync(featuresJsonPath, { encoding: 'utf8' });
var features = JSON.parse(featuresJson);
Expand All @@ -16,24 +16,29 @@ module.exports = function() {
// features[feature] = false;
// }
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can finally remove this comment too, as it is not relevant anymore...

This is just a note, doesn't need to be done within this wonderful PR!


return [
var plugins = [
featureFlags({
import: { module: 'ember-data/-private/features' },
features: features
}),

filterImports({
'ember-data/-private/debug': [
'assert',
'assertPolymorphicType',
'debug',
'deprecate',
'info',
'runInDebug',
'warn',
'debugSeal'
]
})
];

if (environment === 'production') {
plugins.push(
filterImports({
'ember-data/-private/debug': [
'assert',
'assertPolymorphicType',
'debug',
'deprecate',
'info',
'runInDebug',
'warn',
'debugSeal'
]
})
);
}

return plugins;
};
6 changes: 3 additions & 3 deletions lib/stripped-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ 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 options = _options || {};
options.plugins = strippedBuildPlugins();
module.exports = function(packageName, tree, environmentBuildingFor) {
var options = {};
options.plugins = strippedBuildPlugins(environmentBuildingFor);

return babelBuild(packageName, tree, options);
};