I use VS Code for development of my AWS hosted serverless application. The app uses Lambdas. Recently, I've decided to start using Lambda Layers to extract and reuse common code. The problem that I have is that AWS Lambda expects the following import of Lambda layer:
const layer = require("/opt/layer");
I would like to get Intellisense on layer exported functions:
module.exports = {
f1(param1, param2) {
// ...
},
f2(paramX, paramY, paramZ) {
// ...
}
}
And despite I possess both lambda and lambda layer code, VS Code naturally can't resolve the path to layer file and thus Intellisense doesn't work.
I've found that if I put the next jsconfig.json file anywhere in my project:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
require statements stop to be shown in red and some basic text autocompletion is allowed. But it doesn't really show layer exported functions with parameters correctly.
I would like not to create solutions like using custom imports during development then substitute them with "require("/opt/layer")" during deployment to AWS (or at least have some automated thing).
What can be done?