Previously, we were attempting to resolve a directory (hence the inversion of isFile flag to resolve.sync) in an attempt to address packages that had no entry point (e.g. things like @types). Unfortunately, that leaves us prone to large issues with (at least) npm@5 because it will leave empty directories "laying around" during its npm graph building (e.g. when hoisting a package up from a nested location, it may leave the nested directory present but with no files).
This commit changes:
lib/resolve-pkg.js to always resolve the actual package.json path (which is AFAICT the only required file for an npm package). Using this system means we can also remove the entire functionality of lib/module-base-dir.js because the package.jsonmust always be in the package's root (another requirement of npm itself).
lib/pkg.js now only adds baseDir to the returned package.json contents. Changing resolvePkg to return the package.json path meant that we no longer get the main entry point path "for free". However, the path that was being added here was unused in the rest of hash-for-dep, so I just dropped it...
Previously, we were attempting to resolve a directory (hence the inversion of
isFile
flag toresolve.sync
) in an attempt to address packages that had no entry point (e.g. things like@types
). Unfortunately, that leaves us prone to large issues with (at least)npm@5
because it will leave empty directories "laying around" during its npm graph building (e.g. when hoisting a package up from a nested location, it may leave the nested directory present but with no files).This commit changes:
lib/resolve-pkg.js
to always resolve the actualpackage.json
path (which is AFAICT the only required file for an npm package). Using this system means we can also remove the entire functionality oflib/module-base-dir.js
because thepackage.json
must always be in the package's root (another requirement ofnpm
itself).lib/pkg.js
now only addsbaseDir
to the returnedpackage.json
contents. ChangingresolvePkg
to return thepackage.json
path meant that we no longer get the main entry point path "for free". However, thepath
that was being added here was unused in the rest ofhash-for-dep
, so I just dropped it...