From 557fcae6b03b36be35d5fb99974fc959c96263e7 Mon Sep 17 00:00:00 2001 From: EGOIST <0x142857@gmail.com> Date: Thu, 25 Nov 2021 22:33:17 +0800 Subject: [PATCH] feat: add `dts.banner` and `dts.footer` options --- package.json | 2 +- src/options.ts | 4 ++++ src/rollup.ts | 2 ++ tsup.config.ts | 4 ++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f70888e..eec01529 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "scripts": { "dev": "npm run build:simple -- --watch", - "build": "tsup src/cli-*.ts src/index.ts src/rollup.ts --clean --dts-resolve --splitting", + "build": "tsup src/cli-*.ts src/index.ts src/rollup.ts --clean --splitting", "prepublishOnly": "npm run build", "test": "npm run build:simple && jest", "//": "Building without dts for speed", diff --git a/src/options.ts b/src/options.ts index ab406053..415fceba 100644 --- a/src/options.ts +++ b/src/options.ts @@ -9,6 +9,10 @@ export type DtsConfig = { resolve?: boolean | (string | RegExp)[] /** Emit declaration files only */ only?: boolean + /** Insert at the top of each output .d.ts file */ + banner?: string + /** Insert at the bottom */ + footer?: string } /** diff --git a/src/rollup.ts b/src/rollup.ts index 66a17774..2e1aa9bf 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -162,6 +162,8 @@ const getRollupConfig = async ( dir: options.outDir || 'dist', format: 'esm', exports: 'named', + banner: dtsOptions.banner, + footer: dtsOptions.footer, }, } } diff --git a/tsup.config.ts b/tsup.config.ts index 9b50415e..f6ba9e3a 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -3,6 +3,10 @@ import { defineConfig } from 'tsup' export default defineConfig({ name: 'tsup', + dts: { + resolve: true, + banner: '// hehe', + }, esbuildPlugins: [ { name: 'patch-rollup-plugin-dts',