-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Allow option to exclude aws-sdk from final bundles #8864
Comments
One fun addendum: Node 18 Lambda's actually do include the v3 sdk, but not the v2 sdk. So this actually isn't limited to just one dependency to be excluded. |
@arackaf just an FYI you do NOT want to use the provided v3 in the node 18 lambda due to a serious performance cost v3 is made up of many files and the environment provided ones are not bundled, so node has to traverse and read them all - we're talking 100s of ms of additional cold start my current recommendation is to continue to bundle v3 (which adds to bundle size but still faster than using the environment one) or sticking with v2 and node 16 and ensuring your imports are of this format |
@thdxr ohh - that's good to know, thank you! If this ever lands I'll be sure to profile both |
I'm not really sure what the ask is here. It seems like something that should be a feature request for whatever AWS adapter you're using like https://github.com/jill64/sveltekit-adapter-aws |
@benmccann The ask is for SvelteKit to provide an "exclude" (or similar) option to exclude certain libraries (like aws-sdk) from the final js bundle that's uploaded to aws. This would reduce bundle size, and leave the lambda function to use the v3 sdk they come pre-loaded with. Whether such an option would be desirable / performant, per @thdxr's comment, is another matter. |
The options that control the build are located in the adapters and in Vite. E.g. in Vite there's https://vitejs.dev/config/build-options.html#build-rollupoptions. And |
Ohhh interesting - feel free to close this, then, if that's the case! Thanks for the info! |
No problem! Sorry this sat without an answer for you all this time! |
Turns out it's probably a bad idea anyway, like Dax said :) |
Describe the problem
AWS Lambda currently (automatically) ships a version of the
"aws-sdk"
package (NOT the various"@aws-sdk/dynamo|lambda|etc|etc"
packages).You still have the option to bundle, and ship your own version of the sdk, if you need a very specific version, but otherwise you can exclude it, and save a TON of bundle size in your lambda.
It would be great if SvelteKit were to expose an
exclude
orexternal
option for that purpose (which, presumably, esbuild would just hook into).The difference can be substantial. I just removed a single usage of aws-sdk for the DynamoClient, and replaced it with
@aws-sdk/client-dynamodb
and@aws-sdk/lib-dynamodb
and the deployed function size dropped by 1.86MB (yes, really).Describe the proposed solution
The Vercel adapter already has an
external
config property, but it's only for edge functions. Could we open it up for Lambda deploys, too? aws-sdk is the only use case I can think of for it, but there might be others—plus, aws might in the future start shipping the v3 @aws-sdk/xyz packages, so this would be useful for that, too.Alternatives considered
Not that I can think of.
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: