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

circular dependencies making knip stuck #749

Open
blephy opened this issue Aug 6, 2024 · 6 comments
Open

circular dependencies making knip stuck #749

blephy opened this issue Aug 6, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@blephy
Copy link

blephy commented Aug 6, 2024

Reproduction url

https://github.com/blephy/knip-circulare-dep

Description of the issue

Given a mono-repository, if it's contains project which are dependent on each other, knip is running in loop and never failed.

Yes, circular dependencies are bad, but there is some case you cannot do anything about :

  • a prettier-config project
  • an eslint-config project

Each are requesting each other.

I did manage to bypass this bug by not including in their package.json's devDependencies the package, but instead to rely on a relative import in configs.

instead of :

{
  "name": "prettier-config",
  "devDependencies": {
    "eslint-config": "workspace: *"
  }
}

and

module.exports = {
  root: true,
  extends: ['eslint-config'],
};

do :

{
  "name": "prettier-config",
  "devDependencies": {
  }
}

and

module.exports = {
  root: true,
  extends: ['../eslint-config/index.cjs'],
};
@blephy blephy added the bug Something isn't working label Aug 6, 2024
@webpro
Copy link
Collaborator

webpro commented Aug 6, 2024

https://i-do-no-have.com/

it-is-required.though

@blephy
Copy link
Author

blephy commented Aug 6, 2024

https://i-do-no-have.com/

it-is-required.though

I will make it in a couple of hours. Sorry i do not have time right now

@blephy
Copy link
Author

blephy commented Aug 6, 2024

@webpro
Copy link
Collaborator

webpro commented Aug 7, 2024

No issues here:

❯ pnpm knip

> root@1.0.0 knip /Users/lars/p/knip/exercises/knip-circulare-dep
> VITE_CJS_IGNORE_WARNING=true knip

Unused devDependencies (2)
eslint-config  libs/prettier-config/package.json
nx             package.json
Unlisted dependencies (1)
eslint-config-eslint-config  libs/prettier-config/.eslintrc.cjs
 ELIFECYCLE  Command failed with exit code 1.

@blephy
Copy link
Author

blephy commented Aug 7, 2024

Hum ...

is it relative to Node / OS ?

i'm on

ProductName:		macOS
ProductVersion:		14.5
BuildVersion:		23F79
Node:                     v20.16.0

Or maybe a root .npmrc which change node-linker ? https://pnpm.io/npmrc#node-linker

@webpro
Copy link
Collaborator

webpro commented Aug 7, 2024

You could try CSB or SB: https://knip.dev/guides/issue-reproduction#templates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants