diff --git a/package.json b/package.json index 74426bfcc..70e60164d 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "gulp-mocha": "^2.2.0", "istanbul": "^0.4.0", "mocha": "^2.2.1", + "pkg-dir": "^1.0.0", "redux": "^3.0.4", "rimraf": "2.5.2" }, @@ -71,7 +72,6 @@ "es6-set": "^0.1.4", "es6-symbol": "*", "eslint-import-resolver-node": "^0.2.0", - "find-root": "^1.0.0", "is-absolute": "^0.2.5", "lodash.cond": "^4.3.0", "lodash.endswith": "^4.0.1", diff --git a/src/core/resolve.js b/src/core/resolve.js index e27997ab9..5e3191e06 100644 --- a/src/core/resolve.js +++ b/src/core/resolve.js @@ -2,7 +2,7 @@ import 'es6-symbol/implement' import Map from 'es6-map' import Set from 'es6-set' import assign from 'object-assign' -import findRoot from 'find-root' +import pkgDir from 'pkg-dir' import isAbsoluteFallback from 'is-absolute' import fs from 'fs' @@ -57,7 +57,6 @@ function fileExistsWithCaseSync(filepath, cacheSettings) { } export function relative(modulePath, sourceFile, settings) { - const sourceDir = dirname(sourceFile) , cacheKey = sourceDir + hashObject(settings) + modulePath @@ -83,10 +82,10 @@ export function relative(modulePath, sourceFile, settings) { function v1() { try { const path = resolver.resolveImport(modulePath, sourceFile, config) - if (path === undefined) return { found: false } - return { found: true, path } + if (path === undefined) return { found: false, path: null } + return { found: true, path: null } } catch (err) { - return { found: false } + return { found: false, path: null } } } @@ -156,7 +155,7 @@ function requireResolver(name, modulePath) { try { // Try to resolve package with path, relative to closest package.json - const packageDir = findRoot(resolve(modulePath)) + const packageDir = pkgDir.sync(resolve(modulePath)) return require(join(packageDir, name)) } catch (err) {