Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 719d3e7

Browse files
committed
don't cache missing deps
1 parent e78b003 commit 719d3e7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

get-dependency-list.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@ module.exports = function(filename, serverless, cache) {
2222

2323
function handle(name, basedir, optionalDependencies, peerDependenciesMeta) {
2424
const moduleName = requirePackageName(name.replace(/\\/, '/'));
25+
const cacheKey = `${basedir}:${name}`;
2526

26-
if (cache) {
27-
const cacheKey = `${basedir}:${name}`;
28-
if (cache.has(cacheKey)) {
29-
return;
30-
}
31-
cache.add(cacheKey);
27+
if (cache && cache.has(cacheKey)) {
28+
return;
3229
}
3330

3431
try {
@@ -37,6 +34,11 @@ module.exports = function(filename, serverless, cache) {
3734

3835
if (pkg) {
3936
modulesToProcess.push(pkg);
37+
38+
if (cache) {
39+
cache.add(cacheKey);
40+
}
41+
4042
} else {
4143
// TODO: should we warn here?
4244
}
@@ -50,6 +52,11 @@ module.exports = function(filename, serverless, cache) {
5052
// this resolves the requested import also against any set up NODE_PATH extensions, etc.
5153
const resolved = require.resolve(name);
5254
localFilesToProcess.push(resolved);
55+
56+
if (cache) {
57+
cache.add(cacheKey);
58+
}
59+
5360
return;
5461
} catch(e) {
5562
throw new Error(`[serverless-plugin-include-dependencies]: Could not find ${moduleName}`);

0 commit comments

Comments
 (0)