Skip to content

Commit 6662cf6

Browse files
committed
fix: pass transformers object to ts.transpileModule method
1 parent e567002 commit 6662cf6

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,15 @@ export function create (rawOptions: CreateOptions = {}): Register {
488488
let getTypeInfo: (_code: string, _fileName: string, _position: number) => TypeInfo
489489

490490
const getOutputTranspileOnly = (code: string, fileName: string, overrideCompilerOptions?: Partial<_ts.CompilerOptions>): SourceOutput => {
491+
if (typeof transformers === 'function') {
492+
throw new TypeError('Transformers function is unavailable in "--transpile-only"')
493+
}
494+
491495
const result = ts.transpileModule(code, {
492496
fileName,
493497
compilerOptions: overrideCompilerOptions ? { ...config.options, ...overrideCompilerOptions } : config.options,
494-
reportDiagnostics: true
498+
reportDiagnostics: true,
499+
transformers: transformers
495500
})
496501

497502
const diagnosticList = filterDiagnostics(result.diagnostics || [], ignoreDiagnostics)
@@ -785,10 +790,6 @@ export function create (rawOptions: CreateOptions = {}): Register {
785790
}
786791
}
787792
} else {
788-
if (typeof transformers === 'function') {
789-
throw new TypeError('Transformers function is unavailable in "--transpile-only"')
790-
}
791-
792793
getOutput = getOutputTranspileOnly
793794

794795
getTypeInfo = () => {

0 commit comments

Comments
 (0)