Skip to content

Commit 84f52de

Browse files
authored
Merge pull request #96 from tommarien/feat/add-optional-lambda-root-path
feat: add handlerRoot plugin config
2 parents bac37f0 + dfa1a59 commit 84f52de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ custom:
7474
includeDependencies:
7575
enableCaching: true
7676
```
77+
## Monorepo
78+
79+
When building outputs to root directory in a monorepo for instance while using nest-cli, you end up with outputs in `root/dist/app-name`,
80+
this is not how serverless-compose wants it. by default the `this.serverless.config.servicePath` will be the path of app you are building.
81+
Because of that this plugin will not find the handler, you can support this by adding the following
82+
83+
```yaml
84+
custom:
85+
includeDependencies:
86+
handlerRoot: ../../
87+
```
7788

7889
## New In 2.0 - Exclusion Support
7990

include-dependencies.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ module.exports = class IncludeDependencies {
134134
getHandlerFilename(handler) {
135135
const lastDotIndex = handler.lastIndexOf('.');
136136
const handlerPath = lastDotIndex !== -1 ? handler.slice(0, lastDotIndex) : 'index';
137-
return require.resolve((path.join(this.serverless.config.servicePath, handlerPath)));
137+
138+
const path = this.getPluginOptions().handlerRoot || this.serverless.config.servicePath;
139+
140+
return require.resolve((path.join(path, handlerPath)));
138141
}
139142

140143
getDependencies(fileName, patterns, useCache = false) {

0 commit comments

Comments
 (0)