diff --git a/src/builder/rollup.ts b/src/builder/rollup.ts index d6117b86..34ecc04b 100644 --- a/src/builder/rollup.ts +++ b/src/builder/rollup.ts @@ -1,12 +1,7 @@ import { writeFile, mkdir } from "node:fs/promises"; import { promises as fsp } from "node:fs"; import { pathToFileURL } from "node:url"; -import type { - RollupOptions, - OutputOptions, - OutputChunk, - PreRenderedChunk, -} from "rollup"; +import type { OutputOptions, OutputChunk, PreRenderedChunk } from "rollup"; import { rollup } from "rollup"; import commonjs from "@rollup/plugin-commonjs"; import { nodeResolve } from "@rollup/plugin-node-resolve"; @@ -24,7 +19,7 @@ import { import { resolvePath, resolveModuleExportNames } from "mlly"; import { watch as rollupWatch } from "rollup"; import { arrayIncludes, getpkg, tryResolve, warn } from "../utils"; -import type { BuildContext } from "../types"; +import type { BuildContext, RollupOptions } from "../types"; import { esbuild } from "./plugins/esbuild"; import { JSONPlugin } from "./plugins/json"; import { rawPlugin } from "./plugins/raw"; @@ -265,7 +260,7 @@ export async function rollupBuild(ctx: BuildContext) { // Types if (ctx.options.declaration) { rollupOptions.plugins = [ - rollupOptions.plugins, + ...rollupOptions.plugins, dts(ctx.options.rollup.dts), removeShebangPlugin(), ]; diff --git a/src/types.ts b/src/types.ts index ae593983..e3e59a02 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,11 @@ import type { PackageJson } from "pkg-types"; import type { Hookable } from "hookable"; import type { - RollupOptions, + RollupOptions as _RollupOptions, RollupBuild, OutputOptions, WatcherOptions, + InputPluginOption, } from "rollup"; import type { MkdistOptions } from "mkdist"; import type { Schema } from "untyped"; @@ -297,6 +298,10 @@ export interface UntypedOutputs { declaration?: UntypedOutput; } +export interface RollupOptions extends _RollupOptions { + plugins: InputPluginOption[]; +} + export interface BuildHooks { "build:prepare": (ctx: BuildContext) => void | Promise; "build:before": (ctx: BuildContext) => void | Promise;