@d1g1tal/tsbuild 1.5.0 → 1.6.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 CHANGED
@@ -350,7 +350,7 @@ If a directory is provided, all files within will be used as entry points.
350
350
 
351
351
  When `entryPoints` is omitted entirely, tsbuild automatically infers entry points from `package.json` by reverse-mapping output paths back to their source files. Resolution order:
352
352
 
353
- 1. **`exports`** - Subpath export map (wildcard patterns are skipped; `import`/`default` conditions are tried in order)
353
+ 1. **`exports`** - Subpath export map (wildcard patterns are skipped; `import`, `node`, `module`, and `default` conditions are tried in order)
354
354
  2. **`bin`** - Binary entry points
355
355
  3. **`main`** / **`module`** - Legacy fallback (only used when `exports` and `bin` produce no results)
356
356
 
@@ -549,12 +549,12 @@ The TypeScript declaration bundling system was originally inspired by rollup-plu
549
549
  - **[TypeScript](https://www.typescriptlang.org/)** - Type checking, declaration generation, and module resolution
550
550
  - **[SWC](https://swc.rs/)** - Optional decorator metadata transformation
551
551
  - **[magic-string](https://github.com/Rich-Harris/magic-string)** - Efficient source code transformation with sourcemap support
552
- - **[watchr](https://github.com/bevry/watchr)** - File watching for watch mode
552
+ - **[watchr](https://github.com/D1g1talEntr0py/watchr)** - File watching for watch mode
553
553
 
554
554
  ## Limitations
555
555
 
556
556
  - **ESM Only** - No CommonJS support by design
557
- - **Node.js 20.16.0+** - Requires a modern Node.js version
557
+ - **Node.js 22+** - Requires a modern Node.js version
558
558
  - **Personal project** - Works well for my use cases, but hasn't been tested across every environment or edge case
559
559
  - **Plugins are programmatic only** - Custom esbuild plugins can't be declared in `tsconfig.json`; they require using the `TypeScriptProject` API directly
560
560
  - **tsBuildInfoFile Path Changes** - When changing the `tsBuildInfoFile` path in `tsconfig.json`, the old `.tsbuildinfo` file at the previous location will not be automatically cleaned up and must be manually removed
@@ -61,8 +61,6 @@ 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,
66
64
  // Skip type-checking all dependencies
67
65
  skipLibCheck: true,
68
66
  // Ensure TS2742 errors are visible when `true`. TODO - Figure out how to have this work with a value of `true`
@@ -3,7 +3,7 @@ import {
3
3
  Json,
4
4
  Paths,
5
5
  typeScriptExtensionExpression
6
- } from "./UYXU5EAU.js";
6
+ } from "./7FPDHUPW.js";
7
7
 
8
8
  // src/plugins/decorator-metadata.ts
9
9
  import { dirname } from "node:path";
@@ -29,7 +29,7 @@ import {
29
29
  toEsTarget,
30
30
  toJsxRenderingMode,
31
31
  typeMatcher
32
- } from "./UYXU5EAU.js";
32
+ } from "./7FPDHUPW.js";
33
33
 
34
34
  // src/errors.ts
35
35
  import { SyntaxKind } from "typescript";
@@ -318,10 +318,12 @@ var Logger = class _Logger {
318
318
  }
319
319
  /**
320
320
  * Logs a header box with a message.
321
+ * The header is styled with a cyan border and the message is centered inside. ANSI escape codes are stripped from the message when calculating the width to ensure proper formatting.
322
+ * This ensures the header box is sized correctly even when the message contains color codes or other formatting.
321
323
  * @param message The message to display in the header.
322
324
  */
323
325
  static header(message) {
324
- const innerWidth = message.length + 2;
326
+ const innerWidth = message.replace(new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g"), "").length + 2;
325
327
  console.log(TextFormat.cyan(`\u256D${"\u2500".repeat(innerWidth)}\u256E${newLine}\u2502 ${message} \u2502${newLine}\u2570${"\u2500".repeat(innerWidth)}\u256F`));
326
328
  }
327
329
  /**
@@ -345,10 +347,14 @@ var Logger = class _Logger {
345
347
  * @param steps The sub-steps to log.
346
348
  */
347
349
  static subSteps(steps) {
348
- const maxNameLength = steps.reduce((max, { name }) => Math.max(max, name.length), 0);
349
- const maxDurationLength = steps.reduce((max, { duration }) => Math.max(max, duration.length), 0);
350
- for (let i = 0, length = steps.length; i < length; i++) {
351
- const { name, duration } = steps[i];
350
+ const visible = steps.filter(({ ms }) => ms >= 5);
351
+ if (visible.length === 0) {
352
+ return;
353
+ }
354
+ const maxNameLength = visible.reduce((max, { name }) => Math.max(max, name.length), 0);
355
+ const maxDurationLength = visible.reduce((max, { duration }) => Math.max(max, duration.length), 0);
356
+ for (let i = 0, length = visible.length; i < length; i++) {
357
+ const { name, duration } = visible[i];
352
358
  const prefix = i === length - 1 ? " \u2514\u2500" : " \u251C\u2500";
353
359
  console.log(`${TextFormat.dim(prefix)} ${TextFormat.bold(name.padEnd(maxNameLength))} ${TextFormat.cyan(duration.padStart(maxDurationLength))}`);
354
360
  }
@@ -1595,8 +1601,8 @@ _PerformanceLogger = __decorateElement(_init, 0, "PerformanceLogger", _Performan
1595
1601
  __runInitializers(_init, 1, _PerformanceLogger);
1596
1602
  var PerformanceLogger = _PerformanceLogger;
1597
1603
  var measure = new PerformanceLogger().measure;
1598
- function addPerformanceStep(name, duration) {
1599
- pendingSteps.push({ name, duration });
1604
+ function addPerformanceStep(name, ms) {
1605
+ pendingSteps.push({ name, duration: `${ms}ms`, ms });
1600
1606
  }
1601
1607
 
1602
1608
  // src/decorators/debounce.ts
@@ -1831,9 +1837,9 @@ var FileManager = class {
1831
1837
  this.pendingBuildInfo = { path: filePath, text };
1832
1838
  } else {
1833
1839
  this.pendingFiles.push({ path: filePath, text });
1834
- }
1835
- if (!this.hasEmittedFiles) {
1836
- this.hasEmittedFiles = true;
1840
+ if (!this.hasEmittedFiles) {
1841
+ this.hasEmittedFiles = true;
1842
+ }
1837
1843
  }
1838
1844
  };
1839
1845
  /**
@@ -2059,7 +2065,7 @@ var globCharacters = /[*?\\[\]!].*$/;
2059
2065
  var domPredicate = (lib) => lib.toUpperCase() === "DOM";
2060
2066
  var diagnosticsHost = { getNewLine: () => sys2.newLine, getCurrentDirectory: sys2.getCurrentDirectory, getCanonicalFileName: (fileName) => fileName };
2061
2067
  var _triggerRebuild_dec, _processDeclarations_dec, _transpile_dec, _typeCheck_dec, _build_dec, _TypeScriptProject_decorators, _init3;
2062
- _TypeScriptProject_decorators = [closeOnExit], _build_dec = [measure("Build")], _typeCheck_dec = [measure("Type-checking")], _transpile_dec = [measure("Transpile", true)], _processDeclarations_dec = [measure("Process Declarations", true)], _triggerRebuild_dec = [debounce(100)];
2068
+ _TypeScriptProject_decorators = [closeOnExit], _build_dec = [measure("Build")], _typeCheck_dec = [measure("Type-checking")], _transpile_dec = [measure("Transpile", true)], _processDeclarations_dec = [measure("Bundle Declarations", true)], _triggerRebuild_dec = [debounce(100)];
2063
2069
  var _TypeScriptProject = class _TypeScriptProject {
2064
2070
  /**
2065
2071
  * Creates a TypeScript project and prepares it for building/bundling.
@@ -2098,7 +2104,8 @@ var _TypeScriptProject = class _TypeScriptProject {
2098
2104
  return Files.empty(this.buildConfiguration.outDir);
2099
2105
  }
2100
2106
  async build() {
2101
- Logger.header(`\u{1F680} tsbuild v${"1.5.0"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2107
+ const tsLogo = TextFormat.bgBlue(TextFormat.bold(TextFormat.whiteBright(" TS ")));
2108
+ Logger.header(`${tsLogo} tsbuild v${"1.6.0"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2102
2109
  try {
2103
2110
  const processes = [];
2104
2111
  const filesWereEmitted = await this.typeCheck();
@@ -2148,7 +2155,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2148
2155
  performance2.mark("finalize:start");
2149
2156
  const result = this.fileManager.finalize();
2150
2157
  addPerformanceStep("Finalize", _TypeScriptProject.elapsed("finalize:start"));
2151
- return result;
2158
+ return result || !this.configuration.compilerOptions.declaration;
2152
2159
  }
2153
2160
  async transpile() {
2154
2161
  const plugins = [outputPlugin()];
@@ -2157,7 +2164,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2157
2164
  }
2158
2165
  if (this.configuration.compilerOptions.emitDecoratorMetadata) {
2159
2166
  try {
2160
- const { swcDecoratorMetadataPlugin } = await import("./RBRXNRTQ.js");
2167
+ const { swcDecoratorMetadataPlugin } = await import("./LEZQQWX3.js");
2161
2168
  plugins.push(swcDecoratorMetadataPlugin);
2162
2169
  } catch {
2163
2170
  throw new ConfigurationError("emitDecoratorMetadata is enabled but @swc/core is not installed. Install it with: pnpm add -D @swc/core");
@@ -2484,14 +2491,14 @@ var _TypeScriptProject = class _TypeScriptProject {
2484
2491
  /**
2485
2492
  * Calculates elapsed time since a performance mark and clears the mark.
2486
2493
  * @param markName - The name of the performance mark to measure from
2487
- * @returns Formatted elapsed time string (e.g., '42ms')
2494
+ * @returns Elapsed time in milliseconds
2488
2495
  */
2489
2496
  static elapsed(markName) {
2490
2497
  const endMark = performance2.mark(`${markName}:end`);
2491
- const duration = endMark.startTime - performance2.getEntriesByName(markName, "mark")[0].startTime;
2498
+ const ms = ~~(endMark.startTime - performance2.getEntriesByName(markName, "mark")[0].startTime);
2492
2499
  performance2.clearMarks(markName);
2493
2500
  performance2.clearMarks(endMark.name);
2494
- return `${~~duration}ms`;
2501
+ return ms;
2495
2502
  }
2496
2503
  };
2497
2504
  _init3 = __decoratorStart(null);
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ type ClosableConstructor = Constructor<any[], Closable>;
44
44
  type PerformanceSubStep = {
45
45
  name: string;
46
46
  duration: string;
47
+ ms: number;
47
48
  };
48
49
  type PerformanceEntryDetail<T = unknown[]> = {
49
50
  message: string;
@@ -242,7 +243,6 @@ type CompilerOptionOverrides = Readonly<{
242
243
  allowJs: false;
243
244
  checkJs: false;
244
245
  declarationMap: false;
245
- declarationDir: undefined;
246
246
  skipLibCheck: true;
247
247
  preserveSymlinks: false;
248
248
  target: ScriptTarget.ESNext;
@@ -352,7 +352,7 @@ declare class TypeScriptProject implements Closable {
352
352
  /**
353
353
  * Calculates elapsed time since a performance mark and clears the mark.
354
354
  * @param markName - The name of the performance mark to measure from
355
- * @returns Formatted elapsed time string (e.g., '42ms')
355
+ * @returns Elapsed time in milliseconds
356
356
  */
357
357
  private static elapsed;
358
358
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TypeScriptProject
3
- } from "./4BKT57QY.js";
4
- import "./UYXU5EAU.js";
3
+ } from "./Q7VGDC7X.js";
4
+ import "./7FPDHUPW.js";
5
5
  export {
6
6
  TypeScriptProject
7
7
  };
package/dist/tsbuild.js CHANGED
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  BuildError,
4
4
  TypeScriptProject
5
- } from "./4BKT57QY.js";
6
- import "./UYXU5EAU.js";
5
+ } from "./Q7VGDC7X.js";
6
+ import "./7FPDHUPW.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.5.0");
33
+ console.log("1.6.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.5.0",
4
+ "version": "1.6.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",
@@ -42,24 +42,24 @@
42
42
  "tsbuild": "./dist/tsbuild.js"
43
43
  },
44
44
  "dependencies": {
45
- "@d1g1tal/watchr": "1.0.0",
46
- "esbuild": "^0.27.3",
45
+ "@d1g1tal/watchr": "^1.0.3",
46
+ "esbuild": "^0.27.4",
47
47
  "magic-string": "^0.30.21"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@eslint/js": "^10.0.1",
51
- "@types/node": "^25.3.5",
52
- "@typescript-eslint/eslint-plugin": "^8.56.1",
53
- "@typescript-eslint/parser": "^8.56.1",
54
- "@vitest/coverage-v8": "4.0.18",
51
+ "@types/node": "^25.4.0",
52
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
53
+ "@typescript-eslint/parser": "^8.57.0",
54
+ "@vitest/coverage-v8": "^4.1.0",
55
55
  "eslint": "^10.0.3",
56
- "eslint-plugin-jsdoc": "^62.7.1",
56
+ "eslint-plugin-jsdoc": "^62.8.0",
57
57
  "fs-monkey": "^1.1.0",
58
58
  "memfs": "^4.56.11",
59
59
  "tsx": "^4.21.0",
60
- "typescript": "5.9.3",
61
- "typescript-eslint": "^8.56.1",
62
- "vitest": "^4.0.18"
60
+ "typescript": "^5.9.3",
61
+ "typescript-eslint": "^8.57.0",
62
+ "vitest": "^4.1.0"
63
63
  },
64
64
  "keywords": [
65
65
  "typescript",