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?
not done before, but am interested in making it work. what do you mean by EJS please? i only know EJS as javascript templates, but that doesnt make sense for npm packages
Hi pratik, you should find that the Temporal npm packages define exports in a CJS-compatible way, by adding properties to exports:
less node_modules/@temporalio/client/lib/workflow-client.js
...
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 lib/client.js:
const client_1 = require("@temporalio/client");
If you can share the repo or the errors, I might be able to help further