@better-builds/ts-duality

中文文档
1.3.2发布于 2026/01/22GPL-3.0-onlyTypeScriptESM + CJS近 30 天下载 7266

无BS,用于汇编无害环境管理和CJS目标中的TypeScript代码,以及适当接通软件包.json exports.

中文使用文档
文档目录6 节
  1. 开始
  2. 安装
  3. API 密码
  4. 国 际
  5. Java 脚本 API
  6. 捐款

质量

一种稍有倾向但无BS, 方便用于将TypeScript代码编入无害环境管理和A no BS, 方便用于将TypeScript代码编入无害环境管理和CJS两个目标,以及适当接通包件. json出口.

ts-duality 这将为你做全程的歌唱和舞蹈, 默认情况下,它将使CJS和无害环境管理. 您可以选择针对一个特定的输出, 或者你可以仅仅编译而不生成打字.

ts-duality 还将使社区司法分析和无害环境管理模块正确无误 .cjs 财务报告和审定财务报表 .esm 格式,同时确保您代码中使用的任何相对导入被重写为也指向 .cjs 财务报告和审定财务报表 .esm 文档.

TypeScript 检测到的每个文件,作为您来源的一部分,都将自动添加到您的 package.json#exports,如果有一个索引文件,此文件将作为您的 package.json#main 财务报告和审定财务报表 package.json#module。 。 。 .

举个例子,这看起来像什么, 检查一下 软件包.json 文件 页:1 ts-duality。 。 。 . ts-duality 自行编译.

开始

安装

安装 ts-duality 您最喜欢的软件包管理器 :

无

npm i @better-builds/ts-duality --save-dev

小时

pnpm i @better-builds/ts-duality -D

线条

yarn add @better-builds/ts-duality --dev

包头

bun add @better-builds/ts-duality -d

API 密码

国 际

运行 npx ts-duality (或相当于你选择的包管理者) 踢出一个建筑.

查看帮助菜单及其所有选项, 运行 npx ts-duality --help数字 :

Options:
  --version            Show version number                             [boolean]
  --clean              if set, will clean out the build dirs before compiling
                       anything                       [boolean] [default: false]
  --copyOtherFiles     if true, will copy any non source files (anything that
                       doesn't end with .js, .jsx, .cjs, .mts, .ts or .tsx)
                       to the output folder, while maintining the location of
                       the files
                       to match where they were in your source folder
                                                      [boolean] [default: false]
  --cwd                the CWD to use when building
       [string] [default: "/Users/benjaminduran/dddddddd/opensource/ts-duality"]
  --jsx                the type of JSX runtime to use when compiling your code
   [string] [choices: "automatic", "classic", "preserve"] [default: "automatic"]
  --noCjs              if true, will not build the CommonJS variant of this
                       package                        [boolean] [default: false]
  --noDts              if set, will not write typescript typings
                                                      [boolean] [default: false]
  --noEsm              if true, will not build the ESM variant of this package
                                                      [boolean] [default: false]
  --noGenerateExports
                        if true, will NOT modify your package.json file
                        to generate main, module and exports fields.

                        Use this if you just want a simple transpiler that
                        strips your typescript types.
                                                      [boolean] [default: false]
  --noStripLeading     if set, will not strip the leading, last common portion
                       of your input file paths when writing output file paths.
                       if your code is located in a "src/" folder, you want to
                       leave this unset.
                       NOTE: this does *not* affect how typescript compiles
                       typings, so if your tsconfig#compilerOptions#rootDir is
                       misconfigured,
                       or you are mixing roots from across your package, your
                       typings might end up in a different folder than you
                       expect                         [boolean] [default: false]
  --outDir             the folder where the built files will be written
                                                      [string] [default: "dist"]
  --tsconfig           if provided, will explicitly use this tsconfig.json
                       location instead of searching for a tsconfig.build.json
                       or a plain tsconfig.json                         [string]
  --watch              if set, will automatically watch for any changes to this
                       library and rebuild, making it easier for you to consume
                       changes in the monorepo while doing local development
                                                      [boolean] [default: false]
  --help               Show help                                       [boolean]

Java 脚本 API

如果你更愿意与 ts-duality 在 JavaScript 或 TypeScript 文件中,您可以导入其 API 如下 :

javascript
import { buildTsPackage } from '@better-builds/ts-duality';

await buildTsPackage({ /* accepts the same options as the CLI */ });

捐款

确保您在环境中安装了适当的工具版本 . 您可以在 . 工具转换 文档.

如果你喜欢,你可以使用 爱 用于快速启动, 只需克隆此寄存器, 然后运行 mise x -- bun ci 以安装所有依赖.

一旦安装了它们,就马上运行 bun ci 在这个项目中开始开发.

版本与发布记录

@better-builds/ts-duality 共发布 48 个版本,首次发布于 2025/10/28;过去 12 个月发布了 18 个版本。

版本发布日期距今
1.3.2latest2026/01/229 个月前
1.3.2-beta.1beta2026/01/229 个月前
1.3.12026/01/219 个月前
1.3.02026/01/199 个月前
1.2.52026/01/149 个月前
1.2.32026/01/149 个月前

关于 @better-builds/ts-duality 的常见问题

@better-builds/ts-duality 是什么?

无BS,用于汇编无害环境管理和CJS目标中的TypeScript代码,以及适当接通软件包.json exports.

如何安装 @better-builds/ts-duality?

在项目目录运行 npm install @better-builds/ts-duality,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:typescript(^5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 ts-duality,可以用 npx ts-duality 直接运行。

@better-builds/ts-duality 支持 TypeScript 吗?

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

@better-builds/ts-duality 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@better-builds/ts-duality 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.14.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@better-builds/ts-duality 可以商用吗?

@better-builds/ts-duality 使用 GPL-3.0-only 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@better-builds/ts-duality 的下载量有多少?

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

@better-builds/ts-duality 还在维护吗?

最新版本 1.3.2 发布于 2026/01/22(9 个月前);至今共发布 48 个版本,其中过去 12 个月发布了 18 个;首次发布于 2025/10/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。