stalniy/casl

View on GitHub
packages/dx/config/babel.config.mjs

Summary

Maintainability
Test Coverage
const CONFIG = {
  default: {
    plugins: [
      ['@babel/plugin-transform-typescript', {
        allowDeclareFields: false
      }],
      ['@babel/plugin-proposal-class-properties', {
        loose: true
      }],
    ],
  },
  es6: {
    plugins: [
      ['@babel/plugin-proposal-object-rest-spread', {
        loose: true,
        useBuiltIns: true
      }]
    ]
  },
  es5: {
    presets: [
      ['@babel/preset-env', {
        modules: false,
        loose: true,
        targets: {
          browsers: ['last 3 versions']
        }
      }],
    ],
  },
  test: {
    presets: [
      ['@babel/preset-env', {
        loose: true,
        targets: {
          node: '10'
        }
      }]
    ],
  }
};

export default function config(name) {
  if (name === 'default' || !CONFIG[name]) {
    return CONFIG.default;
  }

  const { presets = [], plugins = [] } = CONFIG[name];

  return {
    presets: presets.concat(CONFIG.default.presets || []),
    plugins: plugins.concat(CONFIG.default.plugins || []),
  };
}