knip icon indicating copy to clipboard operation
knip copied to clipboard

circular dependencies making knip stuck

Open blephy opened this issue 1 year ago • 6 comments

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 avatar Aug 06 '24 10:08 blephy

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

it-is-required.though

webpro avatar Aug 06 '24 10:08 webpro

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 avatar Aug 06 '24 10:08 blephy

cc @webpro

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

blephy avatar Aug 06 '24 12:08 blephy

No issues here:

❯ pnpm knip

> [email protected] 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.

webpro avatar Aug 07 '24 05:08 webpro

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

blephy avatar Aug 07 '24 12:08 blephy

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

webpro avatar Aug 07 '24 14:08 webpro

Closing this due to unable to reproduce.

webpro avatar Sep 21 '24 05:09 webpro