Skip to content

Error with sanity typegen in monorepo #10958

@felixdenoix

Description

@felixdenoix

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions