const {babel} = require('@rollup/plugin-babel');

const babelPlugin = babel({
  babelHelpers: 'bundled',
  extensions: ['.js'],
});

const sourceFiles = [
  'src/api.js',
  'src/full.js',
  'src/fullLangRegionMap.js',
  'src/langRegionMap.js',
  'src/main.js',
  'src/regionDayMap.js',
];

module.exports = [
  {
    input: sourceFiles,
    output: {
      dir: 'dist/commonjs',
      format: 'cjs',
      exports: 'named',
      preserveModules: true,
      preserveModulesRoot: 'src',
      sourcemap: true,
    },
    plugins: [babelPlugin],
  },
  {
    input: sourceFiles,
    output: {
      dir: 'dist/es-module',
      format: 'es',
      preserveModules: true,
      preserveModulesRoot: 'src',
      sourcemap: true,
    },
  },
  {
    input: 'src/main.js',
    output: {
      file: 'dist/main.js',
      format: 'umd',
      name: 'weekstart',
      exports: 'named',
      sourcemap: true,
    },
    plugins: [babelPlugin],
  },
  {
    input: 'src/full.js',
    output: {
      file: 'dist/full.js',
      format: 'umd',
      name: 'weekstart',
      exports: 'named',
      sourcemap: true,
    },
    plugins: [babelPlugin],
  },
];
