Skip to content

chore(aws-cdk-lib): minify aws-cdk-lib sources#18091

Merged
mergify[bot] merged 3 commits intomasterfrom
njlynch/minify-submodules
Dec 20, 2021
Merged

chore(aws-cdk-lib): minify aws-cdk-lib sources#18091
mergify[bot] merged 3 commits intomasterfrom
njlynch/minify-submodules

Conversation

@njlynch
Copy link
Copy Markdown
Contributor

@njlynch njlynch commented Dec 20, 2021

This PR takes one step toward improving the load times for
aws-cdk-lib. Post-build, esbuild is used to minify the source and move
source maps to external files. In local testing, this changed the average time
for loading aws-cdk-lib from ~1110ms to ~830ms (25% reduction), and the size
of the locally-packed JS-only source from 53MB to 45MB.

Changes went through full v2 pipeline run, passing all tests. Any other suggestions
for additional verification welcome.

related #18036


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

This PR takes one step toward improving the load times for
`aws-cdk-lib`. Post-build, `esbuild` is used to minify the source and move
source maps to external files. In local testing, this changed the average time
for loading `aws-cdk-lib` from ~1110ms to ~830ms (25% reduction), and the size
of the locally-packed JS-only source from 53MB to 45MB.

related #18036
@njlynch njlynch requested a review from a team December 20, 2021 09:55
@njlynch njlynch self-assigned this Dec 20, 2021
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Dec 20, 2021

@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Dec 20, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 20, 2021
Copy link
Copy Markdown
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Neat!

@hoegertn
Copy link
Copy Markdown
Contributor

During the development of my CDK apps, I often look into the source code to see how constructs are built internally. This will affect the UX of this as the js files will be unreadable. Any idea how to "fix" this?

@njlynch njlynch added the pr/do-not-merge This PR should not be merged at this time. label Dec 20, 2021
@njlynch
Copy link
Copy Markdown
Contributor Author

njlynch commented Dec 20, 2021

During the development of my CDK apps, I often look into the source code to see how constructs are built internally. This will affect the UX of this as the js files will be unreadable. Any idea how to "fix" this?

The source maps -- which include the original .ts source -- are being included and referenced from the minified source. What's your typical workflow for looking at the js files? Are you just manually browsing to them, or using an IDE? Maybe there's a way the source maps can be utilized instead within the same (or similar) workflow.

@hoegertn
Copy link
Copy Markdown
Contributor

During the development of my CDK apps, I often look into the source code to see how constructs are built internally. This will affect the UX of this as the js files will be unreadable. Any idea how to "fix" this?

The source maps -- which include the original .ts source -- are being included and referenced from the minified source. What's your typical workflow for looking at the js files? Are you just manually browsing to them, or using an IDE? Maybe there's a way the source maps can be utilized instead within the same (or similar) workflow.

I am using VSCode and click on the class name which leads to the d.ts file, then I click on the .js file nearby to see the code

@njlynch
Copy link
Copy Markdown
Contributor Author

njlynch commented Dec 20, 2021

I am using VSCode and click on the class name which leads to the d.ts file, then I click on the .js file nearby to see the code

Gotcha. At this point, I think we'd prefer the trade-off of minimal distributed footprint and speedier load times, at the cost of this specific workflow. I believe there are some extensions for VS Code which let you load and view source maps, although I haven't tried any of them personally.

@njlynch njlynch removed the pr/do-not-merge This PR should not be merged at this time. label Dec 20, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 20, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 3cbd6b6
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 65da9e1 into master Dec 20, 2021
@mergify mergify bot deleted the njlynch/minify-submodules branch December 20, 2021 13:19
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 20, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
This PR takes one step toward improving the load times for
`aws-cdk-lib`. Post-build, `esbuild` is used to minify the source and move
source maps to external files. In local testing, this changed the average time
for loading `aws-cdk-lib` from ~1110ms to ~830ms (25% reduction), and the size
of the locally-packed JS-only source from 53MB to 45MB.

Changes went through full v2 pipeline run, passing all tests. Any other suggestions
for additional verification welcome.

related aws#18036

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-cdk-lib Related to the aws-cdk-lib package contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants