Skip to content

Commit 081b86d

Browse files
committed
feat: default to the root src dir
based on the cwd, if none provided
1 parent 2e80f42 commit 081b86d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

build.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const result = await Bun.build({
1111

1212
plugins: [
1313
dts({
14-
rootDir: `${import.meta.dir}/src`,
1514
cwd: import.meta.dir,
1615
}),
1716
],

src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,24 @@ interface DtsOptions {
2525
export async function generate(entryPoints: string | string[], options?: DtsOptions) {
2626
const path = p.resolve(options?.tsconfigPath ?? 'tsconfig.json')
2727
const configJson = ts.readConfigFile(path, ts.sys.readFile).config
28+
const cwd = options?.cwd ?? process.cwd()
29+
const rootDir = options?.rootDir ?? `${cwd}/src`
30+
const outDir = options?.outdir ?? 'dist/types'
31+
const declarationMap = options?.withSourceMap ?? false
2832

2933
const opts: TsOptions = {
30-
rootDir: options?.rootDir ?? options?.cwd ?? process.cwd(),
34+
rootDir,
35+
outDir,
36+
declarationMap,
3137
declaration: true,
3238
emitDeclarationOnly: true,
3339
noEmit: false,
34-
outDir: options?.outdir ?? 'dist/types',
35-
declarationMap: options?.withSourceMap ?? false,
3640
}
3741

3842
const parsedConfig = ts.parseJsonConfigFileContent(
3943
configJson,
4044
ts.sys,
41-
options?.cwd ?? process.cwd(),
45+
cwd,
4246
opts,
4347
path,
4448
)

0 commit comments

Comments
 (0)