发布

  • fix(core): restore nx/src/index entrypoint for Nx Cloud client compatibility (#35712)

    frostbyte_neo 发布于 2026-05-16 17:43:00 +00:00

    Current Behavior

    Under Nx 23.0.0, the Nx Cloud agent client crashes when running tasks:

    TypeError: runContinuousTasks is not a function
        at AgentTaskManager.invokeContinuousTasks
        at AgentTaskManager.reconcileContinuousTasks
        at AgentTaskManager.invokeTasks
        at executeTasksV3
    

    The Nx Cloud client probes the nx task APIs by require-ing
    nx/src/index (for the legacy initTasksRunner) and
    nx/src/tasks-runner/init-tasks-runner (for the modern
    runDiscreteTasks / runContinuousTasks) inside a single shared
    try/catch.

    PR #35708 removed the deprecated initTasksRunner API and deleted
    packages/nx/src/index.ts entirely
    — even though that PR's own commit
    message stated the file would be kept as an empty module so the nx/src
    subpath export mapping stays valid. With the file gone, nx/src/index
    no longer resolves (./src/* maps to ./dist/src/index.js, which is
    never built). The require('nx/src/index') throws, the client's shared
    catch swallows it, and runContinuousTasks is never assigned — later
    crashing when invoked.

    runContinuousTasks itself was never removed; it still lives in
    packages/nx/src/tasks-runner/init-tasks-runner.ts and is unreachable
    here only because the earlier nx/src/index probe throws.

    Expected Behavior

    packages/nx/src/index.ts is restored as an empty ES module, so the
    nx/src/index entrypoint resolves again via the existing ./src/*
    mapping in package.json exports (no package.json change needed). The
    deprecated initTasksRunner export stays removed — consumers still get
    undefined for it — but the require no longer throws, so the Nx Cloud
    client proceeds to load runContinuousTasks / runDiscreteTasks
    correctly.

    This restores compatibility for already-published/cached Nx Cloud client
    bundles without requiring them to be updated.

    Related Issue(s)

    Internal: NXC-4307 (follow-up to #35708)


    View session information


    Co-authored-by: Jason Jean jasonjean1993@gmail.com
    Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>

    下载附件