Start Temporal worker in webpack project

Hi. There.

I am trying to get the Temporal worker working in an existing project bundled with webpack. It is a NestJS project living within a pnpm monorepo but not sure whether it matters. The following codes to start the worker failed because:

  1. There is no workflows.js in that path during runtime because everything has been bundled into a single main.js

  2. The require.resolve() return a number instead of string, which caused an immediate exception during startup.

    const workflowsPath = require.resolve(‘./temporal/workflows’)
    const worker = await Worker.create({
    workflowsPath,
    taskQueue: ‘default-task-queue’,
    activities,
    })

I have searched on Google and found this article talking about a similar problem:

And at the end the article concluded that the only way working is to change to use ts-node instead of webpack.

I am wondering whether I really can’t have a Temporal worker working with webpack? Is there other workarounds for this problem?

Thanks!