44 lines
988 B
TypeScript
44 lines
988 B
TypeScript
import { nodeResolve } from "@rollup/plugin-node-resolve"
|
|
import { defineConfig } from "rollup"
|
|
import cleanup from "rollup-plugin-cleanup"
|
|
import ts from "rollup-plugin-ts"
|
|
import pkg from "./package.json" assert { type: "json" }
|
|
|
|
|
|
export const createBundleConfig = (
|
|
input: string,
|
|
name: keyof typeof pkg.exports,
|
|
) =>
|
|
defineConfig({
|
|
input,
|
|
|
|
output: [
|
|
{
|
|
file: pkg.exports[name].import.default,
|
|
format: "esm",
|
|
},
|
|
{
|
|
file: pkg.exports[name].require.default,
|
|
format: "cjs",
|
|
},
|
|
],
|
|
|
|
external: id => !/^[./]/.test(id),
|
|
|
|
plugins: [
|
|
nodeResolve(),
|
|
ts(),
|
|
|
|
cleanup({
|
|
comments: "jsdoc",
|
|
extensions: ["ts"],
|
|
}),
|
|
],
|
|
})
|
|
|
|
|
|
export default [
|
|
createBundleConfig("src/lib.ts", "."),
|
|
createBundleConfig("src/schema/lib.ts", "."),
|
|
]
|