@d1g1tal/tsbuild 1.3.1 → 1.4.1

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 CHANGED
@@ -44,7 +44,24 @@ If `declaration` is not enabled, phase 2 is just the esbuild step.
44
44
 
45
45
  ## Quick Start
46
46
 
47
- The only thing tsbuild requires in `tsconfig.json` is an `outDir`. Everything else carries over from your existing config:
47
+ The only thing tsbuild requires in `tsconfig.json` is an `outDir`. Everything else carries over from your existing config.
48
+
49
+ ### Minimal config — no `tsbuild` section needed
50
+
51
+ ```jsonc
52
+ {
53
+ "compilerOptions": {
54
+ "outDir": "./dist"
55
+ // ... your existing TypeScript config
56
+ }
57
+ }
58
+ ```
59
+
60
+ Entry points are inferred from `package.json` automatically, and all dependencies are treated as external by default.
61
+
62
+ ### Bundle a specific package into the output
63
+
64
+ By default, bare specifiers (e.g. `lodash-es`) are kept as external imports. Use `noExternal` to force a package to be inlined into the bundle:
48
65
 
49
66
  ```jsonc
50
67
  {
@@ -52,7 +69,59 @@ The only thing tsbuild requires in `tsconfig.json` is an `outDir`. Everything el
52
69
  "outDir": "./dist"
53
70
  // ... your existing TypeScript config
54
71
  },
55
- "tsbuild": {} // entry points are inferred from package.json automatically
72
+ "tsbuild": {
73
+ "noExternal": ["evicting-cache"] // bundle evicting-cache into the output instead of leaving it as an import
74
+ }
75
+ }
76
+ ```
77
+
78
+ ### Preferred `tsconfig.json` setup — incremental (recommended)
79
+
80
+ `incremental` defaults to `true` in tsbuild unless you explicitly set it to `false` in your `tsconfig.json`. With incremental enabled, TypeScript only re-emits changed files on each build and the declaration cache is preserved across runs, making repeated builds significantly faster.
81
+
82
+ ```jsonc
83
+ {
84
+ "compilerOptions": {
85
+ "outDir": "./dist",
86
+ "declaration": true,
87
+ "incremental": true, // redundant — tsbuild enables this by default, but explicit is clear
88
+ "isolatedDeclarations": true, // recommended: enables faster parallel declaration emit
89
+ "isolatedModules": true,
90
+ "verbatimModuleSyntax": true,
91
+ "strict": true,
92
+ "target": "ESNext",
93
+ "module": "ESNext",
94
+ "moduleResolution": "Bundler", // recommended for library builds processed by a bundler
95
+ // lib controls platform detection — omitting "DOM" targets Node.js (platform: "node").
96
+ // Add "DOM" to target the browser (platform: "browser").
97
+ "lib": ["ESNext"] // Node.js library — no DOM APIs
98
+ // "lib": ["ESNext", "DOM"] // Browser library — includes DOM APIs, sets platform to "browser"
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### Preferred `tsconfig.json` setup — non-incremental
104
+
105
+ Set `incremental: false` to opt out of the `.tsbuildinfo` cache entirely. Every build is a full compilation from scratch. Useful for CI environments where you want deterministic, cache-free output.
106
+
107
+ ```jsonc
108
+ {
109
+ "compilerOptions": {
110
+ "outDir": "./dist",
111
+ "declaration": true,
112
+ "incremental": false, // disables TypeScript's .tsbuildinfo cache and tsbuild's DTS cache
113
+ "isolatedDeclarations": true,
114
+ "isolatedModules": true,
115
+ "verbatimModuleSyntax": true,
116
+ "strict": true,
117
+ "target": "ESNext",
118
+ "module": "ESNext",
119
+ "moduleResolution": "Bundler", // recommended for library builds processed by a bundler
120
+ // lib controls platform detection — omitting "DOM" targets Node.js (platform: "node").
121
+ // Add "DOM" to target the browser (platform: "browser").
122
+ "lib": ["ESNext"] // Node.js library — no DOM APIs
123
+ // "lib": ["ESNext", "DOM"] // Browser library — includes DOM APIs, sets platform to "browser"
124
+ }
56
125
  }
57
126
  ```
58
127
 
@@ -1933,6 +1933,13 @@ var IncrementalBuildCache = class {
1933
1933
  isBuildInfoFile(filePath) {
1934
1934
  return filePath === this.buildInfoPath;
1935
1935
  }
1936
+ /**
1937
+ * Checks if the cache is valid (not invalidated).
1938
+ * @returns True if the cache is valid, false if it has been invalidated
1939
+ */
1940
+ isValid() {
1941
+ return !this.invalidated;
1942
+ }
1936
1943
  /**
1937
1944
  * Custom inspection tag for type.
1938
1945
  * @returns The string 'IncrementalBuildCache'
@@ -2091,7 +2098,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2091
2098
  return Files.empty(this.buildConfiguration.outDir);
2092
2099
  }
2093
2100
  async build() {
2094
- Logger.header(`\u{1F680} tsbuild v${"1.3.1"}${this.configuration.compilerOptions.incremental ? " [incremental]" : ""}`);
2101
+ Logger.header(`\u{1F680} tsbuild v${"1.4.1"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2095
2102
  try {
2096
2103
  const processes = [];
2097
2104
  const filesWereEmitted = await this.typeCheck();
@@ -2322,7 +2329,11 @@ var _TypeScriptProject = class _TypeScriptProject {
2322
2329
  try {
2323
2330
  const pkgJson = JSON.parse(packageJsonContent);
2324
2331
  const outDir = typeScriptOptions.compilerOptions?.outDir ?? configResult.config.compilerOptions?.outDir ?? defaultOutDirectory;
2332
+ const hasExportFields = pkgJson.exports !== void 0 || pkgJson.bin !== void 0 || pkgJson.main !== void 0 || pkgJson.module !== void 0;
2325
2333
  inferredEntryPoints = inferEntryPoints(pkgJson, outDir);
2334
+ if (hasExportFields && inferredEntryPoints === void 0) {
2335
+ Logger.warn(`Could not infer entry points from package.json exports (output paths do not match outDir "${outDir}"). Add explicit entryPoints to your tsconfig.json tsbuild configuration.`);
2336
+ }
2326
2337
  } catch {
2327
2338
  }
2328
2339
  }
@@ -2389,7 +2400,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2389
2400
  } else if (await Paths.isFile(resolvedPath)) {
2390
2401
  expandedEntryPoints[name] = resolvedPath;
2391
2402
  } else {
2392
- throw new ConfigurationError(`Entry point does not exist: ${entryPoint}`);
2403
+ throw new ConfigurationError(`Entry point does not exist: ${entryPoint}. Add explicit entryPoints to your tsconfig.json tsbuild configuration.`);
2393
2404
  }
2394
2405
  }
2395
2406
  return expandedEntryPoints;
package/dist/index.d.ts CHANGED
@@ -188,9 +188,15 @@ type CachedDeclaration = {
188
188
  };
189
189
  /** Interface for build cache operations */
190
190
  interface BuildCache {
191
+ /** Invalidates the build cache */
191
192
  invalidate(): void;
193
+ /** Restores cached declaration files into the provided map */
192
194
  restore(target: Map<string, CachedDeclaration>): Promise<void>;
195
+ /** Saves declaration files to the cache */
193
196
  save(source: ReadonlyMap<string, CachedDeclaration>): Promise<void>;
197
+ /** Checks if the cache is valid */
198
+ isValid(): boolean;
199
+ /** Checks if a file path is the TypeScript build info file */
194
200
  isBuildInfoFile(filePath: AbsolutePath): boolean;
195
201
  }
196
202
  type TypeScriptConfiguration = Readonly<PrettyModify<TypeScriptOptions, {
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TypeScriptProject
3
- } from "./KY7JTF4C.js";
3
+ } from "./TY4W6KLM.js";
4
4
  import "./7FPDHUPW.js";
5
5
  export {
6
6
  TypeScriptProject
package/dist/tsbuild.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BuildError,
4
4
  TypeScriptProject
5
- } from "./KY7JTF4C.js";
5
+ } from "./TY4W6KLM.js";
6
6
  import "./7FPDHUPW.js";
7
7
 
8
8
  // src/tsbuild.ts
@@ -30,7 +30,7 @@ if (help) {
30
30
  process.exit(0);
31
31
  }
32
32
  if (version) {
33
- console.log("1.3.1");
33
+ console.log("1.4.1");
34
34
  process.exit(0);
35
35
  }
36
36
  var typeScriptOptions = {
package/package.json CHANGED
@@ -1,8 +1,30 @@
1
1
  {
2
2
  "name": "@d1g1tal/tsbuild",
3
- "version": "1.3.1",
4
- "packageManager": "pnpm@10.30.3",
3
+ "author": "D1g1talEntr0py",
4
+ "version": "1.4.1",
5
+ "license": "MIT",
5
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
+ "homepage": "https://github.com/D1g1talEntr0py/tsbuild#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/D1g1talEntr0py/tsbuild.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/D1g1talEntr0py/tsbuild/issues"
14
+ },
15
+ "maintainers": [
16
+ {
17
+ "name": "D1g1talEntr0py",
18
+ "email": "jason.dimeo@gmail.com"
19
+ }
20
+ ],
21
+ "engines": {
22
+ "node": ">=20.16.0"
23
+ },
24
+ "publishConfig": {
25
+ "registry": "https://registry.npmjs.org",
26
+ "access": "public"
27
+ },
6
28
  "type": "module",
7
29
  "exports": {
8
30
  ".": {
@@ -12,47 +34,13 @@
12
34
  },
13
35
  "files": [
14
36
  "./dist",
15
- "./schema.json"
37
+ "./schema.json",
38
+ "README.md",
39
+ "LICENSE"
16
40
  ],
17
41
  "bin": {
18
42
  "tsbuild": "./dist/tsbuild.js"
19
43
  },
20
- "scripts": {
21
- "prepare": "git config core.hooksPath .githooks",
22
- "build": "tsx ./src/tsbuild.ts",
23
- "build:watch": "tsx ./src/tsbuild.ts --watch",
24
- "type-check": "tsx ./src/tsbuild.ts --noEmit",
25
- "lint": "eslint ./src",
26
- "test": "vitest run",
27
- "test:coverage": "vitest run --coverage",
28
- "prepublishOnly": "pnpm lint && pnpm build"
29
- },
30
- "keywords": [
31
- "typescript",
32
- "build",
33
- "bundler",
34
- "esbuild",
35
- "declarations",
36
- "dts",
37
- "esm"
38
- ],
39
- "author": "D1g1talEntr0py",
40
- "license": "MIT",
41
- "engines": {
42
- "node": ">=20.16.0"
43
- },
44
- "repository": {
45
- "type": "git",
46
- "url": "git+https://github.com/D1g1talEntr0py/tsbuild.git"
47
- },
48
- "publishConfig": {
49
- "registry": "https://registry.npmjs.org",
50
- "access": "public"
51
- },
52
- "bugs": {
53
- "url": "https://github.com/D1g1talEntr0py/tsbuild/issues"
54
- },
55
- "homepage": "https://github.com/D1g1talEntr0py/tsbuild#readme",
56
44
  "dependencies": {
57
45
  "@d1g1tal/watchr": "1.0.0",
58
46
  "esbuild": "^0.27.3",
@@ -60,17 +48,34 @@
60
48
  },
61
49
  "devDependencies": {
62
50
  "@eslint/js": "^10.0.1",
63
- "@types/node": "^25.3.0",
51
+ "@types/node": "^25.3.5",
64
52
  "@typescript-eslint/eslint-plugin": "^8.56.1",
65
53
  "@typescript-eslint/parser": "^8.56.1",
66
54
  "@vitest/coverage-v8": "4.0.18",
67
- "eslint": "^10.0.2",
55
+ "eslint": "^10.0.3",
68
56
  "eslint-plugin-jsdoc": "^62.7.1",
69
57
  "fs-monkey": "^1.1.0",
70
- "memfs": "^4.56.10",
58
+ "memfs": "^4.56.11",
71
59
  "tsx": "^4.21.0",
72
60
  "typescript": "5.9.3",
73
61
  "typescript-eslint": "^8.56.1",
74
62
  "vitest": "^4.0.18"
63
+ },
64
+ "keywords": [
65
+ "typescript",
66
+ "build",
67
+ "bundler",
68
+ "esbuild",
69
+ "declarations",
70
+ "dts",
71
+ "esm"
72
+ ],
73
+ "scripts": {
74
+ "build": "tsx ./src/tsbuild.ts",
75
+ "build:watch": "tsx ./src/tsbuild.ts --watch",
76
+ "type-check": "tsx ./src/tsbuild.ts --noEmit",
77
+ "lint": "eslint ./src",
78
+ "test": "vitest run",
79
+ "test:coverage": "vitest run --coverage"
75
80
  }
76
- }
81
+ }