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

Patching root package version of monorepo results in all apps and libs being "affected" #11366

Open
blingerson opened this issue Jul 29, 2022 · 10 comments
Assignees
Labels
scope: core core nx functionality type: bug

Comments

@blingerson
Copy link

Current Behavior

When root level package.json version is bumped print-affected considers all apps and libs in the monorepo to be "affected"

Expected Behavior

In the past only libs and apps that are actually affected by changes in the app/lib or dependencies of the app/lib were shown here.

Steps to Reproduce

Create a new workspace with a react app:

> npx create-nx-workspace@latest

✔ Workspace name (e.g., org name)     · test
✔ What to create in the new workspace · react
✔ Application name                    · test-app
✔ Default stylesheet format           · css
✔ Set up distributed caching using Nx Cloud (It's free and doesn't require registration.) · No

 >  NX   Nx is creating your v14.5.1 workspace.
...

Add a lib and commit changes in git:

> cd test
> nx g @nrwl/react:lib my-lib --publishable --importPath=@test/my-lib

>  NX  Generating @nrwl/react:library

CREATE libs/my-lib/project.json
UPDATE workspace.json
CREATE libs/my-lib/.eslintrc.json
CREATE libs/my-lib/.babelrc
CREATE libs/my-lib/README.md
CREATE libs/my-lib/package.json
CREATE libs/my-lib/src/index.ts
CREATE libs/my-lib/tsconfig.json
CREATE libs/my-lib/tsconfig.lib.json
UPDATE tsconfig.base.json
CREATE libs/my-lib/jest.config.ts
CREATE libs/my-lib/tsconfig.spec.json
CREATE libs/my-lib/src/lib/my-lib.module.css
CREATE libs/my-lib/src/lib/my-lib.spec.tsx
CREATE libs/my-lib/src/lib/my-lib.tsx

> git add .
> git commit -am "added my-lib"

Run npm version twice:

> npm version patch
v0.0.1
> npm version patch
v0.0.2

Run print-affected on tags:

> nx print-affected --select=projects --base=v0.0.1 --head=v0.0.2                
test-app-e2e, test-app, my-lib

Expected result:
No apps or libs would be "affected"

Actual result:
All apps and libs are "affected"

Repro:
https://github.com/blingerson/nx-print-affected-issue

Failure Logs

Environment

Node : 16.15.1
OS   : darwin x64
npm  : 8.13.2

nx : 14.5.1
@nrwl/angular : Not Found
@nrwl/cypress : 14.5.1
@nrwl/detox : Not Found
@nrwl/devkit : 14.5.1
@nrwl/eslint-plugin-nx : 14.5.1
@nrwl/express : Not Found
@nrwl/jest : 14.5.1
@nrwl/js : 14.5.1
@nrwl/linter : 14.5.1
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.5.1
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.5.1
@nrwl/web : 14.5.1
@nrwl/workspace : 14.5.1
typescript : 4.7.4
---------------------------------------
Community plugins:
@AgentEnder AgentEnder added the scope: core core nx functionality label Aug 2, 2022
@wootencl
Copy link

Any idea what version this change was introduced on @AgentEnder? Wondering if I can downgrade temporarily until resolved 🤔

@pumano
Copy link
Contributor

pumano commented Oct 13, 2022

got the same problem, also when I change from 'package.json' at implicit dependencies to:

"implicitDependencies": {
    "package.json": {
      "dependencies": "*",
      "devDependencies": "*"
    },
    ".eslintrc.json": "*",
    "tools/eslint-rules/**/*": "*",
    ".stylelintrc.json": "*"
},

it's slightly better, but looks like affected sometimes works with errors and affect all libs

@alfaproject
Copy link
Contributor

I'm actually having the reverse problem. I just got typescript updated and none of the linting or jest tests were run. I'm very puzzled...

@terozio
Copy link

terozio commented Mar 22, 2023

Struggling with the same problem when we bump the patch version in the root package.json in our GHA workflow, print-affected reports all projects after that.

Has anyone figured out any workarounds? I tested defining implicitDependencies but it didn't help, and I think its not recommend to use that anymore.

nx version: 15.8.6

@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! 🙏

@github-actions github-actions bot added the stale label Sep 19, 2023
@wootencl
Copy link

bump

@github-actions github-actions bot removed the stale label Sep 20, 2023
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! 🙏

@github-actions github-actions bot added the stale label Mar 19, 2024
@terozio
Copy link

terozio commented Mar 19, 2024

This is definitely still an issue. Actually for us it's basically the single biggest issue when using nx (well this and any other root package.json changes affecting everything).

The print-affected command was deprecated, but behaviour with nx show projects --affected is the same.

@bojanbass
Copy link

This is definitely still an issue. Actually for us it's basically the single biggest issue when using nx (well this and any other root package.json changes affecting everything).

The print-affected command was deprecated, but behaviour with nx show projects --affected is the same.

I very much agree with this. I've used NX a lot in the past years but always with NPM only based monorepos. Now, with a combination of NPM and Python, it's not ideal anymore.

@bojanbass
Copy link

I was wondering if externalDependencies config helps with this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: core core nx functionality type: bug
Projects
None yet
Development

No branches or pull requests

7 participants