Skip to content

Commit e3eb63e

Browse files
author
Eric Butler
committedDec 12, 2023
fix(core): use non-barrel schema file imports when using split-tags mode
fixes bad code generation when using `indexFiles: false`
1 parent 793c8cf commit e3eb63e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎packages/core/src/writers/split-tags-mode.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { generateTargetForTags } from './target-tags';
1212
import { getOrvalGeneratedTypes } from './types';
1313
import { getMockFileExtensionByTypeName } from '../utils/fileExtensions';
14+
import uniqBy from 'lodash.uniqby';
1415

1516
export const writeSplitTagsMode = async ({
1617
builder,
@@ -52,10 +53,17 @@ export const writeSplitTagsMode = async ({
5253
upath.relativeSafe(dirname, getFileInfo(output.schemas).dirname)
5354
: '../' + filename + '.schemas';
5455

56+
const importsForBuilder = output.schemas
57+
? uniqBy(imports, 'name').map((i) => ({
58+
exports: [i],
59+
dependency: upath.join(relativeSchemasPath, camel(i.name)),
60+
}))
61+
: [{ exports: imports, dependency: relativeSchemasPath }];
62+
5563
implementationData += builder.imports({
5664
client: output.client,
5765
implementation,
58-
imports: [{ exports: imports, dependency: relativeSchemasPath }],
66+
imports: importsForBuilder,
5967
specsName,
6068
hasSchemaDir: !!output.schemas,
6169
isAllowSyntheticDefaultImports,

0 commit comments

Comments
 (0)
Please sign in to comment.