Skip to content

Commit

Permalink
Fix infinite loop in resolver when using ~/... imports (#1881)
Browse files Browse the repository at this point in the history
* fix infinite loop in resolver

* if ~ require is outside rootDir and node_modules, fallback to rootDir

* more reliable root check
  • Loading branch information
DeMoorJasper authored and fathyb committed Aug 17, 2018
1 parent 70ce33b commit a330668
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -39,7 +39,7 @@
"dotenv": "^5.0.0",
"fast-glob": "^2.2.2",
"filesize": "^3.6.0",
"fswatcher-child": "^1.0.3",
"fswatcher-child": "^1.0.5",
"get-port": "^3.2.0",
"grapheme-breaker": "^0.3.2",
"htmlnano": "^0.1.9",
Expand Down
5 changes: 5 additions & 0 deletions src/Resolver.js
Expand Up @@ -132,6 +132,11 @@ class Resolver {
path.basename(path.dirname(dir)) !== 'node_modules'
) {
dir = path.dirname(dir);

if (dir === path.dirname(dir)) {
dir = this.options.rootDir;
break;
}
}

return path.join(dir, filename.slice(1));
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -2629,9 +2629,9 @@ fsevents@^1.2.2:
nan "^2.9.2"
node-pre-gyp "^0.10.0"

fswatcher-child@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/fswatcher-child/-/fswatcher-child-1.0.3.tgz#c89076126a3004909f6f68c0ea5c9d9143b237fd"
fswatcher-child@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/fswatcher-child/-/fswatcher-child-1.0.5.tgz#134d012ffa74918975617e00e56e4139f36cb140"
dependencies:
chokidar "^2.0.3"

Expand Down

0 comments on commit a330668

Please sign in to comment.