File tree 3 files changed +16
-7
lines changed
3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 1
1
import path from 'path'
2
2
import fs from 'fs'
3
3
import { Worker } from 'worker_threads'
4
- import type { Buildable , MarkRequired } from 'ts-essentials'
5
4
import { removeFiles , debouncePromise , slash , MaybePromise } from './utils'
6
5
import { loadTsupConfig } from './load'
7
6
import glob from 'globby'
@@ -53,7 +52,7 @@ const normalizeOptions = async (
53
52
...optionsFromConfigFile ,
54
53
...optionsOverride ,
55
54
}
56
- const options : Buildable < NormalizedOptions > = {
55
+ const options : Partial < NormalizedOptions > = {
57
56
target : 'node14' ,
58
57
outDir : 'dist' ,
59
58
..._options ,
@@ -108,6 +107,12 @@ const normalizeOptions = async (
108
107
options . tsconfigResolvePaths = tsconfig . data ?. compilerOptions ?. paths || { }
109
108
options . tsconfigDecoratorMetadata =
110
109
tsconfig . data ?. compilerOptions ?. emitDecoratorMetadata
110
+ if ( options . dts ) {
111
+ options . dts . compilerOptions = {
112
+ ...( tsconfig . data . compilerOptions || { } ) ,
113
+ ...( options . dts . compilerOptions || { } ) ,
114
+ }
115
+ }
111
116
} else if ( options . tsconfig ) {
112
117
throw new PrettyError ( `Cannot find tsconfig: ${ options . tsconfig } ` )
113
118
}
Original file line number Diff line number Diff line change @@ -29,6 +29,11 @@ export type DtsConfig = {
29
29
banner ?: string
30
30
/** Insert at the bottom */
31
31
footer ?: string
32
+ /**
33
+ * Overrides `compilerOptions`
34
+ * This option takes higher priority than `compilerOptions` in tsconfig.json
35
+ */
36
+ compilerOptions ?: any
32
37
}
33
38
34
39
export type BannerOrFooter =
Original file line number Diff line number Diff line change @@ -15,11 +15,10 @@ import resolveFrom from 'resolve-from'
15
15
16
16
const logger = createLogger ( )
17
17
18
- const loadCompilerOptions = ( tsconfig ?: string ) => {
19
- if ( ! tsconfig ) return { }
20
- const configFile = ts . readConfigFile ( tsconfig , ts . sys . readFile )
18
+ const parseCompilerOptions = ( compilerOptions ?: any ) => {
19
+ if ( ! compilerOptions ) return { }
21
20
const { options } = ts . parseJsonConfigFileContent (
22
- configFile . config ,
21
+ { compilerOptions } ,
23
22
ts . sys ,
24
23
'./'
25
24
)
@@ -83,7 +82,7 @@ const getRollupConfig = async (
83
82
) : Promise < RollupConfig > => {
84
83
setSilent ( options . silent )
85
84
86
- const compilerOptions = loadCompilerOptions ( options . tsconfig )
85
+ const compilerOptions = parseCompilerOptions ( options . dts ?. compilerOptions )
87
86
88
87
const dtsOptions = options . dts || { }
89
88
dtsOptions . entry = dtsOptions . entry || options . entry
You can’t perform that action at this time.
0 commit comments