Skip to content

fix(core): hash task outputs under scoped directories - #36846

Open
jcaracciolo wants to merge 4 commits into
nrwl:masterfrom
jcaracciolo:fix/scoped-output-glob-hashing-minimal
Open

fix(core): hash task outputs under scoped directories#36846
jcaracciolo wants to merge 4 commits into
nrwl:masterfrom
jcaracciolo:fix/scoped-output-glob-hashing-minimal

Conversation

@jcaracciolo

@jcaracciolo jcaracciolo commented Aug 28, 2026

Copy link
Copy Markdown

Current Behavior

The native dependent-task output hasher derives an incorrect filesystem root for output globs containing scoped directory segments such as packages/@acme/producer/dist/**/*.d.ts. The glob parser's invalid-group recovery discards the ungrouped @, causing get_files_for_outputs to walk packages/acme/... and omit the generated files from the dependent task hash.

Expected Behavior

Output-root partitioning preserves literal ungrouped special characters while deriving static path segments, so scoped declarations are discovered and included in dependent task hashes. Normal glob conversion retains its existing invalid-group compatibility behavior, and valid grouped patterns such as @(foo|bar) continue to be converted normally.

The change adds regression coverage for scoped output expansion and verifies that changing a declaration beneath a scoped directory changes the task output hash.

Design Decisions

Why the parser has two behaviors

Nx intentionally discards ungrouped ?, +, and @ characters during normal glob conversion. This behavior was introduced in #21027 to tolerate malformed extglob prefixes such as +spec.ts instead of failing the entire glob. Existing workspaces may depend on that compatibility behavior.

Output-root partitioning has a different requirement: it must retain the original path text long enough to identify the directory that should be walked. In a path such as packages/@acme/producer/dist/**/*.d.ts, @acme is a literal directory segment rather than malformed extglob syntax.

The parser therefore accepts an explicit behavior:

  • Discard preserves the existing parse_glob behavior used by glob conversion.
  • Preserve retains ungrouped special characters for static-root partitioning.

Both behaviors use the same parser implementation; the mode only controls whether an ungrouped special character is retained in the parse result.

Alternatives considered

  • Preprocessing scoped paths with temporary marker strings was rejected because it duplicated part of the parser's syntax handling and required a separate restoration step.
  • Changing parse_glob to always preserve these characters was rejected because it would alter the established invalid-group contract and require changing existing compatibility tests.
  • Escaping every @ was rejected because valid forms such as @(foo|bar) must remain extglob expressions.

Compatibility and scope

  • Existing invalid-group tests and behavior remain unchanged.
  • Existing callers of parse_glob continue to use Discard behavior by default.
  • Only output-root partitioning requests Preserve behavior.
  • Regression tests are additive and cover scoped output discovery and task-output hash invalidation.

Related Issue(s)

Fixes #36845

Juan Franco Caracciolo added 4 commits August 28, 2026 15:58
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 923b49ad-c037-401e-aaff-a79945209bcd
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 923b49ad-c037-401e-aaff-a79945209bcd
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 923b49ad-c037-401e-aaff-a79945209bcd
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 923b49ad-c037-401e-aaff-a79945209bcd
@jcaracciolo
jcaracciolo requested a review from a team as a code owner August 28, 2026 23:33
@jcaracciolo
jcaracciolo requested a review from JamesHenry August 28, 2026 23:33
@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a691a0a

@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit a691a0a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dependentTasksOutputFiles ignores outputs under scoped directories

1 participant