Skip to content

RC3 codegen cannot load a real Next.js stack config #246

Description

@olliethedev

Summary

@btst/codegen@0.2.0-rc.3 cannot generate the Drizzle schema from the RC3 validation app's normal Next.js stack config. The wrapper delegates to an isolated npx @btst/cli@2.2.3 process that does not reproduce the application's module resolution.

Reproduction

CI=true corepack pnpm@10.17.1 dlx @btst/codegen@0.2.0-rc.3 generate -- \
  --config lib/stack.ts \
  --output db/btst-schema.ts \
  --orm drizzle \
  --yes

The stack uses the RC3 server authorization split and imports its server module through lib/stack.ts.

Failures observed

  1. With the normal Next.js server marker:
Cannot find module 'server-only'

Adding the marker package explicitly changes this to its intentional outside-RSC error:

This module cannot be imported from a Client Component module. It should only be used from a Server Component.
  1. Temporarily removing the marker reaches the next loader incompatibility:
Cannot find module '@/lib/auth'
Require stack: lib/stack-authorization.server.ts

The CLI does not resolve the app's TypeScript path aliases.

  1. Changing that import to a relative path and supplying the full environment reaches the isolated delegated install, then fails even though the app directly installs drizzle-orm@0.45.2:
ERR_MODULE_NOT_FOUND: Cannot find package 'drizzle-orm' imported from
~/.npm/_npx/.../node_modules/@better-auth/drizzle-adapter/dist/index.mjs

The wrapper prints:

Delegating to: npx --yes @btst/cli@2.2.3 generate ...

Expected

RC3 codegen should load the same config that Next.js and TypeScript load, including standard server-only markers and tsconfig path aliases, and its delegated CLI should resolve ORM peers from the application. Schema generation should not require temporarily weakening server boundaries, rewriting imports, or adding duplicate packages to an isolated npx environment.

Impact

The RC3 media schema added updatedAt fields for both mediaAsset and mediaFolder, but codegen could not produce the update. The validation app had to inspect the published RC3 schema and add those fields manually before generating the Drizzle migration.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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