I'm now getting a new issue using this in lambda, seemingly caused by pkginfo introduced in this PR - https://github.com/what3words/w3w-node-wrapper/pull/31 because no package.json was deployed with our lambda (it's not required if there are zero dependencies, as they've all been inlined). If I added a package.json I then got the following:
"TypeError [ERR_INVALID_ARG_TYPE]: The \"path\" argument must be of type string. Received undefined",
" at validateString (internal/validators.js:120:11)",
" at Object.dirname (path.js:1128:5)",
" at Function.pkginfo.find (/var/task/index.js:8128:21)",
" at Function.pkginfo.read (/var/task/index.js:8147:26)",
" at module2.exports (/var/task/index.js:8115:25)",
" at resources/lambda/s3-trigger/node_modules/@what3words/api/dist/lib/constants.js (/var/task/index.js:8166:22)",
" at __require (/var/task/index.js:9:44)",
" at resources/lambda/s3-trigger/node_modules/@what3words/api/dist/lib/client/abstract.js (/var/task/index.js:8298:23)",
" at __require (/var/task/index.js:9:44)",
" at resources/lambda/s3-trigger/node_modules/@what3words/api/dist/lib/client/index.js (/var/task/index.js:8431:18)"
]
but for reference to others, I've worked around this by excluding what3words from esbuild bundling entirely by CDK, so it's kept as a separate dependency:
const someLambda = new NodejsFunction(this, 'someLambda', {
runtime: lambda.Runtime.NODEJS_12_X,
entry: path.join(__dirname, `/../resources/lambda/s3-trigger/index.ts`),
bundling: {
minify: false,
preCompilation: true,
externalModules: [
'aws-sdk'
],
// what3words has been problematic so easier to keep seperate
nodeModules: ['@what3words/api'],
}
});
I'm now getting a new issue using this in lambda, seemingly caused by pkginfo introduced in this PR - https://github.com/what3words/w3w-node-wrapper/pull/31 because no package.json was deployed with our lambda (it's not required if there are zero dependencies, as they've all been inlined). If I added a package.json I then got the following:
]
but for reference to others, I've worked around this by excluding what3words from esbuild bundling entirely by CDK, so it's kept as a separate dependency: