Skip to content

hub:db (and @nuxthub/db) does not provide TypeScript definition on nuxt db generate #792

@nogic1008

Description

@nogic1008

Describe the bug

In @nuxthub/core v0.10.5, the database schema type definitions (.d.mts) are not generated during nuxt prepare or nuxt db generate, contrary to the intent of PR #758. The types are only generated when running nuxt dev, which breaks CI/CD workflows that rely on nuxt prepare followed by nuxt typecheck.

Steps to reproduce

  1. Install @nuxthub/[email protected]
  2. Create a database schema in server/db/schema.ts
  3. Run rm -rf .nuxt node_modules/@nuxthub/db && pnpm prepare
  4. Check for .nuxt/hub/db/schema.d.mts and node_modules/@nuxthub/db/schema.d.mts
  5. Run nuxt typecheck

Expected behavior

Actual behavior

  • Schema type definition files are NOT generated by nuxt prepare
  • Files are only generated when nuxt dev is started
  • nuxt typecheck fails with errors like: Module '"hub:db"' has no exported member 'db'

Root cause

In src/db/setup.ts, the buildDatabaseSchema() call is inside an if (!nuxt.options._prepare) block with app:templatesGenerated hook, which only fires during nuxt dev, not during nuxt prepare and nuxt db generate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions