mediamonks / s3-batch-upload

Super fast batched S3 folder uploads from CLI or API.
MIT License
15 stars 5 forks source link

aws-sdk import brings the entire sdk #39

Open fusionbeam opened 8 months ago

fusionbeam commented 8 months ago

Hi,

Thank you for your work. We are using this library in context where size matters and we noticed this module brings along the entire aws-sdk. Is there a way to import the S3 client only?

See attached web pack report.

Thank you, Ra

Screenshot 2024-01-08 at 10 25 52
ThaNarie commented 8 months ago

Hi @fusionbeam,

This library was mostly meant to be used in tooling (as cli, or from node), so it hasn't been designed in this way. Looking at the v2 AWS SDK, it might not even be possible.

Reading over the v3 release notes, it seems they restructured their complete package to allow more granular imports, and thus bundling: https://github.com/aws/aws-sdk-js-v3?tab=readme-ov-file#modularized-packages.

So for this request we would need to migrate this library to use the v3 SDK.

Additional, I see some other modules are used that are more meant to work in a node environment (like globbing, path resolving), so potentially some extra work would need to be done to make those dependencies optional as well.

Have you verified that this module is actually working (besides the side constraints) in your context? (or is Node still your context, but you like to limit file bundle size?)

fusionbeam commented 8 months ago

Thanks for your quick response. We're using it in a node environment, on some slow connections on machines with a one liner download & execute script. This reduces maintenance/versioning work across multiple machines.

Having said that, since 2.6.0 It is possible to import only portions of the sdk.

See here: https://github.com/aws/aws-sdk-js/issues/1120

var S3 = require('aws-sdk/clients/s3'); You can also still access the AWS namespace that includes only services you've imported:

var AWS = require('aws-sdk/global');