From e56304e876b309f15c980f689cf18a9cc520ed6a Mon Sep 17 00:00:00 2001 From: KONFeature Date: Sun, 22 Sep 2024 11:24:05 +0200 Subject: [PATCH] fix: Correct file path in `ponder-env.d.ts` 1c0ae2 --- packages/core/src/common/codegen.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/core/src/common/codegen.ts b/packages/core/src/common/codegen.ts index 59b5d6baa..e5aeb7388 100644 --- a/packages/core/src/common/codegen.ts +++ b/packages/core/src/common/codegen.ts @@ -11,8 +11,8 @@ export const ponderEnv = `// This file enables type checking and editor autocomp declare module "@/generated" { import type { Virtual } from "@ponder/core"; - type config = typeof import("./ponder.config.ts").default; - type schema = typeof import("./ponder.schema.ts").default; + type config = typeof import("[[CONFIG]]").default; + type schema = typeof import("[[SCHEMA]]").default; export const ponder: Virtual.Registry; @@ -40,9 +40,22 @@ export function runCodegen({ common: Common; graphqlSchema: GraphQLSchema; }) { + // Replace the placeholder with the actual path to the config file + const relativeConfigFile = path.relative( + common.options.rootDir, + common.options.configFile, + ); + const relativeSchemaFile = path.relative( + common.options.rootDir, + common.options.schemaFile, + ); + const ponderEnvWithPath = ponderEnv + .replace("[[CONFIG]]", `./${relativeConfigFile}`) + .replace("[[SCHEMA]]", `./${relativeSchemaFile}`); + writeFileSync( path.join(common.options.rootDir, "ponder-env.d.ts"), - ponderEnv, + ponderEnvWithPath, "utf8", );