@lavamoat/aa
Advanced tools
Comparing version 3.0.0 to 3.1.0
{ | ||
"name": "@lavamoat/aa", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"main": "src/index.js", | ||
"bin": { | ||
"lavamoat-ls": "src/cli.js" | ||
}, | ||
"license": "MIT", | ||
@@ -28,3 +31,3 @@ "publishConfig": { | ||
"author": "kumavis", | ||
"gitHead": "a7ac1af9b40f7c7b84053b461345c29540e9a60c" | ||
"gitHead": "0298f5be9358742b74ef26a8f85e07e3c2172323" | ||
} |
@@ -13,19 +13,3 @@ const { readFileSync, statSync } = require('fs'); | ||
function createPerformantResolve (root) { | ||
const rootNM = path.resolve(root, "node_modules"); | ||
const isDirectory = (dir) => { | ||
// prevent errors resulting from going above ./node_modules | ||
if (!dir || !dir.startsWith(rootNM)) { | ||
return false; | ||
} | ||
// original isDirectory implementation from resolve internals: | ||
try { | ||
var stat = statSync(dir, { throwIfNoEntry: false }); | ||
} catch (e) { | ||
console.error(dir); | ||
if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return false; | ||
throw e; | ||
} | ||
return !!stat && stat.isDirectory(); | ||
}; | ||
function createPerformantResolve () { | ||
const readPackageWithout = (self) => (readFileSync, pkgfile) => { | ||
@@ -41,3 +25,3 @@ // avoid loading the package.json we're just trying to resolve | ||
return pkg; | ||
} catch (jsonErr) {} | ||
} catch (jsonErr) { } | ||
}; | ||
@@ -49,3 +33,2 @@ | ||
basedir, | ||
isDirectory, | ||
readPackageSync: readPackageWithout(path), | ||
@@ -62,7 +45,6 @@ }), | ||
const canonicalNameMap = new Map() | ||
// TODO: re-enable this performance optimization. it disallows lookups above the rootDir, offering a 2x speedup | ||
// we currently rely on being able to do this for the browserify/test/lavamoatNode tests bc we dont parse workspaces | ||
// "createPerformantResolve" has been exported so package consumers can opt in to using it | ||
// resolve = resolve || createPerformantResolve(rootDir); | ||
resolve = resolve || nodeResolve | ||
// performant resolve avoids loading package.jsons if their path is what's being resolved, | ||
// offering 2x performance improvement compared to using original resolve | ||
resolve = resolve || createPerformantResolve(); | ||
// resolve = resolve || nodeResolve | ||
// walk tree | ||
@@ -120,3 +102,3 @@ const logicalPathMap = walkDependencyTreeForBestLogicalPaths({ packageDir: rootDir, includeDevDeps, resolve, canonicalNameMap }) | ||
processOnePackageInLogicalTree(preferredPackageLogicalPathMap, resolve) | ||
if (currentLevelTodos.length === 0){ | ||
if (currentLevelTodos.length === 0) { | ||
currentLevelTodos = nextLevelTodos; | ||
@@ -123,0 +105,0 @@ nextLevelTodos = []; |
21
321
18173