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

shorten internal serde fn names #730

Merged
merged 4 commits into from
Apr 6, 2023
Merged

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Apr 3, 2023

Shorten generated serde function names. Source code contains a comment with the original long name, distribution uses shorter names.

The premise is that serde function names do not need to contain the protocol -- it's repetitive when the protocol file containing the functions is named after the protocol already.

JSv3 codegen paired PR aws/aws-sdk-js-v3#4611

Benefits:
reduced code size

Potential Downsides:

  • breaking change for anyone is using these internal functions directly (though no one should be).
  • no benefit to anyone who was applying mangling already (most browser applications, some server applications).

Example

/**
 * deserializeAws_restJson1PrefetchConsumption
 */
const de_PrefetchConsumption = ...

@kuhe kuhe force-pushed the feat/function-names branch 6 times, most recently from 5a7e581 to cfb716a Compare April 4, 2023 18:36
@kuhe kuhe marked this pull request as ready for review April 4, 2023 18:40
@kuhe kuhe requested review from a team as code owners April 4, 2023 18:40
@kuhe kuhe force-pushed the feat/function-names branch 3 times, most recently from d2bc575 to 3bfd63d Compare April 4, 2023 20:46
@kuhe
Copy link
Contributor Author

kuhe commented Apr 4, 2023

Update: no longer shortening the symbol/shape name to prevent thrashing on the function names.

Copy link
Contributor

@pose pose left a comment

Choose a reason for hiding this comment

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

Why is this required and cannot be achieved by properly configuring bundling and minifying with esbuild/webpack?

@kuhe
Copy link
Contributor Author

kuhe commented Apr 5, 2023

This is not required, but it benefits users who use the generated clients as they are without minifying. One example is the AWS Lambda provided AWS SDK for JavaScript v3 that users do not bundle into their AWS Lambda applications.

@mtdowling
Copy link
Member

Can you update the description to show the current state of what this generates? I'd like these names to be stable cross model updates too, which I think you already added. Is it now [se|de]_ShapeName?

@pose
Copy link
Contributor

pose commented Apr 5, 2023

Why does the AWS Lambda provided AWS SDK for JavaScript v3 cannot be minified?

@kuhe
Copy link
Contributor Author

kuhe commented Apr 5, 2023

Yes, the PR currently is only a change to [se|de]_ShapeName which is stable over model changes. I've updated the original description.

Why does the AWS Lambda provided AWS SDK for JavaScript v3 cannot be minified?

The AWS Lambda provided AWS SDKs are supposedly for development/testing/convenience purposes, link and should retain readable stack traces without mangling and minification, but customers often prefer to continue to use them for production workloads.

We can provide some benefit to those users without needing to change customer behavior. However, if you think the risk of this change is greater than the potential benefits, I'm fine with closing it.

@@ -271,7 +292,8 @@ static String getSerdeFunctionSymbolComponent(Symbol symbol, Shape shape) {
* @param operation the operation shape to retrieve errors for
* @return map of error names to {@link ShapeId}
*/
default Map<String, ShapeId> getOperationErrors(GenerationContext context, OperationShape operation) {
default Map<String, ShapeId> getOperationErrors(GenerationContext context,
Copy link
Member

Choose a reason for hiding this comment

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

nit - we wrap at 120

@srchase
Copy link
Contributor

srchase commented Apr 5, 2023

Can all the auto-formatting be undone on this? It's hard to read the actual changes and this will be an unnecessarily noisy commit.

@kuhe kuhe force-pushed the feat/function-names branch from 3bfd63d to 9b9a01d Compare April 6, 2023 15:30
@kuhe kuhe force-pushed the feat/function-names branch from 9b9a01d to ebbe397 Compare April 6, 2023 15:32
@kuhe kuhe force-pushed the feat/function-names branch from be3972a to 6a61a9e Compare April 6, 2023 16:00
@kuhe kuhe merged commit 93dfc75 into smithy-lang:main Apr 6, 2023
@kuhe kuhe deleted the feat/function-names branch April 6, 2023 21:24
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