-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Fix support for baseUrl
in typescript projects
#244
Comments
This is the main issue here. Assuming you're in a monorepo, you should not be referencing files in other workspaces directly? But importing them properly using package identifiers and import maps. If you don't want to do that you can still opt into things like But maybe I'm missing something? Just guessing based in the input provided. |
Actually we are importing resources using (classic ?) From what I can see the My use case would be essentially the following: Let's say I have the below structure:
If, in the The idea with this feature would be to allow such "private" workspace to enlist for being referenced to by other packages from the same workspace. (To be honest I'm experimenting a lot and trying to tweak configurations so I may have missed something) |
Any chance you could whip up a minimal rep(r)o for this? That would help a lot, then we can take it from there and look at our options. |
Sure ! Just did it here: https://github.com/antoine-malliarakis/knip-utility-package-reproduction-path Thanks P.S.: I already started looking into it if I can help don't hesitate |
Why would you use the empty array for In case you want to have the util packages not use the default entry file then you can either set that empty array for only that workspace, or use a different file name (i.e. not |
Actually I only declared it to simplify declaration. It seems that the webapp-a manifest entry paths were actually used, unless I missed something ?
Will be altering the workspace configuration so that it's more explicit. |
@webpro updated the workspace configurations to be compliant with expectations. |
I understand the confusion: Knip reads the For future reference, running with the
|
We use the same monorepo premise: importing files across workspaces in a monorepo, without In my test: homburg/hello-knip#6 knip seems to understand this correctly:
I hope this will be supported in knip in the future as well |
By checking your
Would need to check what happened in your recent changes. |
I can't seem to reproduce your result ( What commands are you using to run knip? I'm wondering if you are running a particular version My normal setup for running knip in the repo is:
|
Actually I wasn't using bun. I was using npm. Let me retry with that one. |
@homburg so here we're in an awkward situation. Using bun it works. Unfortunately I'm not sure that using bun is a viable plan in our build chain (could be checking but I doubt that "just so that knip passes" would be a sufficient motive). Does the same issue occur for you if you try using npm ? |
@antoine-malliarakis That's interesting :-) I'll try looking into how it works with I was using yarn (berry) before, which seemed to work as well |
To be fair we are using yarn 1. I was trying to use npm because it seemed to me that would be the closest to "bare metal" but then it seems that evidence is proving me wrong. Could that be related to the usage of "workspace:*" ? (We are not using such tricks on our side since we're using yarn 1) |
An I was naively thinking that the package manager wouldn't affect the result :-) bun was just faster in github actions |
I looked at the repro and the issue is a bug in Knip (or rather a missing feature). The root cause is setting the Removing the I have some ideas to fix it, will update progress here. |
baseUrl
in typescript projects
Updated description of this ticket following recent findings. |
🚀 This issue has been resolved in v2.26.0. See Release 2.26.0 for release notes. |
Full disclosure. What was not supported yet: having non-entry files being imported from another workspace in the same monorepo AND at least one of the workspaces configured a |
Thanks ! |
Issue description
In the context of our projects heavily rely on the usage of the
baseUrl
parameter in our typescript configurations.The issues is that intra workspace package dependencies (e.g. imports from other workspace packages) are not appropriately spotted, leading to project resources invalidly flagged as unused.
The text was updated successfully, but these errors were encountered: