Skip to content

buildDatabaseSchema fails for layers installed via gh: extends (node_modules type stripping) #852

@BlueBazze

Description

@BlueBazze

Describe the bug

When a Nuxt app uses layers installed via gh: extends (which are resolved into node_modules/.c12/), buildDatabaseSchema fails because the generated hub/db/schema.entry.ts contains absolute-path re-exports pointing to .ts files under node_modules:

export * from '/project/node_modules/.c12/gh_Org_layer_abc123/server/db/schema/users.postgresql.ts'

When tsdown processes this entry file, Node's type stripping is invoked on those .ts files, which fails because Node does not support stripping types from files under node_modules.

Steps to reproduce

  1. Create a Nuxt layer that defines DB schema files in server/db/schema/*.ts
  2. In a consuming app, extend that layer via gh: syntax:
  // nuxt.config.ts
  export default defineNuxtConfig({
    extends: [
      ['gh:Org/layer#main', { auth: process.env.GITHUB_TOKEN, install: true }],
    ],
    modules: ['@nuxthub/core'],
    hub: { db: 'postgresql' },
  })
  1. Run nuxi dev or nuxi build
  2. See error: Stripping types is currently unsupported for files under node_modules,
    for "file:///project/node_modules/.c12/gh_Org_layer_abc123/server/db/schema/example.po
    stgresql.ts"

Expected behavior

Schema files from gh: extended layers should work regardless of their resolved location on disk. The schema .ts files from layers under node_modules/.c12/ should be copied to the build directory (outside node_modules) before being passed to tsdown, so that Node's type stripping can process them.

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