import typescript from "@rollup/plugin-typescript";
import dts from "rollup-plugin-dts";
import terser from "@rollup/plugin-terser";

export default [
  // JS builds (CJS + ESM)
  {
    input: "src/index.ts",
    output: [
      {
        file: "dist/index.mjs",
        format: "esm",
        sourcemap: true,
        exports: "auto"
      },
      {
        file: "dist/index.cjs",
        format: "cjs",
        sourcemap: true,
        exports: "auto"
      }
    ],
    plugins: [
      typescript({
        target: "ES2020", // closest to Node 12
        module: "ESNext",
        removeComments: true
      }),
      terser()
    ]
  },

  // Type declarations
  {
    input: "src/index.ts",
    output: { file: "dist/index.d.ts", format: "es" },
    plugins: [dts()]
  }
];
