SuperAPI AI 工具集

tsup

编程与开发

查看项目

更新于 10-16 06:46

技能介绍

tsup 是由 esbuild 驱动的 TypeScript 打包器,主打零配置和快速构建库。安装:npm install --save-dev tsup typescript。基本用法:npx tsup src/index.ts 使用默认配置打包;npx tsup src/index.ts --format esm,cjs --dts 同时输出 ESM 与 CJS 并生成类型声明;npx tsup src/index.ts --watch 进入监听模式。也可用 tsup.config.ts 配合 defineConfig 配置 entry、format、dts、sourcemap、clean、minify、target、outDir 等。支持多入口(数组、对象或 glob)、条件配置(接收 options.watch)、代码分割、minify/terser、环境变量 define/env、banner/footer、CLI shebang、esbuild 插件、自定义 loader 等。package.json 可设置 exports 字段区分 import/require 的类型与入口。适用场景包括 React 库、Node.js 包、CLI 工具及多配置构建(主库+CLI)。限制:资料未提供具体性能数据、收费信息或版本要求;更完整的选项参考见 references/options.md。