@@ -18,6 +18,7 @@ function getTsProperties(args: Parameters<typeof transformer>) {
18
18
let tsInstance : typeof ts ;
19
19
let compilerOptions : ts . CompilerOptions ;
20
20
let fileNames : readonly string [ ] | undefined ;
21
+ let isTranspileOnly = false ;
21
22
let isTsNode = false ;
22
23
23
24
const [ program , pluginConfig , extras , manualTransformOptions ] = args ;
@@ -29,23 +30,25 @@ function getTsProperties(args: Parameters<typeof transformer>) {
29
30
outputMode : pluginConfig ?. outputMode === "esm" ? < const > "esm" : < const > "commonjs" ,
30
31
} ;
31
32
33
+ const tsNodeProps = getTsNodeRegistrationProperties ( tsInstance ) ;
34
+ if ( tsNodeProps ) isTsNode = true ;
35
+
32
36
if ( program ) {
33
- compilerOptions ??= program . getCompilerOptions ( ) ;
37
+ compilerOptions ??= Object . assign ( { } , program . getCompilerOptions ( ) , tsNodeProps ?. compilerOptions ) ;
34
38
} else if ( manualTransformOptions ) {
35
39
fileNames = manualTransformOptions . fileNames ;
36
40
} else {
37
- const tsNodeProps = getTsNodeRegistrationProperties ( tsInstance ) ;
38
41
if ( ! tsNodeProps )
39
42
throw new Error (
40
43
`Cannot transform without a Program, ts-node instance, or manual parameters supplied. ` +
41
44
`Make sure you're using ts-patch or ts-node with transpileOnly.`
42
45
) ;
43
- isTsNode = true ;
46
+ isTranspileOnly = true ;
44
47
compilerOptions = tsNodeProps . compilerOptions ;
45
48
fileNames = tsNodeProps . fileNames ;
46
49
}
47
50
48
- return { tsInstance, compilerOptions, fileNames, isTsNode , config } ;
51
+ return { tsInstance, compilerOptions, fileNames, isTranspileOnly , config, isTsNode } ;
49
52
}
50
53
51
54
// endregion
@@ -72,6 +75,7 @@ export default function transformer(
72
75
tsInstance,
73
76
compilerOptions,
74
77
fileNames,
78
+ isTranspileOnly,
75
79
isTsNode,
76
80
config
77
81
} = getTsProperties ( [ program , pluginConfig , transformerExtras , manualTransformOptions ] ) ;
@@ -86,7 +90,7 @@ export default function transformer(
86
90
`No EmitHost found and could not determine files to be processed. Please file an issue with a reproduction!`
87
91
) ;
88
92
emitHost = createSyntheticEmitHost ( compilerOptions , tsInstance , getCanonicalFileName , fileNames as string [ ] ) ;
89
- } else if ( isTsNode ) {
93
+ } else if ( isTranspileOnly ) {
90
94
Object . assign ( emitHost , { getCompilerOptions : ( ) => compilerOptions } ) ;
91
95
}
92
96
@@ -103,6 +107,7 @@ export default function transformer(
103
107
transformationContext,
104
108
tsInstance,
105
109
emitHost,
110
+ isTranspileOnly,
106
111
isTsNode,
107
112
tsThreeInstance : cast < TypeScriptThree > ( tsInstance ) ,
108
113
excludeMatchers : config . exclude ?. map ( ( globPattern ) => new Minimatch ( globPattern , { matchBase : true } ) ) ,
0 commit comments