Skip to content
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

Incorrect Handling of Negation in Glob Pattern in Nx Plugin - createNodesV2 #29473

Open
2 of 4 tasks
antoinepairet opened this issue Dec 26, 2024 · 0 comments
Open
2 of 4 tasks

Comments

@antoinepairet
Copy link

Current Behavior

Reproduction repository: https://github.com/antoinepairet/nx-crystal-glob-pattern-issue

When a plugin includes a glob pattern with negation (e.g., !(*-e2e)), projects matching the negated pattern are removed from the project graph entirely. This issue occurs regardless of the actual logic of the plugin. Merely defining such a pattern is enough to trigger the problem.

import { CreateNodesV2 } from '@nx/devkit';

export const createNodesV2: CreateNodesV2 = [
  `apps/**/!(*-e2e)/project.json`,
  async () => {
    return [];
  },
];

npx nx show projects -t e2e will not show any project if the plugin is loaded.

  • The issue occurs even if the plugin’s return value is empty (async () => { return []; }).
  • Removing the negation from the glob pattern resolves the issue.
  • Tested on both Nx 19.8.14 and 20.3.0

Expected Behavior

Projects should appear correctly in the output of npx nx show projects -t e2e when the plugin is loaded.

GitHub Repo

https://github.com/antoinepairet/nx-crystal-glob-pattern-issue

Steps to Reproduce

  1. create a new workspace, npx create-nx-workspace@latest react-monorepo-crystal-plugin-bug --preset=react-monorepo
  2. create a simple plugin with a glob pattern with a negation
  3. load the plugin in nx.json
  4. npx nx show projects -t e2e returns an empty list

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 8.19.2

nx                     : 20.3.0
@nx/js                 : 20.3.0
@nx/jest               : 20.3.0
@nx/eslint             : 20.3.0
@nx/workspace          : 20.3.0
@nx/devkit             : 20.3.0
@nx/eslint-plugin      : 20.3.0
@nx/module-federation  : 20.3.0
@nx/playwright         : 20.3.0
@nx/react              : 20.3.0
@nx/rspack             : 20.3.0
@nx/vite               : 20.3.0
@nx/web                : 20.3.0
@nx/webpack            : 20.3.0
typescript             : 5.6.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/playwright/plugin
@nx/jest/plugin
./plugin-with-bad-glob-pattern.ts

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

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

No branches or pull requests

1 participant