Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore external module if not declared in package.json #197

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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