From f0a875eefdefc2af84c0e81e75f1125d74bd6ff9 Mon Sep 17 00:00:00 2001 From: Rahul Chaudhary Date: Tue, 16 Jun 2026 18:25:23 +0530 Subject: [PATCH] fix: replace tsconfck with native typescript config parsing --- .changeset/afraid-bags-pretend.md | 5 +++ packages/build/package.json | 3 +- packages/build/src/extensions/typescript.ts | 41 +++++++++++++++------ pnpm-lock.yaml | 17 --------- 4 files changed, 35 insertions(+), 31 deletions(-) create mode 100644 .changeset/afraid-bags-pretend.md diff --git a/.changeset/afraid-bags-pretend.md b/.changeset/afraid-bags-pretend.md new file mode 100644 index 00000000000..cb37ba034b8 --- /dev/null +++ b/.changeset/afraid-bags-pretend.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/build": patch +--- + +Remove deprecated tsconfck dependency and replace with native typescript compiler api to resolve typescript 6 peer dependency installation issues diff --git a/packages/build/package.json b/packages/build/package.json index b7cb386c64c..f74398063b6 100644 --- a/packages/build/package.json +++ b/packages/build/package.json @@ -82,8 +82,7 @@ "mlly": "^1.7.1", "pkg-types": "^1.1.3", "resolve": "^1.22.8", - "tinyglobby": "^0.2.2", - "tsconfck": "3.1.3" + "tinyglobby": "^0.2.2" }, "devDependencies": { "@arethetypeswrong/cli": "^0.15.4", diff --git a/packages/build/src/extensions/typescript.ts b/packages/build/src/extensions/typescript.ts index a9e955edecd..bdb9c17f901 100644 --- a/packages/build/src/extensions/typescript.ts +++ b/packages/build/src/extensions/typescript.ts @@ -1,8 +1,9 @@ +import { dirname } from "node:path"; import { BuildExtension } from "@trigger.dev/core/v3/build"; import { readFile } from "node:fs/promises"; import typescriptPkg from "typescript"; -const { transpileModule, ModuleKind } = typescriptPkg; +const { transpileModule, ModuleKind, findConfigFile, readConfigFile, parseJsonConfigFileContent, sys } = typescriptPkg; const decoratorMatcher = new RegExp(/((?(); + const configCache = new Map(); build.onLoad({ filter: /\.ts$/ }, async (args) => { context.logger.debug("emitDecoratorMetadata onLoad", { args }); - const { tsconfigFile, tsconfig } = await parseNative(args.path, { - ignoreNodeModules: true, - cache, - }); + const searchPath = dirname(args.path); + const tsconfigFile = findConfigFile(searchPath, sys.fileExists, "tsconfig.json"); - context.logger.debug("emitDecoratorMetadata parsed native tsconfig", { - tsconfig, + context.logger.debug("emitDecoratorMetadata resolved tsconfig file", { tsconfigFile, args, }); - if (tsconfig.compilerOptions?.emitDecoratorMetadata !== true) { + let compilerOptions: any = {}; + + if (tsconfigFile) { + if (configCache.has(tsconfigFile)) { + compilerOptions = configCache.get(tsconfigFile); + } else { + const configFile = readConfigFile(tsconfigFile, sys.readFile); + if (configFile.config) { + const parsedConfig = parseJsonConfigFileContent( + configFile.config, + sys, + dirname(tsconfigFile) + ); + compilerOptions = parsedConfig.options || {}; + } + configCache.set(tsconfigFile, compilerOptions); + } + } + + if (compilerOptions.emitDecoratorMetadata !== true) { context.logger.debug("emitDecoratorMetadata skipping", { args, - tsconfig, + compilerOptions, }); return undefined; @@ -55,7 +71,7 @@ export function emitDecoratorMetadata(): BuildExtension { const program = transpileModule(ts, { fileName: args.path, compilerOptions: { - ...tsconfig.compilerOptions, + ...compilerOptions, module: ModuleKind.ES2022, }, }); @@ -67,3 +83,4 @@ export function emitDecoratorMetadata(): BuildExtension { }, }; } + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2b2df6bd89..c2cee022bdb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1502,9 +1502,6 @@ importers: tinyglobby: specifier: ^0.2.2 version: 0.2.2 - tsconfck: - specifier: 3.1.3 - version: 3.1.3(typescript@5.5.4) devDependencies: '@arethetypeswrong/cli': specifier: ^0.15.4 @@ -16164,16 +16161,6 @@ packages: typescript: optional: true - tsconfck@3.1.3: - resolution: {integrity: sha512-ulNZP1SVpRDesxeMLON/LtWM8HIgAJEIVpVVhBM6gsmvQ8+Rh+ZG7FWGvHh7Ah3pRABwVJWklWCr/BTZSv0xnQ==} - engines: {node: ^18 || >=20} - hasBin: true - peerDependencies: - typescript: 5.5.4 - peerDependenciesMeta: - typescript: - optional: true - tsconfig-paths@3.14.1: resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==} @@ -34932,10 +34919,6 @@ snapshots: optionalDependencies: typescript: 5.5.4 - tsconfck@3.1.3(typescript@5.5.4): - optionalDependencies: - typescript: 5.5.4 - tsconfig-paths@3.14.1: dependencies: '@types/json5': 0.0.29