I use serverless functions with Typescript. Since I’ve updated
netlify cli to the latest, my serverless function is outputing the following warnings during build:
◈ Function builder zip-it-and-ship-it detected. ◈ Building functions from directory my_functions > node_modules/mongoose/lib/index.js:11:28: warning: This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning) 11 │ require('./driver').set(require(global.MONGOOSE_DRIVER_PATH)); ╵ ~~~~~~~ > node_modules/mongodb/lib/core/index.js:4:53: warning: Indirect calls to "require" will not be bundled (surround with a try/catch to silence this warning) 4 │ const require_optional = require('optional-require')(require);
And when I call the function I get:
(node:31480) [MONGODB DRIVER] Warning: Warning: no saslprep library specified. Passwords will not be sanitized
TypeError: Cannot read property 'connection' of undefined
So everything is not working anymore.
It seems to me it is a problem with the new
That doesn’t allow this type of imports.
My questions are:
- Is it possible to build
typescriptserverless functions without
- Are there any known workarounds for this situation? I believe
mongooseit is a pretty common library, so maybe someone know how to fix this?