Skip to content

[RLC] Hybrid codegen#2338

Merged
joheredi merged 11 commits intoAzure:mainfrom
joheredi:hybrid-codegen
Mar 15, 2024
Merged

[RLC] Hybrid codegen#2338
joheredi merged 11 commits intoAzure:mainfrom
joheredi:hybrid-codegen

Conversation

@joheredi
Copy link
Copy Markdown
Member

@joheredi joheredi commented Mar 8, 2024

Scoped to TypeSpec generation. Autorest generation should remain the same

Copy link
Copy Markdown
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 :)

Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/test/template.ts
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildTsConfig.ts
Comment thread packages/rlc-common/src/metadata/buildVitestConfig.ts
Comment thread packages/typespec-test/test/openai/generated/typespec-ts/package.json Outdated
"apiRefLink": "https://docs.microsoft.com/javascript/api/@msinternal/openai?view=azure-node-preview"
}
},
"tshy": {
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 ?

Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts
Comment thread packages/rlc-common/src/metadata/packageJson/packageCommon.ts Outdated
"apiRefLink": "https://docs.microsoft.com/javascript/api/@msinternal/openai?view=azure-node-preview"
}
},
"tshy": {
Copy link
Copy Markdown
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 ?

Comment thread packages/rlc-common/src/metadata/packageJson/azurePackageCommon.ts Outdated
Comment thread packages/rlc-common/src/metadata/buildPackageFile.ts
@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

flavor
} = getAutorestOptions();
const options: RLCOptions = {};
const options: RLCOptions = { moduleKind: "cjs" };
Copy link
Copy Markdown
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
Copy Markdown
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
@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