"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getBabelPlugin = getBabelPlugin;

var _modeUtils = require("../bundler/webpack/common/modeUtils");

var _addDefaultPlugins = require("./addDefaultPlugins");

const babelPluginMapping = {
  removeAttribute: './babel_plugins/removeAttributesPlugin',
  removePropTypes: 'babel-plugin-transform-react-remove-prop-types',
  devConsoleExclude: 'babel-plugin-transform-remove-console'
};
const babelPluginOrder = ['removeAttribute', 'removePropTypes', 'devConsoleExclude'];

function getBabelPlugin(options) {
  const {
    mode
  } = options;
  let customPlugins = [];
  const {
    babelCustomizations
  } = options;

  if ((0, _modeUtils.isProductionMode)(mode)) {
    const configCreator = _addDefaultPlugins.addDefaultPlugins;
    const plugins = babelPluginOrder.map(p => configCreator(babelCustomizations[p], babelPluginMapping[p]));
    customPlugins = plugins;
  }

  return customPlugins.filter(Boolean);
}

;