Skip to content

Commit 0e4882a

Browse files
committed
fix: add ability to skip generating index file with output.indexFile
1 parent 55f27bf commit 0e4882a

File tree

6 files changed

+1970
-4
lines changed

6 files changed

+1970
-4
lines changed

.changeset/wicked-apples-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: add ability to skip generating index file with output.indexFile

packages/openapi-ts/src/generate/output.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ export const generateOutput = async ({ context }: { context: IR.Context }) => {
143143
continue;
144144
}
145145

146-
if (!file.isEmpty() && file.exportFromIndex) {
146+
if (
147+
!file.isEmpty() &&
148+
file.exportFromIndex &&
149+
context.config.output.indexFile
150+
) {
147151
// TODO: parser - add export method for more granular control over
148152
// what's exported so we can support named exports
149153
indexFile.add(
@@ -156,6 +160,8 @@ export const generateOutput = async ({ context }: { context: IR.Context }) => {
156160
file.write('\n\n');
157161
}
158162

159-
indexFile.write();
163+
if (context.config.output.indexFile) {
164+
indexFile.write();
165+
}
160166
}
161167
};

packages/openapi-ts/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ const getOutput = (userConfig: ClientConfig): Config['output'] => {
159159
let output: Config['output'] = {
160160
clean: true,
161161
format: false,
162+
indexFile: true,
162163
lint: false,
163164
path: '',
164165
};

packages/openapi-ts/src/types/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,14 @@ export interface ClientConfig {
170170
* @default false
171171
*/
172172
format?: Formatters | false;
173+
/**
174+
* Should the exports from plugin files be re-exported in the index
175+
* barrel file? By default, this is enabled and only default plugins
176+
* are re-exported.
177+
*
178+
* @default true
179+
*/
180+
indexFile?: boolean;
173181
/**
174182
* Process output folder with linter?
175183
*

0 commit comments

Comments
 (0)