Skip to content

Conversation

@BrigittaK307
Copy link

@BrigittaK307 BrigittaK307 commented Sep 17, 2025

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.

Co-authored-by: Deeksha Sinha <[email protected]>
Copy link
Contributor

@deekshas8 deekshas8 left a 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.

]);
});

const esmOptions = {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

@deekshas8 deekshas8 left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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',
Copy link
Contributor

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.

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.

4 participants