@cosyte/tsup-config

中文文档
0.1.3发布于 2026/11/09MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 5853

Shared tsup build config (dual ESM + CJS, ES2023) for @cosyte/* libraries.

原始使用文档
文档目录10 节
  1. Why this exists
  2. Status
  3. Install
  4. Usage
  5. Entry points
  6. Overrides
  7. PHI and safety
  8. Compatibility
  9. Contributing
  10. License
The Cosyte logo on its own white ground: the icon beside the word Cosyte.

@cosyte/tsup-config

One dual-format build baseline, so every Cosyte library packs the same way.

npm version CI License: MIT Node

Shared tsup build config (dual ESM + CJS, ES2023) for @cosyte/* libraries.

Why this exists

Dual-format publishing is where a library quietly breaks: the ESM build resolves, the CJS build does not, the .d.ts files point at the wrong one, and nobody finds out until a consumer on the other module system installs it. Getting that right once and copying the config into ten repositories means getting it wrong in nine of them eventually.

The nearest alternative is a hand-written tsup.config.ts per repository. This is the same baseline as a published package instead, so a fix to the out-extension or the target reaches every library that uses it as a version bump.

Status

@cosyte/tsup-config is on the Cosyte 0.1.x line: the public API is settled and bump types follow ordinary semver.

Still moving: the compile target and the treeshake and splitting settings, all three of which change what a consumer's published artifact looks like. The cosyteTsup(options) shape itself is the part least likely to move.

Install

pnpm add -D @cosyte/tsup-config tsup

tsup (8 or 9) is a peer dependency. Node >=22.14; tsup 9 itself needs 22.18 or later. ESM only.

Usage

tsup.config.ts is one call, and entry is the one option every consumer supplies, because only the package knows what it builds:

import { cosyteTsup } from "@cosyte/tsup-config";

const config = cosyteTsup({ entry: ["src/index.ts"] });
config.format; // => ["esm", "cjs"]
config.outExtension({ format: "esm" }); // => { js: ".mjs" }

Export that object as the file's default (export default cosyteTsup({ entry: ["src/index.ts"] })) and everything else is the enforced standard.

Pair it with @arethetypeswrong/cli (attw) as a publish gate. A dual build that emits the wrong declaration for one of its two module systems still packs and still publishes; attw is what turns that into a red before it reaches npm.

Entry points

entry pointwhat it is
@cosyte/tsup-configthe cosyteTsup(overrides?) factory, returning a tsup config object

One entry point, so @cosyte/tsup-config is the only specifier a consumer ever writes.

Overrides

Anything in tsup's own Options can be passed to cosyteTsup and is merged over the baseline, so adding a second entry point or switching a format off is one argument:

export default cosyteTsup({
  entry: ["src/index.ts", "src/perf/index.ts"],
  sourcemap: false,
});

The merge is shallow and the overrides win, so nothing here is unreachable. That is deliberate: a build config that cannot be adjusted per package is one a package works around by not using it. The baseline is what you get for free, not what you are held to.

PHI and safety

This package is build configuration. It shapes how a library is compiled and packed, reads no runtime input, and never sees patient data: nothing here logs, retains or transmits anything.

Compatibility

Dual ESM + CJS with .d.ts, ES2023 target, Node platform, treeshake on, splitting off, .mjs and .cjs out-extensions, and sourcemaps. The out-extensions are deliberate: they make each artifact's module system explicit in its filename rather than dependent on the nearest package.json type field.

Contributing

Questions, bug reports and proposals go to the issue tracker. Pull requests are welcome, in cosyte/config, where this package lives.

A change has to clear the required verify job, and a change to the baseline needs a changeset saying what moved: it changes the artifact every consumer publishes.

License

MIT, copyright Cosyte LLC. See LICENSE.

版本与发布记录

@cosyte/tsup-config 共发布 7 个版本,首次发布于 2026/06/26;过去 12 个月发布了 7 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.3latest2026/11/092 天前
0.1.22026/11/082 天前
0.1.12026/11/083 天前
0.1.02026/09/211 个月前
0.0.32026/08/053 个月前
0.0.22026/07/313 个月前

关于 @cosyte/tsup-config 的常见问题

@cosyte/tsup-config 是什么?

Shared tsup build config (dual ESM + CJS, ES2023) for @cosyte/* libraries.

如何安装 @cosyte/tsup-config?

在项目目录运行 npm install @cosyte/tsup-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:tsup(^8.0.0 || ^9.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cosyte/tsup-config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cosyte/tsup-config 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cosyte/tsup-config 可以商用吗?

@cosyte/tsup-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cosyte/tsup-config 的下载量有多少?

根据 npm 官方下载统计,@cosyte/tsup-config 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,853 次,日均约 195 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cosyte/tsup-config 还在维护吗?

最新版本 0.1.3 发布于 2026/11/09(2 天前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/06/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。