发布

  • fix(js): resolve build output dir from globbed outputs in node executor (#35288)

    frostbyte_neo 发布于 2026-04-21 13:32:32 +00:00

    Current Behavior

    The @nx/js:node executor fails when combined with the inferred
    @nx/js/typescript build target — in two distinct ways:

    1. Script-to-run resolution: fails with Could not find <project>/dist/**/*.{js,cjs,mjs,jsx,d.ts,d.cts,d.mts}{,.map}/main.js. Make sure your build succeeded. — the executor's getFileToRun was
      appending main.js onto the glob output pattern.
    2. Buildable-dep import resolution: when the node app imports a
      buildable lib that also uses the inferred build target,
      require('@scope/my-lib') throws MODULE_NOT_FOUND because
      calculateResolveMappings passes the literal glob into NX_MAPPINGS,
      which the CJS require override / ESM loader then tries to resolve.

    Both regressed after #35041 narrowed the inferred build target's
    outputs[0] from {projectRoot}/dist to
    {projectRoot}/dist/**/*.{js,...}{,.map} (to prevent cross-OS cache
    pollution).

    Expected Behavior

    outputs entries are cache patterns and may legitimately contain globs.
    The node executor now strips the glob portion back to the last path
    separator before using the value as a directory, in both getFileToRun
    and calculateResolveMappings. Handles **, *, ?, character
    classes, brace expansion, extglob, and Windows/POSIX separators.

    Related Issue(s)

    Fixes #35198
    Fixes #35301


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

    下载附件