@bunup/dts 0.14.24 → 0.14.25

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/dist/index.d.ts CHANGED
@@ -51,6 +51,12 @@ type GenerateDtsOptions = {
51
51
  * which will automatically infer the types of exports, eliminating the need for explicit type annotations.
52
52
  */
53
53
  inferTypes?: boolean;
54
+ /**
55
+ * Whether to use TypeScript's native compiler (tsgo), 10x faster than the traditional TypeScript compiler (tsc).
56
+ *
57
+ * This is only applicable if you have the `dts.inferTypes` option enabled. Without this enabled, bunup uses TypeScript's isolated declarations mode by default, so any TypeScript compiler is not relevant in this case.
58
+ */
59
+ tsgo?: boolean;
54
60
  };
55
61
  type GenerateDtsResultFile = {
56
62
  /**
package/dist/index.js CHANGED
@@ -458,17 +458,20 @@ function createResolver({
458
458
  };
459
459
  }
460
460
 
461
- // src/tsgo.ts
461
+ // src/typescript-compiler.ts
462
462
  import { mkdtemp } from "node:fs/promises";
463
463
  import { tmpdir } from "node:os";
464
464
  import path from "node:path";
465
- async function runTsgo(root, tsconfig) {
466
- const tsgoPackage = import.meta.resolve("@typescript/native-preview/package.json");
467
- const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPackage).href);
468
- const tsgo = getExePath();
465
+ async function runTypescriptCompiler(root, tsgo, tsconfig) {
466
+ let executable = "tsc";
467
+ if (tsgo) {
468
+ const tsgoPackage = import.meta.resolve("@typescript/native-preview/package.json");
469
+ const { default: getExePath } = await import(new URL("lib/getExePath.js", tsgoPackage).href);
470
+ executable = getExePath();
471
+ }
469
472
  const dist = await mkdtemp(path.join(tmpdir(), "bunup-dts-"));
470
473
  const proc = Bun.spawn([
471
- tsgo,
474
+ executable,
472
475
  "--noEmit",
473
476
  "false",
474
477
  "--declaration",
@@ -501,7 +504,7 @@ async function generateDts(entrypoints, options = {}) {
501
504
  resolveOption: resolve,
502
505
  tsconfig: tsconfig.filepath
503
506
  });
504
- let tsgoDist;
507
+ let tsCompiledDist;
505
508
  try {
506
509
  const fakeJsPlugin = {
507
510
  name: "fake-js",
@@ -528,7 +531,7 @@ async function generateDts(entrypoints, options = {}) {
528
531
  };
529
532
  });
530
533
  if (options.inferTypes) {
531
- tsgoDist = await runTsgo(cwd, tsconfig.filepath ?? undefined);
534
+ tsCompiledDist = await runTypescriptCompiler(cwd, !!options.tsgo, tsconfig.filepath ?? undefined);
532
535
  }
533
536
  build.onLoad({ filter: /\.(ts|tsx|d\.ts|d\.mts|d\.cts)$/ }, async (args) => {
534
537
  const sourceText = await Bun.file(args.path).text();
@@ -537,8 +540,8 @@ async function generateDts(entrypoints, options = {}) {
537
540
  if (NODE_MODULES_RE.test(args.path)) {
538
541
  declaration = sourceText;
539
542
  } else {
540
- if (options.inferTypes && tsgoDist) {
541
- const declarationPath = replaceExtension(path2.join(tsgoDist, args.path.replace(cwd, "")), ".d.ts");
543
+ if (options.inferTypes && tsCompiledDist) {
544
+ const declarationPath = replaceExtension(path2.join(tsCompiledDist, args.path.replace(cwd, "")), ".d.ts");
542
545
  declaration = await Bun.file(declarationPath).text();
543
546
  } else {
544
547
  const isolatedDeclarationResult = isolatedDeclaration(args.path, sourceText);
@@ -622,8 +625,8 @@ ${JSON.stringify(treeshakedDts.errors, null, 2)}`);
622
625
  errors: collectedErrors
623
626
  };
624
627
  } finally {
625
- if (tsgoDist) {
626
- await rm(tsgoDist, { recursive: true, force: true });
628
+ if (tsCompiledDist) {
629
+ await rm(tsCompiledDist, { recursive: true, force: true });
627
630
  }
628
631
  }
629
632
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bunup/dts",
3
- "version": "0.14.24",
3
+ "version": "0.14.25",
4
4
  "description": "An extremely fast TypeScript declaration bundler built on Bun's native bundler.",
5
5
  "homepage": "https://github.com/bunup/dts#readme",
6
6
  "bugs": {
@@ -43,9 +43,7 @@
43
43
  "bumpp": "^10.3.1",
44
44
  "bunup": "^0.14.21",
45
45
  "simple-git-hooks": "^2.13.1",
46
- "type-fest": "^5.1.0",
47
- "typescript": "^5.9.3",
48
- "zod": "^4.1.12"
46
+ "typescript": "^5.9.3"
49
47
  },
50
48
  "peerDependencies": {
51
49
  "typescript": ">=4.5.0"