@@ -18,6 +18,7 @@ function getTsProperties(args: Parameters<typeof transformer>) {
1818 let tsInstance : typeof ts ;
1919 let compilerOptions : ts . CompilerOptions ;
2020 let fileNames : readonly string [ ] | undefined ;
21+ let isTranspileOnly = false ;
2122 let isTsNode = false ;
2223
2324 const [ program , pluginConfig , extras , manualTransformOptions ] = args ;
@@ -29,23 +30,25 @@ function getTsProperties(args: Parameters<typeof transformer>) {
2930 outputMode : pluginConfig ?. outputMode === "esm" ? < const > "esm" : < const > "commonjs" ,
3031 } ;
3132
33+ const tsNodeProps = getTsNodeRegistrationProperties ( tsInstance ) ;
34+ if ( tsNodeProps ) isTsNode = true ;
35+
3236 if ( program ) {
33- compilerOptions ??= program . getCompilerOptions ( ) ;
37+ compilerOptions ??= Object . assign ( { } , program . getCompilerOptions ( ) , tsNodeProps ?. compilerOptions ) ;
3438 } else if ( manualTransformOptions ) {
3539 fileNames = manualTransformOptions . fileNames ;
3640 } else {
37- const tsNodeProps = getTsNodeRegistrationProperties ( tsInstance ) ;
3841 if ( ! tsNodeProps )
3942 throw new Error (
4043 `Cannot transform without a Program, ts-node instance, or manual parameters supplied. ` +
4144 `Make sure you're using ts-patch or ts-node with transpileOnly.`
4245 ) ;
43- isTsNode = true ;
46+ isTranspileOnly = true ;
4447 compilerOptions = tsNodeProps . compilerOptions ;
4548 fileNames = tsNodeProps . fileNames ;
4649 }
4750
48- return { tsInstance, compilerOptions, fileNames, isTsNode , config } ;
51+ return { tsInstance, compilerOptions, fileNames, isTranspileOnly , config, isTsNode } ;
4952}
5053
5154// endregion
@@ -72,6 +75,7 @@ export default function transformer(
7275 tsInstance,
7376 compilerOptions,
7477 fileNames,
78+ isTranspileOnly,
7579 isTsNode,
7680 config
7781 } = getTsProperties ( [ program , pluginConfig , transformerExtras , manualTransformOptions ] ) ;
@@ -86,7 +90,7 @@ export default function transformer(
8690 `No EmitHost found and could not determine files to be processed. Please file an issue with a reproduction!`
8791 ) ;
8892 emitHost = createSyntheticEmitHost ( compilerOptions , tsInstance , getCanonicalFileName , fileNames as string [ ] ) ;
89- } else if ( isTsNode ) {
93+ } else if ( isTranspileOnly ) {
9094 Object . assign ( emitHost , { getCompilerOptions : ( ) => compilerOptions } ) ;
9195 }
9296
@@ -103,6 +107,7 @@ export default function transformer(
103107 transformationContext,
104108 tsInstance,
105109 emitHost,
110+ isTranspileOnly,
106111 isTsNode,
107112 tsThreeInstance : cast < TypeScriptThree > ( tsInstance ) ,
108113 excludeMatchers : config . exclude ?. map ( ( globPattern ) => new Minimatch ( globPattern , { matchBase : true } ) ) ,
0 commit comments