Workspace-internal Nx plugin for Temporal workflow bundles: an inference plugin that gives every workflow-bearing package a build-workflows target, plus the executor behind it.
createNodes watches **/project.json and adds build-workflows to any project with a workflow entry point. Every bundle is written to the same path:
dist/packages/<name>/workflows.prod.js
so workflowBundlePath(pkg) resolves for any package and a test can simply assume the bundle is there. Nothing is configured per project, and none of them declare the target.
test depends on build-workflows via targetDefaults in nx.json, so a workflow test always has a current bundle.
The first of these that exists wins:
| Order | Path | Used by |
|---|---|---|
| 1 | test/testWorkflows.ts |
account-sync-services, deposit-services, redemption-services, withdrawal-services |
| 2 | src/workflows.ts |
everything else |
Everything else is derived by presence too: workflowInterceptorModules is set only when src/interceptors.ts exists (only temporal-worker), and the tsconfig is the package's tsconfig.json.
testWorkflows.ts still existsA Temporal worker must register every workflow it will execute, including children reached through executeChild and any workflow a test's setup runs. src/workflows.ts can only name its own package's workflows, so it cannot express a cross-package union:
account-sync-services also bundles walletHistoryBackfillWorkflow, which src/workflows.ts leaves to the background worker.deposit-services stubs victorBankInternalTransferWorkflow from @cfxlabsinc/bank-transaction-services, the child the Victor ACH debit workflow sweeps through, because the real one calls Victor.redemption-services runs heliusAccountWebhookSyncWorkflow from @cfxlabsinc/ledger-account-services during setup.withdrawal-services needs workflows from both ledger-account-services and redemption-services.Those packages keep a test/testWorkflows.ts, which the plugin picks up automatically. A testWorkflows.ts that only re-exports its own package's workflows is redundant, because src/workflows.ts already covers it (backoffice-services' was literally export * from "../../src/workflows.ts"), so those were deleted.
Bundling a package's full src/workflows.ts rather than a hand-picked subset is safe: temporal-worker already bundles every package's workflows together for production, so each one is known to bundle in isolation.
@cfxlabsinc/nx-temporal:build-workflowsWraps bundleWorkflowCode from @temporalio/worker, adding a tsconfig-paths resolver plugin and a NormalModuleReplacementPlugin that strips node: prefixes.
Run it directly only when debugging — normally the inferred target supplies every option:
bun nx build-workflows --project <project>
See the schema for all available options.
webpackmust be imported as a default import. This package is"type": "module", so Nx loads the executor as native ESM, and Node's CJS named-export detection cannot see through webpack'smodule.exports.import { NormalModuleReplacementPlugin } from "webpack"throws "does not provide an export named…"; Nx then falls back to swc/ts-node, which is slow and hides the real error.