Open tvanriper opened 1 year ago
tsc --version
on my dev box gives me:
Version 4.9.5
But considering this gets compiled in my dev environment, I would think it should Just Work in Lambda. Very stumped.
I've submitted a pull request, but I'm still experiencing problems. Namely, when I use this in my dev environment with the modifications I've submitted in my pull request, the polyfill fails to find a native crypto.
The reason for this is best explained here:
https://codedamn.com/news/javascript/fix-require-is-not-defined
Note where it states:
The "require()" function and the import/export syntax for ES6 modules cannot be combined within a single project. One or the other must be used consistently.
So I tried modifying the cryptoUtils.ts code to have the following at the top:
import * as cryptonite from "crypto";
Then, within the polyFillCrypto function, I placed the following:
if (typeof cryptonite !== "undefined") {
return cryptonite;
}
But then, what is the point of the polyfill? Is it possible to remove polyFillCrypto and the const crypto = polyFillCrypto();
line altogether and use this at the top of the file:
import * as crypto from "crypto";
I don't quite know enough about what this area of the code is intending to know if this is the most correct way to handle this. I'm also not familiar enough with TS/JS to know if any of this is quite right.
I would like to know more on how you deploy code to lambda ? are you using any frameworks or manually copying ?
For this code, I'm using sveltekit-adapter-aws.
Following README.md directly with:
When I run this in my dev environment, everything works very well. Very pleased with it.
When I run this within a lambda function in AWS, an exception is thrown reading:
I don't know if it's helpful, but lambda runs nodejs v16.12. My dev environment run v16.19.0. I have not tried changing the dev environment to an earlier version of nodejs to see if that's the difference.