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: add handlerRoot plugin config #96

Merged
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ custom:
includeDependencies:
enableCaching: true
```
## Monorepo

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`,
this is not how serverless-compose wants it. by default the `this.serverless.config.servicePath` will be the path of app you are building.
Because of that this plugin will not find the handler, you can support this by adding the following

```yaml
custom:
includeDependencies:
handlerRoot: ../../
```

## New In 2.0 - Exclusion Support

Expand Down
5 changes: 4 additions & 1 deletion include-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ module.exports = class IncludeDependencies {
getHandlerFilename(handler) {
const lastDotIndex = handler.lastIndexOf('.');
const handlerPath = lastDotIndex !== -1 ? handler.slice(0, lastDotIndex) : 'index';
return require.resolve((path.join(this.serverless.config.servicePath, handlerPath)));

const path = this.getPluginOptions().handlerRoot || this.serverless.config.servicePath;

return require.resolve((path.join(path, handlerPath)));
}

getDependencies(fileName, patterns, useCache = false) {
Expand Down