Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/auth-adapters/better-auth/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ export const zenstackAdapter = <Schema extends SchemaDef>(db: ClientContract<Sch
options: config,

createSchema: async ({ file, tables }) => {
const generateSchema = (await import('./schema-generator')).generateSchema;
// Self-import via package subpath (not a relative './schema-generator') so the
// bundler treats it as external and keeps it lazy in the CJS output — see tsdown.config.ts.
const generateSchema = (await import('@zenstackhq/better-auth/schema-generator')).generateSchema;
return generateSchema(file, tables, config, options);
},
};
Expand Down
5 changes: 4 additions & 1 deletion packages/auth-adapters/better-auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"rootDir": ".",
"noPropertyAccessFromIndexSignature": false,
"types": ["node"]
"types": ["node"],
"paths": {
"@zenstackhq/better-auth/schema-generator": ["./src/schema-generator.ts"]
}
},
"include": ["src/**/*"]
}
17 changes: 16 additions & 1 deletion packages/auth-adapters/better-auth/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
import { createConfig } from '@zenstackhq/tsdown-config';

export default createConfig({ entry: { index: 'src/index.ts', 'schema-generator': 'src/schema-generator.ts' } });
// `index` and `schema-generator` are built as two separate tsdown invocations so that
// the lazy `await import('@zenstackhq/better-auth/schema-generator')` in the adapter
// stays lazy in the CJS output. When both entries live in a single build, Rolldown
// treats them as siblings and injects a top-level `require('./schema-generator.cjs')`
// into `index.cjs`, which eagerly pulls in `@zenstackhq/language` (Langium) at adapter
// load time. Splitting the builds hides that relationship; `neverBundle` then keeps
// the dynamic import as a package-name reference that Node resolves at first call.
export default [
createConfig({
entry: { index: 'src/index.ts' },
deps: { neverBundle: ['@zenstackhq/better-auth/schema-generator'] },
}),
createConfig({
entry: { 'schema-generator': 'src/schema-generator.ts' },
}),
];
Loading