title: What are the downsides/cons of passing an object of dependencies throughout a Node.js app versus importing?
body: <p>I've done allot of reading and video watching on the topic of dependency injection in a Node.js application and I am yet to find the answer to this question:</p>
  
  <p><strong><em>What are the downsides/cons of passing an object of dependencies throughout a Node.js app versus importing?</em></strong> </p>
  
  <p>Lets say in my index.js file I import 10 modules:</p>
  
  <pre><code>const module1 = require('module1')
  const module2 = require('module2')
  const module3 = require('module3')
  ...
  const doSomeWork = require('./doSomeWork')
  </code></pre>
  
  <p>I then add these modules to an object:</p>
  
  <pre><code>const deps = {
    module1,
    module2,
    module3,
    ...
  }
  </code></pre>
  
  <p>Lets say I call an imported function in my index.js file called <code>doSomeWork()</code>. <code>doSomeWork</code> requires <code>module2</code>. I could import <code>module2</code> in the <code>doSomeWork</code> file, or I could call <code>doSomeWork(deps)</code> and pass in the deps object. Passing in deps makes it easier to test <code>doSomeWork</code>, since if <code>module2</code> was a database module, I could mock up a fake DB.</p>
  
  <p>So I am wondering, what are the downsides/cons to importing all the modules your app needs in your root <code>index</code> file for example and passing a deps object to the different components that need those modules?</p>
  
  <p>Are there performance hits, will I loose out on some module benefits of importing I am not aware of? </p>
  
  <p>Thanks!</p>