import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import alias from '@rollup/plugin-alias';
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import replace from "@rollup/plugin-replace";

const packageJson = require("./package.json");


export default {
  input: 'src/index.tsx',
  output: [
    {
      file: packageJson.main,
      format: 'cjs',
      sourcemap: true
    },
    {
      file: packageJson.module,
      format: 'esm',
      sourcemap: true
    },
    {
      file: 'dist/index.system.js',
      format: 'system',
      sourcemap: true
    }
  ],
  plugins: [
    peerDepsExternal(),
    typescript(),
    resolve(),
    commonjs(),
    json(),
    alias({
      entries: [
        { find: 'react-native', replacement: 'react-native-web' },
      ],
    }),
    replace({
      'process.env.NODE_ENV': JSON.stringify('production')
    })
  ],
};
