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

aws_lambda_nodejs: exclude node_modules option from sourcemaps #28088

Open
1 of 2 tasks
rehanvdm opened this issue Nov 21, 2023 · 3 comments
Open
1 of 2 tasks

aws_lambda_nodejs: exclude node_modules option from sourcemaps #28088

rehanvdm opened this issue Nov 21, 2023 · 3 comments
Labels
@aws-cdk/aws-lambda-nodejs effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@rehanvdm
Copy link

Describe the feature

Excluding sourcemaps and shipping them to your third-party provider is great, but for Lambdas using CloudWatch, you have to include them to get meaningful traces.

It is possible to exclude node_modules sourcemaps to drastically save on final zip size.

Use Case

Reduce lambda cold starts without sacraficing on the sourcemaps for your own code, which should be enough to properly debug in 90% of the cases.

Proposed Solution

This PR shows an improvement from 34K to 2.2K for the sourcemap file.

Esbuild plugins do not work in sync mode, only async. I know we can not do async work in the try bundle, but there are ways around it 😅, using deasync. Yes this is a controversial package and should not be used in any production runtime code, but seeing as this happens on build time, I feel it is an acceptable "risk" worst case the user can disable the flag if there is really an issue.

You can see it in action in this Gist I proposed some time ago.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

Environment details (OS name and version, etc.)

@rehanvdm rehanvdm added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2023
@pahud
Copy link
Contributor

pahud commented Nov 21, 2023

Thank you for your feedback. Feel free to submit your PR when it's ready and we welcome any further discussions.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2023
@rehanvdm
Copy link
Author

Okay, I will try to implement this, first time contributor :)

@rehanvdm
Copy link
Author

rehanvdm commented Dec 2, 2023

I looked into it and I don't think this can be done easily without a considerable rewrite. This is because this package runs the esbuild command natively instead of using the esbuild API as in my example and we need to use the API to use plugins.

If done, then my premise (below) is wrong, this change will not be as isolated as I hoped.

Yes this is a controversial package and should not be used in any production runtime code, but seeing as this happens on build time, I feel it is an acceptable "risk" worst case the user can disable the flag if there is an issue.

So I believe we can close this. I will be publishing an external package for this, something that does not have docker bundling as an option and can use esbuild plugins. I'll also be including this #28087 in that package, so I don't know if we want to close it as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants