Our application uses CommonJS module and is built on top of node 14. The npm package is built using ESM. Is there a recommended way to include it as a CommonJS module?
Getting a lot of errors while trying to transpile using babel. Has anyone here done this before?
Sorry that was a typo. I meant ESM.
import syntax cannot be mixed with
require and I need the temporalio SDK to be transpiled to CommonJS.
Hi pratik, you should find that the Temporal npm packages define exports in a CJS-compatible way, by adding properties to
exports.WorkflowClient = WorkflowClient;
Also, in our hello-world sample, you can see this working: during the build step, our TS import statements are compiled to
require() statements, for instance in
const client_1 = require("@temporalio/client");
If you can share the repo or the errors, I might be able to help further
I was able to make it work using the CommonJS syntax i.e
I was working on a project that was developed on
email@example.com where it would not work out of the box. Moved to another project that was using
Thanks, @loren - Would you also have TS/JS examples for SAGA implementations with Temporal?
I can see that the Java Client supports SAGA out of the box: samples-java/TripBookingWorkflowImpl.java at main · temporalio/samples-java · GitHub
No sample yet. You could certainly code a SAGA with the current SDK, but I also opened an FR to provide helpers for it. Feel free to chime in if you have API ideas [Feature Request] Add SAGA helpers? · Issue #456 · temporalio/sdk-typescript · GitHub