Closed michaelschufi closed 3 months ago
Set "Include Package JSON Auto Imports" to "On" instead of "auto"
Thank you so much! This seems to fix it π Now, since it's not the default, I have to ask: What are the implications regarding performance if I enable that?
Maybe there could be some kind of whitelist, so we can include the internal packages in the VS Code settings?
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Set "Include Package JSON Auto Imports" to "On" instead of "auto"
You save my life... thanks... π
OMG, that's a game changer!
This issue has been marked as "Question" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
I'd be curious to know that too
π Search Terms
"intellisense not working", "auto import", "autoimport", "internal package", "monorepo internal"
π Version & Regression Information
Versions checked
I've used VS Code Insiders so I don't have any excess extensions (just WSL).
β― Playground Link
No response
π» Code
Reproduction Repo
See: https://github.com/michaelschufi/repro-monorepo-tsserver-import
Internal Package
package.json
get-foo.ts
pnpx tsc --showConfig
App using internal package
package.json
page.tsx
pnpx tsc --showConfig
π Actual behavior
Import suggestions for an internal package stop working if the number of installed dependencies grows too large. This already happens with as little as ~12 dependencies.
Reproduction
The reprodution repo is basically just Turborepo's basic example with a few dependencies added to showcase the autoimport failing.
from (Turborepo Getting Started). It uses the strategy for internal packages outlined here Turborepo Internal Packages - which is already preconfigured in the example.
Initial Steps
apps/web
folder.pnpm i
apps/web/app/page.tsx
and try to import-suggest thegetFoo
function.Observing the strange behavior
next
,react
orreact-dom
)pnpm i
to remove them fromnode_modules
.You can remove any other dependencies (as shown in the video). It doesn't matter which ones. I tried the following
Removing any ?random? group of packages, makes the import work.
https://github.com/microsoft/TypeScript/assets/2805598/4bbab7d3-281b-4239-b4b2-9358bdcfde4b
Note The imports start showing up, if at least one file in the project has imported the file already. E.g.
page.tsx
importsthen, all imports from
"@repo/ui/get-foo"
are available when triggering the suggestion. Even if we are in e.g.layout.tsx
.But the imports from other paths of the internal package e.g.
"@repo/ui/get-foobar"
are not.π Expected behavior
I expect the imports to be working regardless of how many dependencies I have installed.
Additional information about the issue
Possibly related issues:
39778 - this one seems to be close
48880 - especially this comment https://github.com/microsoft/TypeScript/issues/48880#issuecomment-1863484041
36708
Below are the tsserver logs. Note the following lines in the first one
https://gist.github.com/michaelschufi/638a0a9bc5bc8568c86b50a8c0c0e723