Skip to content

Commit e43ac4b

Browse files
committed
fix(codegen): resolve codegen plugins from the app, not the cli
Typecheck depends on codegen, and codegen failed once the global store became active in CI: Unable to find template plugin matching 'schema-ast' The plugin is not missing. @graphql-codegen/schema-ast is declared as a dependency of this app, but the codegen CLI resolves plugin packages relative to its own location, and the store links the CLI in from outside the project. From there the app's dependencies are not reachable, so the short name fails to load. The client preset was unaffected because presets resolve by a different path. Point pluginLoader at this config file so plugins resolve where they are declared. Same underlying cause as the React type redirect: a package resolving a sibling by name from a store path that sits outside the project. With codegen working, the full typecheck reports zero errors against the symlinked tree.
1 parent fbf3aa5 commit e43ac4b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/browseros-agent/apps/app/codegen.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ const ignoresList = ignorePatterns.ignores?.map((each) => `!${each}`) ?? []
2626

2727
const config: CodegenConfig = {
2828
schema: schemaPath,
29+
// The codegen CLI resolves plugin packages relative to its own location. Bun
30+
// links it in from a store outside this project, so a plugin declared as this
31+
// app's dependency is not reachable from there and the short name fails to
32+
// load. Resolve from this file instead, where the dependency is declared.
33+
pluginLoader: (name: string) =>
34+
import(
35+
name.startsWith('@graphql-codegen/') ? name : `@graphql-codegen/${name}`
36+
),
2937
documents: ['./**/*.tsx', './**/*.ts', ...ignoresList],
3038
ignoreNoDocuments: true,
3139
generates: {

0 commit comments

Comments
 (0)