bun-plugin-dtsx
Version:
A Bun Bundler plugin that auto generates your DTS types extremely fast.
38 lines (37 loc) • 845 B
JavaScript
// @bun
// src/index.ts
import process from "process";
import { generate } from "@stacksjs/dtsx";
function dts(options = {
root: "./src",
outdir: "./dist"
}) {
return {
name: "bun-plugin-dtsx",
async setup(build) {
const config = normalizeConfig(options, build);
await generate(config);
}
};
}
function normalizeConfig(options, build) {
const root = options.root || build?.config.root;
const outdir = options.outdir || build?.config.outdir;
if (!root) {
throw new Error("[bun-plugin-dtsx] Root directory is required");
}
return {
...options,
cwd: options.cwd || process.cwd(),
root,
entrypoints: options.entrypoints || ["**/*.ts"],
outdir,
clean: options.clean,
tsconfigPath: options.tsconfigPath
};
}
var src_default = dts;
export {
dts,
src_default as default
};