11import { BuildExtension } from "@trigger.dev/core/v3/build" ;
22import { readFile } from "node:fs/promises" ;
3+ import { dirname } from "node:path" ;
34import { loadTypescript } from "./internal/loadTypescript.js" ;
45
56const decoratorMatcher = new RegExp ( / ( (?< ! [ ( \s ] \s * [ ' " ] ) @ \w [ . [ \] \w \d ] * \s * (? ! [ ; ] ) [ ( ( ? = \s ) ] ) / ) ;
@@ -8,29 +9,35 @@ export function emitDecoratorMetadata(): BuildExtension {
89 return {
910 name : "emitDecoratorMetadata" ,
1011 onBuildStart ( context ) {
11- const { transpileModule, ModuleKind } = loadTypescript ( context . workingDir ) ;
12+ const { convertCompilerOptionsFromJson, transpileModule, ModuleKind } = loadTypescript (
13+ context . workingDir
14+ ) ;
1215
1316 context . registerPlugin ( {
1417 name : "emitDecoratorMetadata" ,
1518 async setup ( build ) {
16- const { parseNative , TSConfckCache } = await import ( "tsconfck" ) ;
19+ const { parse , TSConfckCache } = await import ( "tsconfck" ) ;
1720 const cache = new TSConfckCache < any > ( ) ;
1821
1922 build . onLoad ( { filter : / \. t s $ / } , async ( args ) => {
2023 context . logger . debug ( "emitDecoratorMetadata onLoad" , { args } ) ;
2124
22- const { tsconfigFile, tsconfig } = await parseNative ( args . path , {
25+ const { tsconfigFile, tsconfig } = await parse ( args . path , {
2326 ignoreNodeModules : true ,
2427 cache,
2528 } ) ;
29+ const { options : compilerOptions } = convertCompilerOptionsFromJson (
30+ tsconfig . compilerOptions ?? { } ,
31+ tsconfigFile ? dirname ( tsconfigFile ) : context . workingDir
32+ ) ;
2633
27- context . logger . debug ( "emitDecoratorMetadata parsed native tsconfig" , {
34+ context . logger . debug ( "emitDecoratorMetadata parsed tsconfig" , {
2835 tsconfig,
2936 tsconfigFile,
3037 args,
3138 } ) ;
3239
33- if ( tsconfig . compilerOptions ? .emitDecoratorMetadata !== true ) {
40+ if ( compilerOptions . emitDecoratorMetadata !== true ) {
3441 context . logger . debug ( "emitDecoratorMetadata skipping" , {
3542 args,
3643 tsconfig,
@@ -55,7 +62,7 @@ export function emitDecoratorMetadata(): BuildExtension {
5562 const program = transpileModule ( ts , {
5663 fileName : args . path ,
5764 compilerOptions : {
58- ...tsconfig . compilerOptions ,
65+ ...compilerOptions ,
5966 module : ModuleKind . ES2022 ,
6067 } ,
6168 } ) ;
0 commit comments