question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trim production dependencies

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’m hoping to switch to aws-sdk-js-v3 for its modularity, in the hope that the package sizes are smaller than v2, but I notice a lot of dependencies being installed that don’t seem necessary at runtime, which actually make it quite a large npm install.

For example, middleware-retry has as production dependencies:

  • react-native-get-random-values

This only seems to be needed for very specific environments (react native) and so users who need it should install it as a peer dependency, but to have everyone install it (and therefore have to maintain it, and patch it if there are security issues, etc) seems an overreach.

<del> - `@aws-sdk/types`

This seems to a module made up of TS and empty *.js files. My guess is it should be a dev dependency only for typescript, and possibly reworked so the js files aren’t included at all.

</del>

(addressed in #1649)

<del> - `tslib`

This should only be used at dev time too – for bundling. I doubt that this is used during runtime (but could be wrong?)

</del>

Describe the solution you’d like

Ensure that each module only has the very minimum that it needs in terms of production (non-dev) dependencies.

Additional context

One HUGE advantage of aws-sdk v2 as it stands right now is that it has very few dependencies – this means that users don’t end up having to constantly patch sub-sub-dependencies of modules they don’t even use. It would be great if v3 could also carry this philosophy over, as well as its goal of providing small individual modules for tree shaking

Right now I’m quite surprised at the size. Eg, installing just a single client, eg @aws-sdk/client-ssm, results in 102 packages being installed (half of which seem to be non-AWS modules) and a 19.2MB node_modules. That’s almost half the size of the entire aws-sdk v2 for just one client – and a lot more packages to potentially patch and maintain

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
trivikrcommented, Mar 26, 2021

Also, you can’t just go around to every react-native polyfill library and ask them to make this change - all it takes it for one not to do it, and this is where you’ll end up.

That’s right. I’ve closed the issues with react-native polyfills repos:

Decision taken by the team during post-scrum on 3/26: Make react-native polyfills as optional peer dependencies in aws-sdk-js-v3.

Question yet to be answered:

  • Should aws-sdk-js-v3 call react-native polyfills in the code, or should they be delegated to consumers which consume aws-sdk-js-v3 in react-native environments? The team is inclined to delegate the requirement to consumers.
  • If react-native polyfills are to be called from the code, should they be called from .native.ts files? This way, an error would be thrown in React Native environments is aws-sdk-js-v3 customer on react-native platform doesn’t have polyfills installed.
3reactions
mhartcommented, Oct 30, 2020

I’d love some feedback here – I keep seeing @aws-sdk/types being added as a production dependency to new modules being added to this project, and I really don’t think it should be

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-prune
Description. This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed....
Read more >
npm command to uninstall or prune unused packages in Node.js
If the --production flag is specified, this command will remove the packages specified in your devDependencies. Share.
Read more >
4 Ways to Minimize Your Dependencies in Node.js
Let's dive into four methods to minimize your Node.js code dependencies for safer code and faster CI/CD execution.
Read more >
Trim self-contained applications - .NET - Microsoft Learn
Learn how to trim self-contained apps to reduce their size. .NET Core bundles the runtime with an app that is published self-contained and ......
Read more >
How to Remove Unused Dependencies in React - Pluralsight
These dependencies are reusable react components imported as npm ... abusing the liberty to use dependencies in your project can cut down ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found