import { nodeResolve } from "@rollup/plugin-node-resolve"
import path from "node:path"
import url from "node:url"
import { defineConfig } from "rollup"
import esbuild from "rollup-plugin-esbuild"


const __relativeDirname = path.relative(".", url.fileURLToPath(new URL(".", import.meta.url)))

export default defineConfig({
    input: {
        "entrypoint.bun": path.join(__relativeDirname, "src", "entrypoint.bun.ts"),
        "entrypoint.node": path.join(__relativeDirname, "src", "entrypoint.node.ts"),
    },

    output: {
        dir: path.join(__relativeDirname, "dist"),
        format: "es",
        sourcemap: true,
    },

    external: id => !/^[./]/.test(id) && !/^@website\//.test(id),

    plugins: [
        nodeResolve(),
        esbuild({ minify: true }),
    ],
})
