-
Notifications
You must be signed in to change notification settings - Fork 66
feat: esm support on Odata #6061
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
base: main
Are you sure you want to change the base?
Conversation
…25-esm-support-oData
test-packages/test-services-odata-v2/generate-odata-services.ts
Outdated
Show resolved
Hide resolved
packages/generator/src/generator-without-ts-morph/request-builder/imports.ts
Outdated
Show resolved
Hide resolved
packages/generator/src/generator-without-ts-morph/request-builder/imports.spec.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Deeksha Sinha <[email protected]>
packages/generator/src/generator-without-ts-morph/request-builder/file.ts
Outdated
Show resolved
Hide resolved
packages/generator/src/generator-without-ts-morph/request-builder/imports.ts
Outdated
Show resolved
Hide resolved
deekshas8
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's almost there, just some code cleanup and restructuring needed, Please consider ALL comments and lets discuss if you have questions.
…oud-sdk-js into I753325-esm-support-oData
…oud-sdk-js into I753325-esm-support-oData
| ]); | ||
| }); | ||
|
|
||
| const esmOptions = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please declare this inside the it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only common variables should be declared within describe
…oud-sdk-js into I753325-esm-support-oData
deekshas8
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found two issues during compilation, having to do with incorrect tsconfig and missing type in package.json.
| npmPackageName: service.serviceOptions.packageName, | ||
| sdkVersion: await getSdkVersion(), | ||
| description: packageDescription(service.speakingModuleName), | ||
| oDataVersion: service.oDataVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| oDataVersion: service.oDataVersion, | |
| generateESM: options.generateESM |
This needs to be passed here as well, else the package.json doesn't have type: module for esm
| export const defaultTsConfig = { | ||
| compilerOptions: { | ||
| target: 'es2021', | ||
| module: 'commonjs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always commonjs which is a problem if you set generateESM to true. Because the generated ESM code gets compiled to commonjs. both module and moduleResolution should also be conditional.
The generateESM flag, used in both generator and openapi generator packages controls if the generated client code follows the ECMACScript Module (ESM) syntax or the default, CommonJS one.
when generateESM: true is set, the generator produces code which folllows the ESM syntax.