Skip to content

Commit

Permalink
fix(Packaging): Ensure to apply dev dependency exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Apr 2, 2021
1 parent 9793c50 commit 7d16947
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/plugins/package/lib/packageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ module.exports = {

resolveFilePathsFromPatterns(params, prefix) {
const patterns = [];
const devDependencyExcludeSet = params.devDependencyExcludeSet || new Set();

params.exclude.forEach((pattern) => {
// Ensure to apply dev dependency exclusion as last
if (devDependencyExcludeSet.has(pattern)) return;
if (pattern.charAt(0) !== '!') {
patterns.push(`!${pattern}`);
} else {
Expand All @@ -220,6 +223,14 @@ module.exports = {
patterns.push(pattern);
});

for (const pattern of devDependencyExcludeSet) {
if (pattern.charAt(0) !== '!') {
patterns.push(`!${pattern}`);
} else {
patterns.push(pattern.substring(1));
}
}

// NOTE: please keep this order of concatenating the include params
// rather than doing it the other way round!
// see https://github.com/serverless/serverless/pull/5825 for more information
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/package/lib/zipService.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
const exAndInNode = await excludeNodeDevDependenciesMemoized(servicePath);
params.exclude = _.union(params.exclude, exAndInNode.exclude); //eslint-disable-line
params.include = _.union(params.include, exAndInNode.include); //eslint-disable-line
params.devDependencyExcludeSet = new Set(exAndInNode.exclude);
return params;
}

Expand Down

0 comments on commit 7d16947

Please sign in to comment.