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

TS server significantly slower to initialize when includePackageJsonAutoImports is auto #60854

Closed
OliverJAsh opened this issue Dec 25, 2024 · 4 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@OliverJAsh
Copy link
Contributor

OliverJAsh commented Dec 25, 2024

🔎 Search Terms

  • monorepo
  • project references
  • package exports
  • subpath exports
  • includePackageJsonAutoImports
  • paths

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about auto imports.

⏯ Playground Link

No response

💻 Code

My large work project became significantly slower to initialize in VS Code after we migrated from paths in tsconfig.json to exports in package.json (6s before, 12s after).

I dug into the TS server log and noticed AutoImportProvider was now including many more files than before (2474 before, 8442 after).

This led me to typescript.preferences.includePackageJsonAutoImports, which I understand defaults to auto. When I set it to off, initialization time decreases from 12s back down to 6s. Note this doesn't seem to affect the functionality of auto imports.

I can't imagine this would be expected behaviour: 6s of extra initialization with no noticeable gain in functionality.

Unfortunately I can't share a reduced test case for this, but I would be happy to do further debugging if someone could give me guidance.

For context, this project is a monorepo with multiple packages depending on each other. We are also utilizing project references (each package has its own project). The package exports includes many entries.

🙁 Actual behavior

N/A

🙂 Expected behavior

N/A

Additional information about the issue

No response

@RyanCavanaugh
Copy link
Member

was now including many more files than before (2474 before, 8442 after).

This led me to typescript.preferences.includePackageJsonAutoImports, which I understand defaults to auto. When I set it to off, initialization time decreases from 12s back down to 6s. Note this doesn't seem to affect the functionality of auto imports.

I'm not really sure what the implied defect is here. It's looking at 5,968 more files, so a) exports from those files are now available for auto-import, even if you're not interested in them and b) this takes nonzero time.

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Jan 2, 2025
@OliverJAsh
Copy link
Contributor Author

OliverJAsh commented Jan 2, 2025

It appears these exports are still available even when this feature is disabled (presumably via project references), so in our case, the out-of-the-box behavior just unnecessarily slows things down.

I suppose I'm questioning the heuristics for auto and/or whether includePackageJsonAutoImports could be improved to avoid duplicating work if the files are already included e.g. via project references (assuming this is part of the issue).

@RyanCavanaugh
Copy link
Member

That's interesting. We can take a look if there's a repro that demonstrates the difference.

@OliverJAsh
Copy link
Contributor Author

I just tried to create a reduced test case but no luck so far. I'll give this some more thought but meanwhile let's close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

2 participants