-
-
Notifications
You must be signed in to change notification settings - Fork 168
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 module resolution across multiple dependent workspaces with incompatible tsconfigs #611
Conversation
Thanks for the PR! I really appreciate you went deep into the codebase. I think you're on to something and this might fix some nasty bugs I wasn't aware of indeed.
The idea is that Yet this "isolation" isn't/can't be enforced towards TypeScript itself (i.e. starting at
Not sure why this is regarded as "mixed up". The goal of The
|
Sorry, scratch that. After thinking it through a little bit more, maybe this is a more viable approach:
So behavior won't change much for existing users, and your case should be solved by adding the Maybe the default should be swapped in a next major. The thing is, memory consumption can grow huge easily, and not allowing the garbage collector to clean up makes knip crash in some projects. That's not a great default experience either. Unfortunately I miss data to make a better informed decision here. All I got were crash reports I couldn't reproduce but they were fixed in the default mode (I'm afraid this PR would make those projects crash again). |
I haven't tried the isolate flag on my simple repro, but for my real use case it didn't help (without these additional changes) because referenced files from other workspaces were still pulled in by parent workspaces where they were used. Unfortunately my approach does indeed rely on keeping the principals in memory the whole time since a workspace might add a file that needs to be analyzed by a principal that has previously been analyzed. I'm not sure there's any other way to do it, at least not without major refactoring. I agree that it might make sense to take the approach of 2 different behaviors with and without the isolate filag. I'll try that out and see how it goes. Thanks for the quick review and nice conversation! Happy to help out, as this project has been a helpful tool! |
That's great to hear. Thanks for working on this! It was not an intuitive thing to do, and by default leads to surprising/incorrect behavior, but the performance/memory improvements by combining workspaces into single programs when possible was really significant. |
@dbudzins Just curious: is this still something you fancy working on? |
It is, but I'm really stuck. Fixing this breaks other tests, and I'm not
really sure what to do. Have you had any additional thoughts on how to best
solve it?
…On Sun, May 19, 2024, 08:28 Lars Kappert ***@***.***> wrote:
@dbudzins <https://github.com/dbudzins> Just curious: is this still
something you fancy working on?
—
Reply to this email directly, view it on GitHub
<#611 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABYTA66JGPQTHDUMNY6XCELZDBBBNAVCNFSM6AAAAABG7GXZSCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJZGEYTSNZWGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'll look into it and give it a shot today or tomorrow, and report back :) |
Today I asked since I was working on something related and wanted to make sure things are still compatible. Now I've looked into this and I've pushed a branch with all the latest stuff that has things running fine for me. The commit dd97ca0 is something you can cherry-pick on top of your branch to isolate and try out my changes on top of this PR. The main thing is It's still a bit messy, but let's first see if this holds up in your real use case. You probably should add the |
Just in case you were looking at it, I just did a major refactoring and pushed it to the other |
I've merged this to make sure you're the contributor. I'll just commit more on top of it in main. Thanks a lot @dbudzins, it has been super helpful! |
🚀 This pull request is included in v5.17.0-canary.0. See Release 5.17.0-canary.0 for release notes. Using Knip in a commercial project? Please consider sponsoring me. |
Would be great if you could try this out on your project:
|
@webpro I tried out the latest changes from your branch and both the test fixture and my real life use case pass successfully with the |
Awesome, thanks for the feedback and all the energy that went into this! |
The latest canary includes another refactoring, making |
Still draft until I can figure out why some tests are failing on github but not local.
This PR is my attempt to fix #610.
resolutionCache
ofresolveModuleNames.ts
so that a failed attempt to resolve a file in the wrong principal doesn't block resolution in the right principal from succeedinginternalWorkspaceFilePaths
internalWorkspaceFilePaths
after analyzing all of the principals and lookup which principal each belongs to