webpro-nl / knip

✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
6.49k stars 150 forks source link

Monorepo package dev dependency binary used in GitHub actions workflow reported as unlisted #735

Open with-heart opened 1 month ago

with-heart commented 1 month ago

Reproduction url

https://stackblitz.com/edit/github-e9sos1?file=packages%2Fclient%2Fpackage.json

Description of the issue

When the binary of a dev dependency of a package in a monorepo is used in a GitHub actions workflow (using yarn --cwd), the binary is reported as unlisted.

packages/client/package.json:

  "scripts": {
    "svelte-check": "svelte-check --workspace test"
  },
  "devDependencies": {
    "svelte-check": "^3.2.0"
  },

.github/workflows/node.yml:

      - name: Svelte Check
        run: yarn --cwd packages/client svelte-check
        shell: bash

Output:

❯ yarn knip
yarn run v1.22.19
$ knip
Unlisted binaries (1)
svelte-check  .github/workflows/node.yml
error Command failed with exit code 1.

For reference, I ran into this issue as part of https://github.com/statelyai/xstate/pull/4974. Planned workaround is to add .github/workflows/node.yml to ignore for now.

I would expect no error to be reported.

webpro commented 1 month ago

Indeed, the issue is that Knip does not understand to assign dependencies to the workspaces in packages/client when using the --cwd packages/client argument.

Similar issue to #433. Unfortunately I'll answer this the same.

with-heart commented 1 month ago

Not unfortunate, that's totally understandable! Do you think it'd be worth adding a note in the docs about this somewhere? I'd be happy to tackle that if so