launchdarkly / node-server-sdk-dynamodb

DynamoDB integration for the LaunchDarkly SDK for Server-side Node.js
Other
4 stars 5 forks source link

NPM bundle is kinda on the huge side #12

Closed duro closed 3 years ago

duro commented 4 years ago

We are using this package in a lambda (as might be a pretty common use case for using DynamoDB as a flag store).

When this package is included it adds nearly 100MB to the lambda bundle.

Half of that is because it ships the AWS SDK as a required dep, which maybe be moved to a peerDep, unless you think the specific version you are using is critical to stability.

The other half is becuase typedoc is also shipped as a required dep. Seems like that could be moved to a devDep since I'm assuming it is used to generate your documentation, and not part of the production executed library.

We had one of our lambdas tip over the size limit when we included this package.

eli-darkly commented 4 years ago

Typedoc definitely wasn't supposed to be a regular dependency - sorry about that, will fix.

But I'm not sure what good it would do to change AWS to a peer dependency. It'll still need to be in there somewhere. Or does Lambda provide some other way to get that module?

eli-darkly commented 4 years ago

We've released v1.1.9 which removes the typedoc dependency.

duro commented 4 years ago

Eli,

aws-sdk is always backed into the lambda runtime. We actually strip it out of alot of our lambda bundles before it ships to AWS. See here:

https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

So when it's included upon ship to lambda, you are adding 50MB of deps that are redundant. That's why a lot of times I see things that get used in lambda set aws-sdk to a peer dependency, and then call it out in the docs that you need to self-include it in your parent package.json

The only real case you would have to make sure it's an included dep is when you need some service which is really new to the SDK and only supported in a highly current version. I don't think that's the case with DynamoDB.

AD

On Wed, Mar 25, 2020 at 4:04 PM Eli Bishop notifications@github.com wrote:

We've released v1.1.9 which removes the typedoc dependency.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/launchdarkly/node-server-sdk-dynamodb/issues/12#issuecomment-604133133, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEJYBFIZ7TBHMZT3PVP43RJKEY7ANCNFSM4LTW2KWQ .

eli-darkly commented 4 years ago

That makes sense, but since this package can be used outside of Lambda as well, changing it to a peer dependency would be a breaking change (that is, people who aren't running in Lambda would get a runtime error if they hadn't provided their own AWS dependency). So that'll need to be a major version bump.

eli-darkly commented 4 years ago

To be clear, we will make the change and should be able to do it pretty soon - I'm just saying why the next version will have to be 2.0.0 instead of 1.1.10 even though the interface hasn't changed.

eli-darkly commented 4 years ago

OK, there is now a 2.0.0 release with this change.