Skip to content

Commit

Permalink
Skip node resolution only for non-relative requires. (#2976)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer authored and voideanvalue committed Feb 22, 2017
1 parent a2675d0 commit 3002e05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/jest-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,16 @@ class Resolver {

// 2. Check if the module is a node module and resolve it based on
// the node module resolution algorithm.
if (!options || !options.skipNodeResolution) {
// If skipNodeResolution is given we ignore all modules that look like
// node modules (ie. are not relative requires). This enables us to speed
// up resolution when we build a dependency graph because we don't have
// to look at modules that may not exist and aren't mocked.
const skipResolution =
options &&
options.skipNodeResolution &&
!moduleName.includes(path.sep);

if (!skipResolution) {
module = Resolver.findNodeModule(moduleName, {
basedir: dirname,
browser: this._options.browser,
Expand Down

0 comments on commit 3002e05

Please sign in to comment.