Skip to content

Commit

Permalink
Introduce a new experiment constant list (#24616)
Browse files Browse the repository at this point in the history
* backup experiment constant list

* lint & clean list
  • Loading branch information
zhouyx committed Sep 18, 2019
1 parent 3de54d5 commit 5309266
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions build-system/build.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
const argv = require('minimist')(process.argv.slice(2));
const experimentsConfig = require('./global-configs/experiments-config.json');

const experimentsConstantBackup = require('./global-configs/experiments-const.json');
const localPlugin = name =>
require.resolve(`./babel-plugins/babel-plugin-${name}`);

Expand Down Expand Up @@ -96,7 +96,6 @@ function getReplacePlugin() {
);
}
}

const experimentDefine =
experimentsConfig[experiment]['defineExperimentConstant'];

Expand All @@ -110,6 +109,18 @@ function getReplacePlugin() {
}
});

// default each backup experiment constant to false as well
Object.keys(experimentsConstantBackup).forEach(experimentDefine => {
function flagExists(element) {
return element['identifierName'] === experimentDefine;
}

// only add default replacement if it already doesn't exist in array
if (experimentDefine && !replacements.some(flagExists)) {
replacements.push(createReplacement(experimentDefine, false));
}
});

return ['minify-replace', {replacements}];
}

Expand Down
2 changes: 2 additions & 0 deletions build-system/global-configs/experiments-const.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}

0 comments on commit 5309266

Please sign in to comment.