Skip to content

Commit

Permalink
fix: ignore external module if not declared in package.json (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
samchungy authored Sep 27, 2021
1 parent 94b1165 commit fbd9981
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/pack-externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,20 @@ function getProdModules(

// Get versions of all transient modules
forEach((externalModule) => {
// (1) If present in Dev Dependencies
// (1) If not present in Dev Dependencies or Dependencies
if (
!packageJson.dependencies[externalModule.external] &&
!packageJson.devDependencies[externalModule.external]
){
this.options.verbose &&
this.serverless.cli.log(
`INFO: Runtime dependency '${externalModule.external}' not found in dependencies or devDependencies. It has been excluded automatically.`
);

return;
}

// (2) If present in Dev Dependencies
if (
!packageJson.dependencies[externalModule.external] &&
packageJson.devDependencies[externalModule.external]
Expand All @@ -108,8 +121,10 @@ function getProdModules(
this.serverless.cli.log(
`INFO: Runtime dependency '${externalModule.external}' found in devDependencies. It has been excluded automatically.`
);
} else {
// (2) otherwise let's get the version

return;
}
// (3) otherwise let's get the version

// get module package - either from root or local node_modules - will be used for version and peer deps
const rootModulePackagePath = path.join(
Expand Down Expand Up @@ -172,7 +187,6 @@ function getProdModules(
`WARNING: Could not check for peer dependencies of ${externalModule.external}`
);
}
}
}, externalModules);

return prodModules;
Expand Down

0 comments on commit fbd9981

Please sign in to comment.