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

[RLC] Hybrid codegen #2338

Merged
merged 11 commits into from
Mar 15, 2024
Merged

[RLC] Hybrid codegen #2338

merged 11 commits into from
Mar 15, 2024

Conversation

joheredi
Copy link
Member

@joheredi joheredi commented Mar 8, 2024

Scoped to TypeSpec generation. Autorest generation should remain the same

Copy link
Member

@qiaozha qiaozha left a comment

Choose a reason for hiding this comment

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

left some small and probably naive comments :)

"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@msinternal/openai?view=azure-node-preview"
}
},
"tshy": {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why we're not doing browser builds as part of RLC generation?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's because RLC types is meaningless as they are just generated for better user experience ?

"disableDocsMs": true,
"apiRefLink": "https://docs.microsoft.com/javascript/api/@msinternal/openai?view=azure-node-preview"
}
},
"tshy": {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's because RLC types is meaningless as they are just generated for better user experience ?

@joheredi joheredi marked this pull request as ready for review March 13, 2024 20:55

if (model.options?.moduleKind === "cjs") {
mainEntryPointFilePath = `./types${
generateTest || isModularLibrary ? "/src" : ""
Copy link
Member

Choose a reason for hiding this comment

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

we don't need to consider the generateSample here?

model.options || {};
const project = new Project();

let mainEntryPointFilePath = "./dist/esm/index.d.ts";
Copy link
Member

@qiaozha qiaozha Mar 15, 2024

Choose a reason for hiding this comment

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

I am trying to understand if it's esm, we don't really need to compile the samples and tests? so does the cjs compile result? I mean in 'dist/commonjs' folder

Copy link
Member

@qiaozha qiaozha 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 minor comments

"apiRefLink": "https://docs.microsoft.com/javascript/api/@msinternal/ai-anomaly-detector?view=azure-node-preview"
}
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts"
Copy link
Member

Choose a reason for hiding this comment

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

Does that mean we will build types in both cjs and esm? Both of them are the extract same definitions?

},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
Copy link
Member

@MaryGao MaryGao Mar 15, 2024

Choose a reason for hiding this comment

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

Could you help me understand the dist structure here? How do we organize sample and test build codes? Will it be like:

dist/
├─ esm/
│  ├─ test/
│  ├─ samples-dev/
│  ├─ src?/
│  ├─ index.d.ts/ (whoes index file? src/sample/test?)
│  ├─ index.js/ 
.....

"./src/**/*.ts",
"./src/**/*.mts",
"./src/**/*.cts",
"test/**/*.ts"
Copy link
Member

Choose a reason for hiding this comment

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

the test folder may not be always there? e.g if customers disable the test gen or in non-branded we disable test gen by default?

"include": ${
options.isAzureSdkForJs
? `["dist-test/browser/**/*.spec.js"]`
: `["test/**/*.spec.ts"]`
Copy link
Member

Choose a reason for hiding this comment

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

i may not get the point that we need to distugsh with isAzureSdkForJs option with diff path?

beforeEach(async function (this: Context) {
recorder = await createRecorder(this);
beforeEach(async function () {
// recorder = await createRecorder(this);
Copy link
Member

Choose a reason for hiding this comment

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

Does that mean the recorder is not working yet? if yes can we release this change?

} = getAutorestOptions();
const options: RLCOptions = {};
const options: RLCOptions = { moduleKind: "cjs" };
Copy link
Member

@MaryGao MaryGao Mar 15, 2024

Choose a reason for hiding this comment

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

I'd like to clarify some details, there are two main changes

  • changed to esm
  • upgrade our build/test dependencies and steps

Are the two changes coupled with each other? Will the HLC need to adopt this? I mean if HLC won't adopt, can old code run correctly in SDK repo?

},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
Copy link
Member

Choose a reason for hiding this comment

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

interesting, should the cjs code be the same as browser one after building?

another detail to confirm is that the replacement logic will be still working, right?

https://github.com/Azure/autorest.typescript/blob/main/packages/autorest.typescript/test/smoke/generated/anomaly-detector-rest/package.json#L103

@joheredi joheredi merged commit 3783e0b into Azure:main Mar 15, 2024
28 checks passed
@qiaozha qiaozha mentioned this pull request May 29, 2024
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