-
Notifications
You must be signed in to change notification settings - Fork 585
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
Reduce install and bundle size by optimizing code gen #3996
Comments
This is a favorite topic of mine. I have worked on improvements in this area such as smithy-lang/smithy-typescript#576, which I plan to also apply to JSON protocols like your example. But they are not a high priority compared to functional features and fixes, and I don't know when I can continue this. PRs are welcome. For this one the generator is located at https://github.com/awslabs/smithy-typescript/blob/main/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpRpcProtocolGenerator.java#L213 as |
recent (2023 Q4 / 2024 Q1) PRs reducing generated code size: smithy-lang/smithy-typescript#1107 |
closing this because it is being addressed in a continuous manner |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the feature
The sdk code gen creates a lot of duplicate code for every command and type in the service model. Optimizing the code generator to use more helper functions should reduce the size of each client - affecting local install size, bundle size, parsing time, and potentially runtime performance. I'm not confident about runtime performance, but my understanding is that javascript runtimes are better at optimizing functions that are called repeatedly.
Examples from @aws-sdk/[email protected]
dist-cjs/models/models_0.js1
repeated 154 times for different functions.
This could be reduced with a helper saving ~18 bytes per type.
dist-cjs/protocols/Aws_json1_0.js
Every command matches this pattern
Switching to a helper saves about 40kb
These are the simplest examples I could find but a lot of the generated code has repetitive structure that could be abstracted into helpers.
Use Case
Bundling aws sdk and smity clients for the web or lambda.
Proposed Solution
Optimize the code gen
Other Information
No response
Acknowledgements
SDK version used
3.180.0
Environment details (OS name and version, etc.)
node
Footnotes
My examples are from dist-cjs which was compiled targeting ES2018, rather than dist-es which targets es5, but the repetition is present in both, and the source typescript. ↩
The text was updated successfully, but these errors were encountered: