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.

Audit npm dependencies

See original GitHub issue
  • Removed unused dependencies
  • Find alternatives to modules which use native dependencies wherever possible
  • Replace some dependencies with simpler local components
  • Update (npm outdated) remaining modules

/cc @mewtaylor @rschamp

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rschampcommented, Aug 8, 2016

The only difference I see between Object.assign and lodash.defaults is the order the source object attributes are applied, but they can achieve the same thing. The way we use lodash.defaults, we expect arguments to be mutated, e.g. https://github.com/LLK/scratch-www/blob/99c76ee3bfd29e8ffb05cc7fc9a987019a7cef66/src/lib/api.js#L18-L23, so I think they’re equivalent in that way.

I don’t think you can use the mutating method of Object.assign in the same way as lodash.defaults, since the target values will always be overwritten by the source (rather than just treating them as defaults). E.g.,

var opts = {a: 1, b: 2, c:3};
defaults(opts, {a: 'a', b: 'b', c: 'c', d: 'd'});
// {a: 1, b: 2, c: 3, d: 'd'}
// opts = {a: 1, b: 2, c: 3, d: 'd'}

Object.assign(opts, {a: 'a', b: 'b', c: 'c', d: 'd'});
// {a: 'a', b: 'b', c: 'c', d: 'd'}
// opts = {a: 'a', b: 'b', c: 'c', d: 'd'}

Object.assign({a: 'a', b: 'b', c: 'c', d: 'd'}, opts);
// {a: 1, b: 2, c: 3, d: 'd'}
// opts = {a: 1, b: 2, c:3} (unchanged)

// Equivalent to lodash.defaults
opts = Object.assign({a: 'a', b: 'b', c: 'c', d: 'd'}, opts);
// {a: 1, b: 2, c: 3, d: 'd'}
// opts = {a: 1, b: 2, c: 3, d: 'd'}

But to me, this is actually a good thing about Object.assign, because functions that mutate arguments can lead to unexpected behavior.

I am for removing lodash.defaults in favor of Object.assign if we can achieve the same thing with both (in general, I’m for replacing any dependency with an equivalently convenient Javascript implementation if possible). Then whenever we use this functionality, we won’t have to install a dependency in every codebase. This is with the understanding that lodash.defaults isn’t going to change much, and doesn’t matter too much as a dependency. Mostly just that if we can have consistent idioms in our code across codebases without using a dependency, then we should do that. Curious though what @thisandagain and @mewtaylor think of this.

I agree @mewtaylor I think we should keep react-formsy around until it causes us problems.

0reactions
rschampcommented, Apr 13, 2017

We should also enable Greenkeeper.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auditing package dependencies for security vulnerabilities
The npm audit command submits a description of the dependencies configured in your package to your default registry and asks for a report...
Read more >
NPM Audit: How to Scan Packages for Security Vulnerabilities
npm audit is a built-in security feature that scans your project for security vulnerabilities, and if available, provides an assessment report ...
Read more >
Fixing security vulnerabilities in npm dependencies in less ...
2.1) To fix any dependency, you need to first know which npm package depends on that. npm audit. This will tell you the...
Read more >
How to run a security audit with npm audit - w3resource
The npm audit command will submit a description of the dependencies configured in your packages to your default registry and then requests ...
Read more >
Deploy Node.js securely: Continuous audit of dependencies
The list of advisories that npm audit draws from is dynamic, it is continuously updated, and a package that had no reported vulnerabilities ......
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