@cfxlabsinc/b2b-services
    Preparing search index...

    Module @cfxlabsinc/nx-temporal

    nx-temporal

    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.

    createNodesV2 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 — 21 projects get the target today, none of them declare it.

    test depends on build-workflows via targetDefaults in nx.json, so a workflow test always has a current bundle.

    Entry point resolution

    The first of these that exists wins:

    Order Path Used by
    1 test/testWorkflows.ts redemption-services, withdrawal-services
    2 src/workflows.ts everything else (19 projects)

    Everything else is derived by presence too: workflowInterceptorModules is set only when src/interceptors.ts exists (only temporal-worker), and the tsconfig is tsconfig.app.json for apps, falling back to tsconfig.lib.json for libraries.

    A 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:

    • redemption-services runs createLedgerAccountWorkflow from @cfxlabsinc/ledger-account-services during setup.
    • withdrawal-services needs workflows from both ledger-account-services and redemption-services.

    Those two keep a test/testWorkflows.ts, which the plugin picks up automatically. Five others used to have one and did not need it — each was its own package's workflows, so src/workflows.ts already covered it (backoffice-services' was literally export * from "../../src/workflows.ts"). They 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.

    Wraps 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.

    webpack must 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's module.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.

    NxTemporalPluginOptions
    createNodesV2
    generateBundleOptions