@d1g1tal/tsbuild 1.7.0 → 1.7.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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [1.7.1](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.7.0...v1.7.1) (2026-03-29)
2
+
3
+ ### Code Refactoring
4
+
5
+ * **bundler:** remove internal index files and improve declaration bundling (0299420b919a09fab5f3988124296e8105a21c7f)
6
+ - Updates package.json types and exports to point to type-script-project instead of index
7
+ - Removes src/index.ts and src/dts/index.ts files
8
+ - Updates test imports to reference declaration-bundler directly instead of via index
9
+ - Fixes declaration bundler to gracefully handle entry points without declaration files
10
+ - Updates declaration bundler to ensure the output directory exists before writing
11
+ - Refines declaration identifier conflict mapping to use Set for finalTypeExports
12
+ - Updates file-manager to skip processing and writing empty declaration files
13
+ - Removes internal Symbol.toStringTag from FileManager
14
+
15
+
16
+ ### Styles
17
+
18
+ * update editorconfig indent size to 2 (e56b2b6dc13e4b53ff064db8a8b950cc1c6b23ae)
19
+ - Changes indent_size from 1 to 2 in .editorconfig
20
+
1
21
  ## [1.7.0](https://github.com/D1g1talEntr0py/tsbuild/compare/v1.6.5...v1.7.0) (2026-03-27)
2
22
 
3
23
  ### Features
@@ -30,73 +30,6 @@ import {
30
30
  typeMatcher
31
31
  } from "./YC2FB45E.js";
32
32
 
33
- // src/errors.ts
34
- import { SyntaxKind } from "typescript";
35
- var BuildError = class extends Error {
36
- /**
37
- * Creates a new BuildError
38
- * @param message - Error message
39
- * @param code - Exit code (default: 1)
40
- */
41
- constructor(message, code = 1) {
42
- super(message);
43
- this.code = code;
44
- this.name = "BuildError";
45
- Error.captureStackTrace(this, this.constructor);
46
- }
47
- };
48
- var TypeCheckError = class extends BuildError {
49
- /**
50
- * Creates a new TypeCheckError
51
- * @param message - Error message
52
- * @param diagnostics - Optional TypeScript diagnostics output
53
- */
54
- constructor(message, diagnostics) {
55
- super(message, 1);
56
- this.diagnostics = diagnostics;
57
- this.name = "TypeCheckError";
58
- }
59
- };
60
- var BundleError = class extends BuildError {
61
- /**
62
- * Creates a new BundleError
63
- * @param message - Error message
64
- */
65
- constructor(message) {
66
- super(message, 2);
67
- this.name = "BundleError";
68
- }
69
- };
70
- var ConfigurationError = class extends BuildError {
71
- /**
72
- * Creates a new ConfigurationError
73
- * @param message - Error message
74
- */
75
- constructor(message) {
76
- super(message, 3);
77
- this.name = "ConfigurationError";
78
- }
79
- };
80
- var UnsupportedSyntaxError = class extends BundleError {
81
- /**
82
- * Creates an instance of UnsupportedSyntaxError.
83
- * @param node The node with unsupported syntax
84
- * @param message The message to display (default: 'Syntax not yet supported')
85
- */
86
- constructor(node, message = "Syntax not yet supported") {
87
- const syntaxKindName = SyntaxKind[node.kind] ?? `Unknown(${node.kind})`;
88
- const nodeText = node.getText ? node.getText().slice(0, 100) : "<no text>";
89
- super(`${message}: ${syntaxKindName} - "${nodeText}"`);
90
- this.name = "UnsupportedSyntaxError";
91
- }
92
- };
93
- var castError = (exception) => {
94
- if (exception instanceof Error) {
95
- return exception;
96
- }
97
- return new Error(typeof exception === "string" ? exception : "Unknown error");
98
- };
99
-
100
33
  // src/files.ts
101
34
  import { dirname } from "node:path";
102
35
  import { serialize, deserialize } from "node:v8";
@@ -440,6 +373,73 @@ import MagicString2 from "magic-string";
440
373
  import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
441
374
  import { basename, posix } from "node:path";
442
375
 
376
+ // src/errors.ts
377
+ import { SyntaxKind } from "typescript";
378
+ var BuildError = class extends Error {
379
+ /**
380
+ * Creates a new BuildError
381
+ * @param message - Error message
382
+ * @param code - Exit code (default: 1)
383
+ */
384
+ constructor(message, code = 1) {
385
+ super(message);
386
+ this.code = code;
387
+ this.name = "BuildError";
388
+ Error.captureStackTrace(this, this.constructor);
389
+ }
390
+ };
391
+ var TypeCheckError = class extends BuildError {
392
+ /**
393
+ * Creates a new TypeCheckError
394
+ * @param message - Error message
395
+ * @param diagnostics - Optional TypeScript diagnostics output
396
+ */
397
+ constructor(message, diagnostics) {
398
+ super(message, 1);
399
+ this.diagnostics = diagnostics;
400
+ this.name = "TypeCheckError";
401
+ }
402
+ };
403
+ var BundleError = class extends BuildError {
404
+ /**
405
+ * Creates a new BundleError
406
+ * @param message - Error message
407
+ */
408
+ constructor(message) {
409
+ super(message, 2);
410
+ this.name = "BundleError";
411
+ }
412
+ };
413
+ var ConfigurationError = class extends BuildError {
414
+ /**
415
+ * Creates a new ConfigurationError
416
+ * @param message - Error message
417
+ */
418
+ constructor(message) {
419
+ super(message, 3);
420
+ this.name = "ConfigurationError";
421
+ }
422
+ };
423
+ var UnsupportedSyntaxError = class extends BundleError {
424
+ /**
425
+ * Creates an instance of UnsupportedSyntaxError.
426
+ * @param node The node with unsupported syntax
427
+ * @param message The message to display (default: 'Syntax not yet supported')
428
+ */
429
+ constructor(node, message = "Syntax not yet supported") {
430
+ const syntaxKindName = SyntaxKind[node.kind] ?? `Unknown(${node.kind})`;
431
+ const nodeText = node.getText ? node.getText().slice(0, 100) : "<no text>";
432
+ super(`${message}: ${syntaxKindName} - "${nodeText}"`);
433
+ this.name = "UnsupportedSyntaxError";
434
+ }
435
+ };
436
+ var castError = (exception) => {
437
+ if (exception instanceof Error) {
438
+ return exception;
439
+ }
440
+ return new Error(typeof exception === "string" ? exception : "Unknown error");
441
+ };
442
+
443
443
  // src/dts/declaration-processor.ts
444
444
  import {
445
445
  canHaveModifiers,
@@ -1204,8 +1204,7 @@ var DeclarationBundler = class {
1204
1204
  forEachChild2(sourceFile, visitQualified);
1205
1205
  }
1206
1206
  const finalValueExports = [...new Set(valueExports.map(exportsMapper))];
1207
- const valueExportsSet = new Set(finalValueExports);
1208
- const finalTypeExports = [...new Set(typeExports.map(exportsMapper).filter((t) => !valueExportsSet.has(t)))];
1207
+ const finalTypeExports = [...new Set(typeExports.map(exportsMapper).filter((t) => !new Set(finalValueExports).has(t)))];
1209
1208
  return { code: magic.toString(), externalImports, typeExports: finalTypeExports, valueExports: finalValueExports };
1210
1209
  }
1211
1210
  /**
@@ -1240,9 +1239,8 @@ var DeclarationBundler = class {
1240
1239
  }
1241
1240
  for (const [name, sourcesSet] of declarationSources) {
1242
1241
  if (sourcesSet.size > 1) {
1243
- const sources = Array.from(sourcesSet);
1244
1242
  let suffix = 1;
1245
- for (const modulePath of sources.slice(1)) {
1243
+ for (const modulePath of Array.from(sourcesSet).slice(1)) {
1246
1244
  let candidate = `${name}$${suffix}`;
1247
1245
  while (declarationSources.has(candidate)) {
1248
1246
  candidate = `${name}$${++suffix}`;
@@ -1313,6 +1311,9 @@ var DeclarationBundler = class {
1313
1311
  */
1314
1312
  bundle(entryPoint) {
1315
1313
  const dtsEntryPoint = this.resolveEntryPoint(entryPoint, this.options.compilerOptions);
1314
+ if (dtsEntryPoint === void 0) {
1315
+ return "";
1316
+ }
1316
1317
  const { modules, bundledSpecifiers } = this.buildModuleGraph(dtsEntryPoint);
1317
1318
  const { code } = this.combineModules(this.sortModules(modules, dtsEntryPoint), bundledSpecifiers);
1318
1319
  return DeclarationProcessor.postProcess(createSourceFile(dtsEntryPoint, code, ScriptTarget.Latest, true));
@@ -1325,31 +1326,38 @@ var DeclarationBundler = class {
1325
1326
  */
1326
1327
  resolveEntryPoint(entryPoint, compilerOptions) {
1327
1328
  const dtsEntryPoint = sys.resolvePath(entryPoint.endsWith(FileExtension.DTS) ? entryPoint : this.sourceToDeclarationPath(entryPoint));
1328
- if (!this.declarationFiles.has(dtsEntryPoint)) {
1329
- const availableFiles = Array.from(this.declarationFiles.keys());
1330
- const entryPointFilename = basename(entryPoint);
1331
- const similarFiles = availableFiles.filter((filePath) => filePath.includes(entryPointFilename));
1332
- throw new BundleError(
1333
- `Entry point declaration file not found: ${dtsEntryPoint || "unknown"}
1329
+ if (this.declarationFiles.has(dtsEntryPoint)) {
1330
+ return dtsEntryPoint;
1331
+ }
1332
+ if (!entryPoint.endsWith(FileExtension.DTS)) {
1333
+ return void 0;
1334
+ }
1335
+ const availableFiles = Array.from(this.declarationFiles.keys());
1336
+ const entryPointFilename = basename(entryPoint);
1337
+ const similarFiles = availableFiles.filter((filePath) => filePath.includes(entryPointFilename));
1338
+ throw new BundleError(
1339
+ `Entry point declaration file not found: ${dtsEntryPoint || "unknown"}
1334
1340
  Original entry: ${entryPoint}
1335
1341
  Compiler options: outDir=${compilerOptions.outDir || "dist"}, rootDir=${compilerOptions.rootDir || "not set"}
1336
1342
  Similar files found:
1337
1343
  ${similarFiles.map((f) => ` - ${f}`).join("\n")}
1338
1344
  Total available files: ${availableFiles.length}`
1339
- );
1340
- }
1341
- return dtsEntryPoint;
1345
+ );
1342
1346
  }
1343
1347
  };
1344
1348
  async function bundleDeclarations(options) {
1345
- await mkdir2(options.compilerOptions.outDir, defaultDirOptions);
1349
+ if (!await Files.exists(options.compilerOptions.outDir)) {
1350
+ await mkdir2(options.compilerOptions.outDir, defaultDirOptions);
1351
+ }
1346
1352
  const dtsBundler = new DeclarationBundler(options);
1347
- const bundleTasks = Object.entries(options.entryPoints).map(async ([entryName, entryPoint]) => {
1348
- const outPath = Paths.join(options.compilerOptions.outDir, `${entryName}.d.ts`);
1353
+ const bundleTasks = [];
1354
+ for (const [entryName, entryPoint] of Object.entries(options.entryPoints)) {
1349
1355
  const content = dtsBundler.bundle(entryPoint);
1350
- await writeFile2(outPath, content, Encoding.utf8);
1351
- return { path: Paths.relative(options.currentDirectory, outPath), size: content.length };
1352
- });
1356
+ if (content.length > 0) {
1357
+ const outPath = Paths.join(options.compilerOptions.outDir, `${entryName}.d.ts`);
1358
+ bundleTasks.push(writeFile2(outPath, content, Encoding.utf8).then(() => ({ path: Paths.relative(options.currentDirectory, outPath), size: content.length })));
1359
+ }
1360
+ }
1353
1361
  const results = await Promise.all(bundleTasks);
1354
1362
  dtsBundler.clearExternalFiles();
1355
1363
  return results;
@@ -1785,9 +1793,11 @@ var FileManager = class {
1785
1793
  }
1786
1794
  const writeTasks = [];
1787
1795
  for (const [filePath, { code }] of this.declarationFiles) {
1788
- writeTasks.push(this.writeFile(projectDirectory, filePath, code));
1796
+ if (code.length > 0) {
1797
+ writeTasks.push(this.writeFile(projectDirectory, filePath, code));
1798
+ }
1789
1799
  }
1790
- return Promise.all(writeTasks);
1800
+ return (await Promise.all(writeTasks)).filter((result) => result !== void 0);
1791
1801
  }
1792
1802
  /**
1793
1803
  * Resolves entry points for declaration bundling.
@@ -1869,14 +1879,16 @@ var FileManager = class {
1869
1879
  */
1870
1880
  processEmittedFiles() {
1871
1881
  for (const { path, text } of this.pendingFiles) {
1872
- this.declarationFiles.set(path, DeclarationProcessor.preProcess(createSourceFile2(path, text, ScriptTarget2.Latest, true)));
1882
+ const result = DeclarationProcessor.preProcess(createSourceFile2(path, text, ScriptTarget2.Latest, true));
1883
+ if (result.code.length > 0) {
1884
+ this.declarationFiles.set(path, result);
1885
+ }
1873
1886
  }
1874
1887
  this.pendingFiles.length = 0;
1875
1888
  }
1876
1889
  /**
1877
1890
  * Custom inspection method for better type representation.
1878
1891
  * @returns The string 'FileManager'
1879
- * @internal
1880
1892
  */
1881
1893
  get [Symbol.toStringTag]() {
1882
1894
  return "FileManager";
@@ -2122,7 +2134,7 @@ var _TypeScriptProject = class _TypeScriptProject {
2122
2134
  return Files.empty(this.buildConfiguration.outDir);
2123
2135
  }
2124
2136
  async build() {
2125
- Logger.header(`${tsLogo} tsbuild v${"1.7.0"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2137
+ Logger.header(`${tsLogo} tsbuild v${"1.7.1"}${this.configuration.compilerOptions.incremental && this.configuration.buildCache?.isValid() ? " [incremental]" : ""}`);
2126
2138
  try {
2127
2139
  const processes = [];
2128
2140
  const filesWereEmitted = await this.typeCheck();
package/dist/tsbuild.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BuildError,
4
4
  TypeScriptProject
5
- } from "./QNWF5BZL.js";
5
+ } from "./DT4U2QPA.js";
6
6
  import "./YC2FB45E.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.7.0");
33
+ console.log("1.7.1");
34
34
  process.exit(0);
35
35
  }
36
36
  var typeScriptOptions = {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  TypeScriptProject
3
- } from "./QNWF5BZL.js";
3
+ } from "./DT4U2QPA.js";
4
4
  import "./YC2FB45E.js";
5
5
  export {
6
6
  TypeScriptProject
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d1g1tal/tsbuild",
3
3
  "author": "D1g1talEntr0py",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
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",
@@ -26,11 +26,11 @@
26
26
  "access": "public"
27
27
  },
28
28
  "type": "module",
29
- "types": "./dist/index.d.ts",
29
+ "types": "./dist/type-script-project.d.ts",
30
30
  "exports": {
31
31
  ".": {
32
- "types": "./dist/index.d.ts",
33
- "import": "./dist/index.js"
32
+ "types": "./dist/type-script-project.d.ts",
33
+ "import": "./dist/type-script-project.js"
34
34
  }
35
35
  },
36
36
  "files": [
File without changes