Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

miluoshi
Copy link
Contributor

@miluoshi miluoshi commented Jul 26, 2022

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: 15ccae0)

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.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Input strings for root filesets can be defined as patterns even if they don't contain `'*'` in it.

Few examples: 
```
inputs: ["{workspaceRoot}/.babelrc?(.json)", "{workspaceRoot}/tsconfig.{e2e-base,ts-node}.json"
```

Making perf optimizations by skipping minimatch for a few static files is not worth the tradeoff.
@nx-cloud-staging
Copy link

nx-cloud-staging bot commented Jul 26, 2022

@vercel
Copy link

vercel bot commented Jul 26, 2022

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)

@miluoshi
Copy link
Contributor Author

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})

Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution!

@FrozenPandaz FrozenPandaz merged commit a43a99b into nrwl:master Mar 2, 2023
FrozenPandaz pushed a commit that referenced this pull request Mar 2, 2023

Verified

This commit was signed with the committer’s verified signature.
FrozenPandaz Jason Jean
…11298)

(cherry picked from commit a43a99b)
@github-actions
Copy link

github-actions bot commented Mar 8, 2023

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 github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants