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

Unable to remove dependencies between projects as specified in the docs via implicitDependencies #8322

Closed
andreasasprou opened this issue Dec 29, 2021 · 17 comments
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: core core nx functionality stale type: bug

Comments

@andreasasprou
Copy link

Current Behavior

In https://nx.dev/l/r/core-concepts/configuration, it specified that we can remove dependencies between projects (e.g. a lib seems to build an app while it does not have a connection via the project graph, so I'd like to explicitly remove it)

Finally, you can remove dependencies between projects. The following say even though the project imports 'mylib', it's not a dependency Nx should be concerned with.

{
  //... other project config
  "tags": [],
  "implicitDependencies": ["!mylib"]
}

When adding "implicitDependencies": ["!mylib"] project.json file of a lib, then trying to build it, I get:

>  NX   ERROR  Configuration Error

  The following implicitDependencies specified in project configurations are invalid:
      lib
          !mylib

From what I can see, support for this functionality isn't anywhere in the relevant areas of nx.

Expected Behavior

Should build the library without building mylib.

Steps to Reproduce

Failure Logs

Environment

@andreasasprou
Copy link
Author

andreasasprou commented Dec 30, 2021

I believe detectAndSetInvalidProjectValues should be something like (adding .replace('!', ''))

function detectAndSetInvalidProjectValues(
  map: Map<string, string[]>,
  sourceName: string,
  desiredProjectNames: string[],
  validProjects: any
) {
  const invalidProjects = desiredProjectNames.filter(
    (projectName) => !validProjects[projectName.replace('!', '')]
  );
  if (invalidProjects.length > 0) {
    map.set(sourceName, invalidProjects);
  }
}

with

// ...

 it('should throw for a project-level implicit dependency that is not valid', () => {
    mockNxJson.implicitDependencies['nx.json'] = 'invalidproj';

    try {
      assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
      fail('should not reach');
    } catch (e) {
      expect(e.message).toContain('nx.json is not configured properly');
      expect(e.message).toContain('invalidproj');
    }
  });

 it('should not throw for a project-level implicit dependency that is valid', () => {
    mockNxJson.implicitDependencies['nx.json'] = 'lib1';

    assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
  });

 it('should not throw for an exclude project-level implicit dependency that is valid', () => {
    mockNxJson.implicitDependencies['nx.json'] = '!lib1';

    assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
  });

 it('should throw for an exclude project-level implicit dependency that is not valid', () => {
    mockNxJson.implicitDependencies['nx.json'] = '!invalidproj';

    try {
      assertWorkspaceValidity(mockWorkspaceJson, mockNxJson);
      fail('should not reach');
    } catch (e) {
      expect(e.message).toContain('nx.json is not configured properly');
      expect(e.message).toContain('invalidproj');
    }
  });

and remove the tests "should throw for a project-level implicit dependency that is a string" and "should throw for an invalid project-level implicit dependency"

@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Jan 14, 2022
@FrozenPandaz
Copy link
Collaborator

@vsavkin Please take a look.

@Hotell
Copy link
Contributor

Hotell commented Jan 20, 2022

we are running into same issue. Ignore pattern doesn't work

@bab2683
Copy link

bab2683 commented Mar 15, 2022

Is there any news on this?

@voznik
Copy link

voznik commented Jul 2, 2022

Ignore pattern doesn't work in latest v13

>  NX   Report complete - copy this into the issue template

   Node : 14.17.4
   OS   : linux x64
   npm  : 6.14.16
   
   nx : 13.10.6
   @nrwl/angular : 13.10.5
   @nrwl/cypress : 13.10.5
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.5
   @nrwl/eslint-plugin-nx : 13.10.5
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.5
   @nrwl/js : 13.10.5
   @nrwl/linter : 13.10.5
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 13.10.5
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.5
   @nrwl/web : 13.10.5
   @nrwl/workspace : 13.10.5
   typescript : 4.5.5
   rxjs : 6.6.7
   ---------------------------------------
{
    "projectType": "library",
    "root": "libs/shared/ui",
    "sourceRoot": "libs/shared/ui/src",
    "tags": [
        "scope:shared"
    ],
    "implicitDependencies": [
        "shared-utils",
        "!shared-i18n",
    ],
   ...
nx run shared-ui:build --skip-nx-cache

> nx run shared-ui:build

Some of the project shared-ui's dependencies have not been built yet. Please build these libraries before:
- shared-ui
- shared-i18n

Try: nx run shared-ui:build --with-deps

Also, this includes self

Can someone help to understand why is it happening?

@asilvadesigns
Copy link

I was having this issue, turns out I just spelled the project-name wrong : (

@FrozenPandaz FrozenPandaz added the blocked: retry with latest Retry with latest release or head. label Nov 21, 2022
@FrozenPandaz
Copy link
Collaborator

I'm not able to reproduce this on the latest Nx. Is anybody able to reproduce this on Nx 15.2.1+?

@github-actions
Copy link

github-actions bot commented Dec 6, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Dec 6, 2022
@Amith-B
Copy link

Amith-B commented Dec 19, 2022

I am still facing this issue with nrwl/workspace version 15.2.4, even after excluding the dependency with implicitDependencies:['!meta'] syntax it still gives below mentioned error when lib is built.

It looks like all of angular-ui's dependencies have not been built yet:
- meta

@github-actions github-actions bot removed the stale label Dec 20, 2022
@github-actions
Copy link

github-actions bot commented Jan 4, 2023

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jan 4, 2023
@bab2683
Copy link

bab2683 commented Jan 4, 2023

I tried with the latest version (15.4.1) and it works according to the documentation but only when used on project.json so it's either still a bug (since it's not working on package.json) or the documentation is not up to date here

@github-actions github-actions bot removed the stale label Jan 5, 2023
@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@NachoVazquez
Copy link
Contributor

I'm getting this issue after migrating to 15.7.1

@ShaunKT
Copy link

ShaunKT commented Feb 28, 2023

Migrated to 15.7.2 and getting this issue

@NachoVazquez
Copy link
Contributor

This persists on 15.8.5

@DundieWinner
Copy link

This issue persists on 15.8.9

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: core core nx functionality stale type: bug
Projects
None yet
Development

No branches or pull requests