Error with sanity typegen in monorepo
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Start with the linked reproduction repository and run sanity typegen generate from the studio directory. Inspect ./src/queries/page.ts, compare its imported object and fragment strings, and trace how the command resolves @heaume/studio-globals/fragments; done means queries using imported fragments generate types without the reported binding error.
Written by the indexing model from the issue text.
Description
Describe the bug
I'm working with a turborepo monorepo containing a sanity studio app and a package build with tsdown containing standard objects and fragments for the sanity app.
I'm encountering errors when trying to generate the types for the sanity studio queries with imported fragments. The imported fragments are strings.
I've managed to import objects without issues and the schema extraction happens without any issue.
When running the sanity typegen generate command from the studio directory to generate the types from the queries and the existing schema, the queries using fragments from the monorepo package are breaking the type generation with following error:
✗ Could not find binding for import "fragments" in "@heaume/studio-globals/fragments" in "./src/queries/page.ts"
To Reproduce
Reproduction repo available here
Expected behavior
Typegen should work
Which versions of Sanity are you using?
@sanity/cli (global) 4.11.0 (latest: 4.12.0)
sanity 4.11.0 (latest: 4.12.0)
What operating system are you using?
linux mint
Which versions of Node.js / npm are you running?
node v22.19.0
pnpm 10.19.0
Additional context
none
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 2
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sanity-io/codegen
-
Difficulty 3/5 1-2 days Newbie friendliness 74/100
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in sanity-io/codegen
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·