Skip to content

[autorest.typescript] Allow generating ESM-style imports#2925

Merged
maorleger merged 19 commits intoAzure:mainfrom
maorleger:autorest-swagger-esm
Jan 7, 2025
Merged

[autorest.typescript] Allow generating ESM-style imports#2925
maorleger merged 19 commits intoAzure:mainfrom
maorleger:autorest-swagger-esm

Conversation

@maorleger
Copy link
Copy Markdown
Member

@maorleger maorleger commented Nov 22, 2024

This PR adds the module-kind flag to autorest options, allowing the generated code to have ESM-style imports/exports. Those may be generated with .js extension and/or index.js for directory-style imports.

The default remains CJS in autorest, but the idea is to then add this option to each HLC package that migrates to ESM in our repo.

The yaml would look like:

module-kind: esm

For any package that has already migrated

TODOs:

  • Document this flag
  • Changelog

Comment thread packages/autorest.typescript/src/autorestSession.ts
Comment thread packages/autorest.typescript/src/generators/clientFileGenerator.ts
Comment thread packages/autorest.typescript/src/generators/clientFileGenerator.ts
Comment thread packages/autorest.typescript/src/generators/clientFileGenerator.ts
@maorleger maorleger force-pushed the autorest-swagger-esm branch 3 times, most recently from b2aa4b1 to 9dca685 Compare December 2, 2024 17:42
@maorleger maorleger marked this pull request as ready for review December 2, 2024 18:39
@maorleger maorleger changed the title WIP - [autorest.typescript] Allow generating ESM imports [autorest.typescript] Allow generating ESM-style imports Dec 2, 2024
@maorleger maorleger force-pushed the autorest-swagger-esm branch from 7a67d2a to 290a914 Compare December 10, 2024 18:28
@maorleger
Copy link
Copy Markdown
Member Author

@joheredi @sarangan12 @qiaozha @MaryGao friendly ping on this - could y'all review and provide your feedback and/or approval? 🙏

Copy link
Copy Markdown
Member

@dgetu dgetu left a comment

Choose a reason for hiding this comment

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

LGTM, just some questions out of curiosity :)

Comment thread packages/autorest.typescript/src/utils/nameConstructors.ts
@maorleger maorleger force-pushed the autorest-swagger-esm branch from 290a914 to 186d3c9 Compare December 16, 2024 17:40
@qiaozha
Copy link
Copy Markdown
Member

qiaozha commented Dec 18, 2024

@kazrael2119 can you help verify if the generated code for this works fine?

@maorleger
Copy link
Copy Markdown
Member Author

@kazrael2119 can you help verify if the generated code for this works fine?

Hi @qiaozha - I plan to merge the PR this week, any concerns?

@maorleger maorleger force-pushed the autorest-swagger-esm branch from 50b0e36 to 02c68de Compare January 7, 2025 18:23
@maorleger maorleger merged commit ef19210 into Azure:main Jan 7, 2025
@maorleger maorleger deleted the autorest-swagger-esm branch January 7, 2025 19:11
@qiaozha qiaozha assigned MaryGao and unassigned qiaozha Jan 8, 2025
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.

5 participants