Skip to content

Commit 5e99a7f

Browse files
committed
fix: replace require.resolve hack with ./orm sub-path export
Add exports field to graphql-codegen package.json with ./orm sub-path so generateOrm is a stable contract instead of a filesystem crawl. Update codegen-helper.ts to use clean import from @constructive-io/graphql-codegen/orm.
1 parent 7993fb7 commit 5e99a7f

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

graphql/codegen/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@
2929
"main": "index.js",
3030
"module": "index.mjs",
3131
"types": "index.d.ts",
32+
"exports": {
33+
".": {
34+
"import": "./esm/index.js",
35+
"require": "./index.js",
36+
"types": "./index.d.ts"
37+
},
38+
"./orm": {
39+
"import": "./esm/core/codegen/orm/index.js",
40+
"require": "./core/codegen/orm/index.js",
41+
"types": "./core/codegen/orm/index.d.ts"
42+
}
43+
},
3244
"bin": {
3345
"graphql-codegen": "cli/index.js"
3446
},

graphql/test/src/codegen-helper.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,7 @@ import {
3232
} from '@constructive-io/graphql-query';
3333
import type { Table } from '@constructive-io/graphql-query';
3434

35-
// generateOrm is not re-exported from the public barrel — resolve via dist
36-
const codegenRoot = path.dirname(
37-
require.resolve('@constructive-io/graphql-codegen'),
38-
);
39-
const { generateOrm } = require(
40-
path.join(codegenRoot, 'core/codegen/orm/index.js'),
41-
) as {
42-
generateOrm: (opts: any) => { files: { path: string; content: string }[] };
43-
};
35+
import { generateOrm } from '@constructive-io/graphql-codegen/orm';
4436

4537
export interface CodegenResult {
4638
/** Factory function to create an ORM client from a GraphQLAdapter */

0 commit comments

Comments
 (0)