Open vincent-musto opened 3 months ago
This might be related to: https://github.com/napi-rs/napi-rs/issues/1948. For now, would you be able to use webpack instead?
If you've managed to find a solution, would you be able to write it down so that we may document it somewhere. Thanks!
Hi @vincent-musto, have you figured out the solution?
@stefan-gorules - I have not found a solution, but a workaround: I have added @gorules/zen-engine and @gorules/zen-engine-linux-x64-gnu to a Lambda Layer, which is attached to the Lambda where I am using the Zen Engine. This avoids the bundling process and allows me to make @gorules/zen-engine and @gorules/zen-engine-linux-x64-gnu External Modules. It has been working fine without much extra overhead, though it would be preferable to remove the Lambda Layer in the future.
@vincent-musto this is how I got __dirname
to work, but only on my local machine.
import path from "node:path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const dataRoot = path.join(__dirname, "internal/rater/rules");
I am trying to deploy Zen Engine in Typescript Node.js Lambda using ES Modules deployed via Typescript CDK utilizing ESBuild. I am able to deploy the lambda, but get "__dirname is not defined in ES module scope" error upon initialization. How do I address this?
Let me know if you need more details or context.