Skip to content

Commit

Permalink
fix(core): use non-barrel schema file imports when using split-tags mode
Browse files Browse the repository at this point in the history
fixes bad code generation when using `indexFiles: false`
  • Loading branch information
Eric Butler committed Dec 12, 2023
1 parent 793c8cf commit e3eb63e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/core/src/writers/split-tags-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { generateTargetForTags } from './target-tags';
import { getOrvalGeneratedTypes } from './types';
import { getMockFileExtensionByTypeName } from '../utils/fileExtensions';
import uniqBy from 'lodash.uniqby';

export const writeSplitTagsMode = async ({
builder,
Expand Down Expand Up @@ -52,10 +53,17 @@ export const writeSplitTagsMode = async ({
upath.relativeSafe(dirname, getFileInfo(output.schemas).dirname)
: '../' + filename + '.schemas';

const importsForBuilder = output.schemas
? uniqBy(imports, 'name').map((i) => ({
exports: [i],
dependency: upath.join(relativeSchemasPath, camel(i.name)),
}))
: [{ exports: imports, dependency: relativeSchemasPath }];

implementationData += builder.imports({
client: output.client,
implementation,
imports: [{ exports: imports, dependency: relativeSchemasPath }],
imports: importsForBuilder,
specsName,
hasSchemaDir: !!output.schemas,
isAllowSyntheticDefaultImports,
Expand Down

0 comments on commit e3eb63e

Please sign in to comment.