ReviewOS

stacks/bun-plugin-dtsx

generate d.ts file for types similar to bun-plugin-dts same entrypoints file rather creating as chucks of all the files in the src

#1634
Open hedaukartik opened this 8 days ago ·
8 days ago

Describe the bug

Regarding bun-plugin-dtsx: "0.21.17"

When I am having configuration like below

import { $ } from "bun";
import dts from "bun-plugin-dtsx";

const buildStart = performance.now();

const outdir = "./dist";

// Clean the output directory, equivalent to tsup's `clean: true`
await $`rm -rf ${outdir}`;

const result = await Bun.build({
  root: "./src",
  entrypoints: ["./src/index.ts"],
  outdir,
  format: "esm",
  splitting: false, // Matches tsup config
  sourcemap: "none", // Matches tsup config `sourcemap: false`
  minify: true, // Standard for production builds
  external: ["react", "react-dom"], // buFrom peerDependencies
  plugins: [
    dts(),
  ],
});

if (!result.success) {
  console.error("Build failed");
  for (const message of result.logs) {
    console.error(message);
  }
  process.exit(1);
}

const buildEnd = performance.now();

console.log("Builder completed.");
console.log(`Build time: ${buildEnd - buildStart} ms.`);

console.log("Build completed successfully.");
for (const output of result.outputs) {
  console.log(`  - ${output.path}`);
}

and index.ts file as

export * from "./props";
// export * from "./session";
// export * from "./types";
// export * from "./time";
// export * from "./lang";
// export * from "./locale";
// export * from "./hooks";
// export * from "./download";
// export * from "./expression";
// export * from "./id";
// export * from "./dom";
// export * from "./auth";
// export * from "./regex";
// export * from "./pipeline";
// export * from "./capability";
// export * from "./predicates";
// export * from "./compare";
// export * from "./url";
// export * from "./functools";
// export * from "./event-bus";
// export * from "./action";
// export * from "./data";

tsconfig.json:

{
  "$schema": "https://json.schemastore.org/tsconfig",
  "display": "Standard Library",
  "extends": "@up/typescript-config/library.json",
  "compilerOptions": {
    "outDir": "./dist",
    "rootDir": "./src",
    "forceConsistentCasingInFileNames": true,
    "types": ["node"],
    "skipLibCheck": true
  },
  "include": ["src/**/*.ts", "src/**/*.tsx"],
  "exclude": ["node_modules", "src/**/*.test.ts", "src/**/*.data.ts", "dist"]
}

I see this: Which included non-exported files and test file too which are already excluded in tsconfig.json

Image

When using bun-plugin-dts library, it like giving one d.ts file

Image

Reproduction

Screenshot attached.

System Info

System:
    OS: macOS 26.2
    CPU: (10) arm64 Apple M1 Pro
    Memory: 67.22 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.0 - /Users/<me>/.nvm/versions/node/v22.17.0/bin/node
    npm: 10.9.2 - /Users/<me>/.nvm/versions/node/v22.17.0/bin/npm
    pnpm: 10.18.1 - /Users/<me>/.nvm/versions/node/v22.17.0/bin/pnpm
    bun: 1.3.8 - /Users/<me>/.bun/bin/bun
  Browsers:
    Chrome: 145.0.7632.109
    Firefox: 147.0.3
    Safari: 26.2

Used Package Manager

bun

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
8 days ago

I really want to use this library because of speed which is better than bun-plugin-dts

Sign in to comment on this issue.