1. const chromeManifest = require('../react-devtools-extensions/chrome/manifest.json');
    
  2. const firefoxManifest = require('../react-devtools-extensions/firefox/manifest.json');
    
  3. 
    
  4. const minChromeVersion = parseInt(chromeManifest.minimum_chrome_version, 10);
    
  5. const minFirefoxVersion = parseInt(
    
  6.   firefoxManifest.applications.gecko.strict_min_version,
    
  7.   10,
    
  8. );
    
  9. validateVersion(minChromeVersion);
    
  10. validateVersion(minFirefoxVersion);
    
  11. 
    
  12. function validateVersion(version) {
    
  13.   if (version > 0 && version < 200) {
    
  14.     return;
    
  15.   }
    
  16.   throw new Error('Suspicious browser version in manifest: ' + version);
    
  17. }
    
  18. 
    
  19. module.exports = api => {
    
  20.   const isTest = api.env('test');
    
  21.   const targets = {};
    
  22.   if (isTest) {
    
  23.     targets.node = 'current';
    
  24.   } else {
    
  25.     targets.chrome = minChromeVersion.toString();
    
  26.     targets.firefox = minFirefoxVersion.toString();
    
  27. 
    
  28.     let additionalTargets = process.env.BABEL_CONFIG_ADDITIONAL_TARGETS;
    
  29.     if (additionalTargets) {
    
  30.       additionalTargets = JSON.parse(additionalTargets);
    
  31.       for (const target in additionalTargets) {
    
  32.         targets[target] = additionalTargets[target];
    
  33.       }
    
  34.     }
    
  35.   }
    
  36.   const plugins = [
    
  37.     ['@babel/plugin-transform-flow-strip-types'],
    
  38.     ['@babel/plugin-proposal-class-properties', {loose: false}],
    
  39.   ];
    
  40.   if (process.env.NODE_ENV !== 'production') {
    
  41.     plugins.push(['@babel/plugin-transform-react-jsx-source']);
    
  42.   }
    
  43.   return {
    
  44.     plugins,
    
  45.     presets: [
    
  46.       ['@babel/preset-env', {targets}],
    
  47.       '@babel/preset-react',
    
  48.       '@babel/preset-flow',
    
  49.     ],
    
  50.   };
    
  51. };