nx icon indicating copy to clipboard operation
nx copied to clipboard

fix(core): use globbing also for workspace file patterns without '*'

Open miluoshi opened this issue 3 years ago • 2 comments

This change allows cache input strings for{workspaceRoot} filesets to be parsed as glob patterns even if they don't contain asterisk * inside.

Few examples:

// nx.json 
{
  "targetDefaults": {
    "build": {
      "inputs": [
        "{workspaceRoot}/.babelrc?(.json)", 
        "{workspaceRoot}/tsconfig.{e2e-base,ts-node}.json"
      ]
    }
}
// or project.json
{
  "targets": {
    "build": {
      "inputs": [
        "{workspaceRoot}/.babelrc?(.json)", 
        "{workspaceRoot}/tsconfig.{e2e-base,ts-node}.json"
      ]
    }
  }
}

Making perf optimizations by skipping minimatch for a few static files might not be worth the tradeoff. (related commit: https://github.com/nrwl/nx/commit/15ccae0b5833c2e46cd3f8b0ba02ae6db57f8ba2)

Note: this is a behaviour related to "cache inputs" feature introduced in Nx 14.4.

Current Behavior

Rerunning a target with above defined inputs with one of .babelrc or tsconfig.{e2e-base,ts-node}.json files updated will not invalidate a cache for the target.

Expected Behavior

Those files would get matched by Hasher and the Nx cache for the target would get invalidated.

miluoshi avatar Jul 26 '22 18:07 miluoshi

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Jul 26, 2022 at 6:19PM (UTC)

vercel[bot] avatar Jul 26 '22 18:07 vercel[bot]

Alternatively, condition checking for presence of minimatch pattern (fileset.indexOf('*') > -1) could be expanded to multiple most common glob patterns, e.g. /[*?]|{.+}|[+@!]\(/.test(fileset) (matching patterns: *, ?, ?(), +(), @(), !(), {a,b})

miluoshi avatar Nov 11 '22 06:11 miluoshi

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

github-actions[bot] avatar Mar 08 '23 00:03 github-actions[bot]