@@ -2,7 +2,7 @@ import type { DtsGenerationOption, GenerationStats } from '@stacksjs/dtsx'
22import type { BunPlugin } from 'bun'
33import { createHash } from 'node:crypto'
44import { existsSync , readFileSync , writeFileSync } from 'node:fs'
5- import { join , resolve } from 'node:path'
5+ import { basename , join , resolve } from 'node:path'
66import process from 'node:process'
77import { generate } from '@stacksjs/dtsx'
88
@@ -102,6 +102,7 @@ export interface PluginConfig extends DtsGenerationOption {
102102 config : {
103103 root ?: string
104104 outdir ?: string
105+ entrypoints ?: string [ ]
105106 }
106107 }
107108
@@ -468,11 +469,32 @@ function normalizeConfig(options: PluginConfig, build: PluginConfig['build']): D
468469 )
469470 }
470471
472+ // Derive entrypoints from Bun's build config if not explicitly provided.
473+ // Using '**/*.ts' as default causes dtsx to process every .ts file individually,
474+ // which hangs on large codebases. Instead, derive from Bun's entrypoints
475+ // or fall back to 'index.ts'.
476+ let entrypoints = options . entrypoints
477+ if ( ! entrypoints ) {
478+ const bunEntrypoints = build ?. config ?. entrypoints
479+ if ( bunEntrypoints ?. length ) {
480+ const resolvedRoot = resolve ( options . cwd || process . cwd ( ) , root )
481+ entrypoints = bunEntrypoints . map ( ( ep : string ) => {
482+ const resolved = resolve ( ep )
483+ return resolved . startsWith ( resolvedRoot )
484+ ? resolved . slice ( resolvedRoot . length + 1 )
485+ : basename ( resolved )
486+ } )
487+ }
488+ else {
489+ entrypoints = [ 'index.ts' ]
490+ }
491+ }
492+
471493 return {
472494 ...options ,
473495 cwd : options . cwd || process . cwd ( ) ,
474496 root,
475- entrypoints : options . entrypoints || [ '**/*.ts' ] ,
497+ entrypoints,
476498 outdir,
477499 clean : options . clean ,
478500 tsconfigPath : options . tsconfigPath ,
0 commit comments