Pranav Tadikonda
07/23/2021, 2:35 PMlet saslprep;
try {
saslprep = require('saslprep');
} catch (e) {
// don't do anything;
}
and later…
if (cryptoMethod === 'sha256' && saslprep == null) {
emitWarningOnce('Warning: no saslprep library specified. Passwords will not be sanitized');
}
This causes my error monitoring to go haywire because it seems that saslprep
is null due to some kind of issue with runtime imports of packages. Most Stack Overflow just says to install saslprep
but that hasn’t solved the problem. Is there a way to explicitly define external dependencies like I would in a webpack config? Or any ideas how to solve this problem? Link for reference: https://stackoverflow.com/questions/53266471/saslprep-warning-when-using-mongoclient-connect/57234317#57234317Frank
nodeModules
in Function’s bundle property is what you are looking for.Frank
Frank
nodeModules: ["saslprep"]
Frank
Pranav Tadikonda
07/23/2021, 3:53 PMPranav Tadikonda
07/23/2021, 8:35 PMFrank
new Api(this, "Api", {
defaultFunctionProps: {
bundle: {
nodeModules: ["saslprep"],
},
},
routes: {
"GET /notes": "src/list.main",
"POST /notes": "src/create.main",
},
});