@d1g1tal/tsbuild 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -48
- package/dist/{TY4W6KLM.js → 4BKT57QY.js} +6 -4
- package/dist/{LEZQQWX3.js → RBRXNRTQ.js} +1 -1
- package/dist/{7FPDHUPW.js → UYXU5EAU.js} +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/tsbuild.js +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://nodejs.org)
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
10
|
|
|
11
|
-
A TypeScript build tool that combines three tools into one workflow: **TypeScript's type system** for correctness, **esbuild** for speed, and **SWC** for legacy decorator metadata (optional, not installed by default). Built for modern ESM-only projects on Node.js
|
|
11
|
+
A TypeScript build tool that combines three tools into one workflow: **TypeScript's type system** for correctness, **esbuild** for speed, and **SWC** for legacy decorator metadata (optional, not installed by default). Built for modern ESM-only projects on Node.js 22+.
|
|
12
12
|
|
|
13
13
|
TC39 standard decorators are supported natively — no additional dependencies needed. SWC is only required if you are still using `experimentalDecorators` with `emitDecoratorMetadata`.
|
|
14
14
|
|
|
@@ -42,6 +42,46 @@ The build runs in two phases:
|
|
|
42
42
|
|
|
43
43
|
If `declaration` is not enabled, phase 2 is just the esbuild step.
|
|
44
44
|
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
### Global Installation (Recommended for CLI usage)
|
|
48
|
+
|
|
49
|
+
Installing globally makes the `tsbuild` command available in your terminal across all projects:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# pnpm
|
|
53
|
+
pnpm add -g @d1g1tal/tsbuild
|
|
54
|
+
|
|
55
|
+
# npm
|
|
56
|
+
npm install -g @d1g1tal/tsbuild
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
With a global install, your projects can use `tsbuild` in `package.json` scripts without adding it as a dependency.
|
|
60
|
+
|
|
61
|
+
### Local Installation (Per-project)
|
|
62
|
+
|
|
63
|
+
Install as a dev dependency for per-project version pinning (recommended for CI/CD environments):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# pnpm
|
|
67
|
+
pnpm add -D @d1g1tal/tsbuild
|
|
68
|
+
|
|
69
|
+
# npm
|
|
70
|
+
npm install -D @d1g1tal/tsbuild
|
|
71
|
+
|
|
72
|
+
# yarn
|
|
73
|
+
yarn add -D @d1g1tal/tsbuild
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`@swc/core` is **not a dependency** and will never be installed automatically. It is only needed if you use `experimentalDecorators` with `emitDecoratorMetadata` — see [Decorator Metadata](#decorator-metadata) for details.
|
|
77
|
+
|
|
78
|
+
> **Note:** When installed only as a local dev dependency, the `tsbuild` command is not available directly in your terminal. Use it through `package.json` scripts (e.g., `pnpm build`) or invoke it explicitly with `pnpm exec tsbuild` / `npx tsbuild`.
|
|
79
|
+
|
|
80
|
+
### Requirements
|
|
81
|
+
|
|
82
|
+
- **Node.js**: >=22.0.0
|
|
83
|
+
- **pnpm**: >=10.13.0 (if using corepack)
|
|
84
|
+
|
|
45
85
|
## Quick Start
|
|
46
86
|
|
|
47
87
|
The only thing tsbuild requires in `tsconfig.json` is an `outDir`. Everything else carries over from your existing config.
|
|
@@ -141,47 +181,7 @@ Or if installed locally as a dev dependency, add a script to `package.json` and
|
|
|
141
181
|
pnpm build
|
|
142
182
|
```
|
|
143
183
|
|
|
144
|
-
That's it. tsbuild reads your `compilerOptions`, infers entry points from your `package.json`, and builds. See [Configuration Options](#configuration-options) for everything you can
|
|
145
|
-
|
|
146
|
-
## Installation
|
|
147
|
-
|
|
148
|
-
### Global Installation (Recommended for CLI usage)
|
|
149
|
-
|
|
150
|
-
Installing globally makes the `tsbuild` command available in your terminal across all projects:
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
# pnpm
|
|
154
|
-
pnpm add -g @d1g1tal/tsbuild
|
|
155
|
-
|
|
156
|
-
# npm
|
|
157
|
-
npm install -g @d1g1tal/tsbuild
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
With a global install, your projects can use `tsbuild` in `package.json` scripts without adding it as a dependency.
|
|
161
|
-
|
|
162
|
-
### Local Installation (Per-project)
|
|
163
|
-
|
|
164
|
-
Install as a dev dependency for per-project version pinning (recommended for CI/CD environments):
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
# pnpm
|
|
168
|
-
pnpm add -D @d1g1tal/tsbuild
|
|
169
|
-
|
|
170
|
-
# npm
|
|
171
|
-
npm install -D @d1g1tal/tsbuild
|
|
172
|
-
|
|
173
|
-
# yarn
|
|
174
|
-
yarn add -D @d1g1tal/tsbuild
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
`@swc/core` is **not a dependency** and will never be installed automatically. It is only needed if you use `experimentalDecorators` with `emitDecoratorMetadata` — see [Decorator Metadata](#decorator-metadata) for details.
|
|
178
|
-
|
|
179
|
-
> **Note:** When installed only as a local dev dependency, the `tsbuild` command is not available directly in your terminal. Use it through `package.json` scripts (e.g., `pnpm build`) or invoke it explicitly with `pnpm exec tsbuild` / `npx tsbuild`.
|
|
180
|
-
|
|
181
|
-
### Requirements
|
|
182
|
-
|
|
183
|
-
- **Node.js**: >=20.16.0
|
|
184
|
-
- **pnpm**: >=9.0.0
|
|
184
|
+
That's it. tsbuild reads your `compilerOptions`, infers entry points from your `package.json`, and builds. See [Configuration Options](#configuration-options) for everything you can customize.
|
|
185
185
|
|
|
186
186
|
## Usage
|
|
187
187
|
|
|
@@ -191,7 +191,7 @@ yarn add -D @d1g1tal/tsbuild
|
|
|
191
191
|
|
|
192
192
|
Because tsbuild uses the TypeScript compiler API directly, it reads your `compilerOptions` automatically. There is no need to re-declare `target`, `module`, `lib`, `strict`, `paths`, `moduleResolution`, `baseUrl`, or any other TypeScript settings in a separate config — they are already in your `tsconfig.json`, and tsbuild honours them as-is.
|
|
193
193
|
|
|
194
|
-
The `tsbuild` section only covers options that don't belong in `compilerOptions`: bundling
|
|
194
|
+
The `tsbuild` section only covers options that don't belong in `compilerOptions`: bundling behavior, entry points, watch mode, output formatting, and similar build-specific settings.
|
|
195
195
|
|
|
196
196
|
This means your type-checker and your build always use the exact same TypeScript configuration — no drift, no duplication.
|
|
197
197
|
|
|
@@ -202,7 +202,7 @@ Declaration generation is **not required**. If `declaration: true` is already se
|
|
|
202
202
|
|
|
203
203
|
Everything else carries over automatically.
|
|
204
204
|
|
|
205
|
-
Add a `tsbuild` property to your `tsconfig.json` with only the options you need to
|
|
205
|
+
Add a `tsbuild` property to your `tsconfig.json` with only the options you need to customize:
|
|
206
206
|
|
|
207
207
|
```jsonc
|
|
208
208
|
{
|
|
@@ -284,17 +284,17 @@ tsbuild uses two separate caches to speed up repeated builds, and two flags to c
|
|
|
284
284
|
|
|
285
285
|
### How it works
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
Incremental compilation is **enabled by default** — no configuration needed. To opt out, explicitly set `incremental: false` in `tsconfig.json`:
|
|
288
288
|
|
|
289
289
|
```jsonc
|
|
290
290
|
{
|
|
291
291
|
"compilerOptions": {
|
|
292
|
-
"incremental":
|
|
292
|
+
"incremental": false // disables TypeScript's .tsbuildinfo cache and tsbuild's DTS cache
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
With
|
|
297
|
+
With incremental enabled, each build maintains two caches inside a `.tsbuild/` directory:
|
|
298
298
|
|
|
299
299
|
| Cache | File | What it stores |
|
|
300
300
|
|-------|------|----------------|
|
|
@@ -303,6 +303,20 @@ With this set, each build maintains two caches inside a `.tsbuild/` directory:
|
|
|
303
303
|
|
|
304
304
|
On each build, TypeScript reads `.tsbuildinfo` to determine what changed and only re-emits those files. Changed `.d.ts` files overwrite their entries in the DTS cache; unchanged entries remain valid. If nothing changed, TypeScript skips emission entirely and the output phase is skipped too — this is why incremental rebuilds with no changes take ~5ms.
|
|
305
305
|
|
|
306
|
+
### Ignoring the cache directory
|
|
307
|
+
|
|
308
|
+
The `.tsbuild/` directory contains build artifacts that should not be committed to source control. Add it to your `.gitignore`:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
echo '.tsbuild/' >> .gitignore
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Or add the entry manually:
|
|
315
|
+
|
|
316
|
+
```gitignore
|
|
317
|
+
.tsbuild/
|
|
318
|
+
```
|
|
319
|
+
|
|
306
320
|
### Flags
|
|
307
321
|
|
|
308
322
|
**`--force` (`-f`)** — Runs the output phase (esbuild + DTS bundling) even when TypeScript detects no changes. Useful when something outside the source files changed (e.g. an environment variable or esbuild config) and you need to regenerate output without touching the caches.
|
|
@@ -510,7 +524,7 @@ When a circular dependency is detected between declaration files, tsbuild emits
|
|
|
510
524
|
|
|
511
525
|
tsbuild is designed for speed:
|
|
512
526
|
|
|
513
|
-
- **Incremental builds** - Only
|
|
527
|
+
- **Incremental builds** - Only recompile changed files
|
|
514
528
|
- **In-memory declarations** - No intermediate disk I/O for `.d.ts` files
|
|
515
529
|
- **Parallel processing** - Declaration bundling and transpilation run in parallel after type checking completes
|
|
516
530
|
- **Smart caching** - Leverages `.tsbuildinfo` for TypeScript incremental compilation
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
toEsTarget,
|
|
30
30
|
toJsxRenderingMode,
|
|
31
31
|
typeMatcher
|
|
32
|
-
} from "./
|
|
32
|
+
} from "./UYXU5EAU.js";
|
|
33
33
|
|
|
34
34
|
// src/errors.ts
|
|
35
35
|
import { SyntaxKind } from "typescript";
|
|
@@ -2098,7 +2098,7 @@ var _TypeScriptProject = class _TypeScriptProject {
|
|
|
2098
2098
|
return Files.empty(this.buildConfiguration.outDir);
|
|
2099
2099
|
}
|
|
2100
2100
|
async build() {
|
|
2101
|
-
Logger.header(`\u{1F680} tsbuild v${"1.
|
|
2101
|
+
Logger.header(`\u{1F680} tsbuild v${"1.5.0"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
|
|
2102
2102
|
try {
|
|
2103
2103
|
const processes = [];
|
|
2104
2104
|
const filesWereEmitted = await this.typeCheck();
|
|
@@ -2157,7 +2157,7 @@ var _TypeScriptProject = class _TypeScriptProject {
|
|
|
2157
2157
|
}
|
|
2158
2158
|
if (this.configuration.compilerOptions.emitDecoratorMetadata) {
|
|
2159
2159
|
try {
|
|
2160
|
-
const { swcDecoratorMetadataPlugin } = await import("./
|
|
2160
|
+
const { swcDecoratorMetadataPlugin } = await import("./RBRXNRTQ.js");
|
|
2161
2161
|
plugins.push(swcDecoratorMetadataPlugin);
|
|
2162
2162
|
} catch {
|
|
2163
2163
|
throw new ConfigurationError("emitDecoratorMetadata is enabled but @swc/core is not installed. Install it with: pnpm add -D @swc/core");
|
|
@@ -2364,7 +2364,9 @@ var _TypeScriptProject = class _TypeScriptProject {
|
|
|
2364
2364
|
compilerOptions: {
|
|
2365
2365
|
...{ outDir: defaultOutDirectory, noEmit: false, sourceMap: false, incremental: true, tsBuildInfoFile: Paths.join(cacheDirectory, buildInfoFile), lib: [] },
|
|
2366
2366
|
...configResult.config.compilerOptions,
|
|
2367
|
-
...typeScriptOptions.compilerOptions
|
|
2367
|
+
...typeScriptOptions.compilerOptions,
|
|
2368
|
+
// Always include 'node' and merge with any user-specified types
|
|
2369
|
+
types: [.../* @__PURE__ */ new Set(["node", ...configResult.config.compilerOptions?.types ?? [], ...typeScriptOptions.compilerOptions?.types ?? []])]
|
|
2368
2370
|
}
|
|
2369
2371
|
};
|
|
2370
2372
|
const { options, fileNames, errors } = parseJsonConfigFileContent(baseConfig, sys2, directory);
|
|
@@ -61,6 +61,8 @@ var compilerOptionOverrides = {
|
|
|
61
61
|
checkJs: false,
|
|
62
62
|
// Skip declaration map generation. TODO - Would love to figure out how to combine them into a single file / entry point
|
|
63
63
|
declarationMap: false,
|
|
64
|
+
// Force .d.ts output to outDir so the bundler can reliably find declaration files
|
|
65
|
+
declarationDir: void 0,
|
|
64
66
|
// Skip type-checking all dependencies
|
|
65
67
|
skipLibCheck: true,
|
|
66
68
|
// Ensure TS2742 errors are visible when `true`. TODO - Figure out how to have this work with a value of `true`
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/tsbuild.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
BuildError,
|
|
4
4
|
TypeScriptProject
|
|
5
|
-
} from "./
|
|
6
|
-
import "./
|
|
5
|
+
} from "./4BKT57QY.js";
|
|
6
|
+
import "./UYXU5EAU.js";
|
|
7
7
|
|
|
8
8
|
// src/tsbuild.ts
|
|
9
9
|
import { sys } from "typescript";
|
|
@@ -30,7 +30,7 @@ if (help) {
|
|
|
30
30
|
process.exit(0);
|
|
31
31
|
}
|
|
32
32
|
if (version) {
|
|
33
|
-
console.log("1.
|
|
33
|
+
console.log("1.5.0");
|
|
34
34
|
process.exit(0);
|
|
35
35
|
}
|
|
36
36
|
var typeScriptOptions = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1g1tal/tsbuild",
|
|
3
3
|
"author": "D1g1talEntr0py",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A fast, ESM-only TypeScript build tool combining the TypeScript API for type checking and declaration generation, esbuild for bundling, and SWC for decorator metadata.",
|
|
7
7
|
"homepage": "https://github.com/D1g1talEntr0py/tsbuild#readme",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
],
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=22.0.0"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"registry": "https://registry.npmjs.org",
|