Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not emit an empty module export in the index if no module is required #338

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hristozov
Copy link

@hristozov hristozov commented Dec 3, 2024

Problem

See #337

We might not want a module but still want an index, e.g.:

{
  "module": false,
  "indexFile": true
}

In such a case, we'd get something like:

/* tslint:disable */
/* eslint-disable */
/* Code generated by ng-openapi-gen DO NOT EDIT. */

export { ApiConfiguration } from './api-configuration';
export { BaseService } from './base-service';
export { RequestBuilder } from './request-builder';
export { StrictHttpResponse } from './strict-http-response';
export {  } from './';   // <----------------------------------------- Note this broken export
export { ApiService } from './services/api.service';

Solution

Guard the export in the template. Be sure to not break things by writing tests for the exports in index.ts for both cases - whenever module is on or off.

Testing done

Verified the output no longer contains such an export in that case.

Verified the existing exports are not regressed.

Compared the test output before and after the fix:

$ diff -r out-before out-after
diff --color -r out-before/all-operations/fn/no-tag/path-6-get.ts out-after/all-operations/fn/no-tag/path-6-get.ts
21c21
<     rb.build({ responseType: 'arraybuffer', accept: '*/*', context })
---
>     rb.build({ responseType: 'blob', accept: '*/*', context })
diff --color -r out-before/noModule/index.ts out-after/noModule/index.ts
9d8
< export {  } from './';

(The diff in path-6-get.ts seems unrelated, probably due to non-determinism)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant