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

Detect imports across workspace packages in a monorepo #259

Closed
tasercake opened this issue Sep 22, 2023 · 1 comment
Closed

Detect imports across workspace packages in a monorepo #259

tasercake opened this issue Sep 22, 2023 · 1 comment
Labels
discussion Discussion

Comments

@tasercake
Copy link

tasercake commented Sep 22, 2023

I have a monorepo with 2 packages foo and bar.
bar/index.js imports from foo/lib.js, but knip flags foo/lib.js as unused.

Repro: https://github.com/tasercake/knip-workspace-bug

$ yarn
$ yarn knip
 yarn run v1.22.19
 $ /Users/krishna/Documents/hypotenuse/knip-workspace-bug/node_modules/.bin/knip
 Unused files (1)
 foo/lib.js
 error Command failed with exit code 1.
 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I would expect foo/lib.js to not be flagged as unused because it's imported & used in bar/index.js

Looked around at previous issues but I'm not sure any of them cover my exact problem. #140 (comment) seems to suggest that knip should be aware of imports across packages.

I'm using yarn v1.22.19 (classic) and set up the monorepo according to the classic instructions. To check if that might be the root cause I tried porting the repo over to modern yarn (v3.6.3): https://github.com/tasercake/knip-workspace-bug/tree/yarn-modern, but I get the same output from knip

@tasercake tasercake added the discussion Discussion label Sep 22, 2023
@webpro
Copy link
Collaborator

webpro commented Sep 23, 2023

Sounds like a duplicate of #244, let's track it over there :)

@webpro webpro closed this as completed Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion
Projects
None yet
Development

No branches or pull requests

2 participants