// Debian build: reproduce upstream's dual CJS/ESM bundle (unbuild) with rollup.
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';

const external = [/^node:/, 'strict-event-emitter-types'];

export default [
  {
    input: 'src/index.ts',
    external,
    output: [
      { file: 'dist/index.mjs', format: 'es', sourcemap: true },
      { file: 'dist/index.cjs', format: 'cjs', sourcemap: true },
    ],
    plugins: [
      typescript({ tsconfig: './tsconfig.build.json', module: 'NodeNext', declaration: false, outDir: 'dist' }),
    ],
  },
  {
    input: 'src/index.ts',
    external,
    output: [
      { file: 'dist/index.d.ts', format: 'es' },
      { file: 'dist/index.d.cts', format: 'es' },
    ],
    plugins: [dts({ tsconfig: './tsconfig.build.json' })],
  },
];
