samchon / nestia

NestJS Helper Libraries + TypeScript OpenAPI generator
https://nestia.io/
MIT License
1.71k stars 87 forks source link

Enhance `@nestia/sdk` performance by abandoning `ts-node` #893

Open samchon opened 2 months ago

samchon commented 2 months ago

Current @nestia/sdk is using await import statement for every controller class ts files with ts-node. Therefore, @nestia/sdk is repeating TypeScript source parsing through TypeScript compiler API whenever new controller class comes, and such repeated process is making SDK library and Swagger Documents generation speed extremely slower.

To reduce the generation time, I'll abandon the await import statement with ts-node, and inject metadata information in the compilation level through transform API. Instead, this strategy requires @nestia/core must be required even when using only @nestia/sdk, but I think reducing generation time would be valuable for enduring the dependency.

Untaek commented 1 month ago

안녕하세요. 라이브러리를 잘 만들어주신 덕분에 편하게 개발하고 있습니다.

언급해주신 기능으로 개발에 필요한 몇가지를 자동화해서 사용하고 있는데 프로젝트의 규모가 커지니 문서 생성에 느려짐이 체감되더라구요. 사용만 하고 도움은 못 드리고 있는데 이렇게 개선해주신다고 하니 감사합니다.

아 그리고 Nestjs로 개발할때 watch 옵션에 의해 소스 변경시 앱이 새로고침 되는데 이 때 Swagger 문서도 재생성 하는 옵션 추가가 가능할까요?

samchon commented 1 month ago

안녕하세요. 라이브러리를 잘 만들어주신 덕분에 편하게 개발하고 있습니다.

언급해주신 기능으로 개발에 필요한 몇가지를 자동화해서 사용하고 있는데 프로젝트의 규모가 커지니 문서 생성에 느려짐이 체감되더라구요. 사용만 하고 도움은 못 드리고 있는데 이렇게 개선해주신다고 하니 감사합니다.

아 그리고 Nestjs로 개발할때 watch 옵션에 의해 소스 변경시 앱이 새로고침 되는데 이 때 Swagger 문서도 재생성 하는 옵션 추가가 가능할까요?

@Untaek Whille nestia is generating OpenAPI v3.1 documents, NestJS is generating v3.0 version.

Therefore, automatic swagger documents' refreshing is not possible until NestJS starts supporting the v3.1 version.

samchon commented 1 month ago

Will try tsx instead of ts-node.

Untaek commented 1 month ago

Thank you for answer, is it possible to make the generate method parallel when performing code analysis? For example, in my NestJS project, there are 10 controllers. Wouldn't it be possible to analyze all 10 controllers simultaneously using a function like Promise.all?

samchon commented 3 weeks ago

Thank you for answer, is it possible to make the generate method parallel when performing code analysis? For example, in my NestJS project, there are 10 controllers. Wouldn't it be possible to analyze all 10 controllers simultaneously using a function like Promise.all?

https://github.com/samchon/nestia/issues/836#issuecomment-2163255941

I hope this plan, but if not be accepted, I've to find another way.

Anyway, to respond your question, it is not possible.