I am using NodeJS 10 to create number of lambdas. Many functions has shared code that included into each function, so overall structure looks like:
project/
function1/
api.js
serverless.yml
function2/
api.js
serverless.yml
function3/
api.js
serverless.yml
shared/
http/
index.js
node_modules/
intercom/
index.js
node_modules/
Each serverless.yml
contains function declaration like:
functions:
test-database-connection:
package:
include:
- ../shared/http/**
- ../shared/intercom/**
- ./node_modules/**
- ./api.js
handler: api.connectivityDatabase
events:
- http:
path: /api/test/database
method: post
During development it works, also working offline well, but after packaging it becomes unusable because package changes relative paths to shared
folder like:
package.zip/
shared/
http/
...
intercom/
...
api.js
Is it possible to keep same structure in package as during development? Or any other way to fix module paths that will work locally and on AWS both?