tsup.config.ts
988 Bytes
import { defineConfig } from 'tsup';
/**
* api-core 是唯一需要「出 JS 产物」的包:web 子应用走源码 alias(不消费 dist),
* 但原生小程序「构建 npm」只能吃编译后的 CommonJS / 带 main/miniprogram 入口的包,
* 所以这里把纯 TS 源打成单文件 bundle。
*
* - format: ['cjs', 'esm'] —— WeChat 构建 npm 偏好 CJS(走 main / miniprogram),
* web / node 可走 ESM(走 module)。
* - dts: true —— 顺手产出类型声明,供 TS 消费者(不影响 mp 的 JS 消费)。
* - external: ['@uj/contracts'] —— HttpMethod 是 type-only 导入,运行期零耦合;
* 显式 external 让 dts 仅保留类型引用,不把 workspace 包打进 bundle。
* - 本包零运行时依赖,bundle 完全自包含。
*/
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
clean: true,
target: 'es2018',
sourcemap: true,
external: ['@uj/contracts'],
});