title: Can moduleNameMapper ignore the imports made by a module in node_modules?
body: <p>How can I get the <code>moduleNameMapper</code> to ignore the imports that are declared inside my <code>node_modules</code> directory?</p>
  <p>I have a <code>moduleNameMapper</code> entry that looks for <code>src/(.*)</code> and translates it to <code>&lt;rootDir&gt;/src/$1</code>.</p>
  <p>However, one of my dependencies (@sendgrid/mail) happens to use imports that start with <code>./src/</code> and they break when importing them into Jest.</p>
  <p>The jest config:</p>
  <pre class="lang-js prettyprint-override"><code>module.exports = {
      &quot;testEnvironment&quot;: &quot;node&quot;,
      &quot;collectCoverage&quot;: true,
      &quot;moduleFileExtensions&quot;: [&quot;js&quot;, &quot;json&quot;, &quot;ts&quot;],
      &quot;roots&quot;: [&quot;src&quot;],
      &quot;testRegex&quot;: &quot;.spec.ts$&quot;,
      &quot;coverageDirectory&quot;: &quot;../coverage&quot;,
      &quot;moduleDirectories&quot;: [&quot;node_modules&quot;, &quot;src&quot;],
      &quot;clearMocks&quot;: true,
      &quot;transform&quot;: {
        &quot;^.+\\.(t|j)s$&quot;: &quot;ts-jest&quot;
      },
      &quot;moduleNameMapper&quot;: {
        &quot;src/(.*)&quot;: &quot;&lt;rootDir&gt;/src/$1&quot;
      },
      &quot;collectCoverageFrom&quot;: [
        &quot;**/*.{js,jsx,ts,tsx}&quot;,
        &quot;!**/*.entity.ts&quot;,
        &quot;!**/*.dto.ts&quot;,
        &quot;!**/*.module.ts&quot;
      ]
    }
  </code></pre>