Split up current TypeScript projects in more granular ones #48965
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an experiment/attempt to speed up TypeScript suggestions and code navigation by splitting up the main TS projects (Kibana and X-Pack) into lots of smaller TypeScript projects (e.g., one for each X-Pack plugin). I've personally seen TS latency improve from 20s to sub-second response times.
Previously I investigated creating an APM specific TypeScript config that extends the X-Pack one, and there's some pretty big speed improvements for APM source files. However, type resolution from npm modules is still slow because the TS server has to jump back and forth between the APM TS project and the X-Pack one, resulting in latency of up to 20s for suggestions and navigation.
This PR removes the files from the Kibana/X-Pack TypeScript projects and creates more granular configurations for sub-projects, like
./src, orx-pack/plugins, orx-pack/legacy/plugins/apm. This means that even if TypeScript has to switch projects, start up time is much faster because the project is smaller.To get a good comparison, I've checked out kibana in a separate directory, and opened that in vs code. In another instance of vs code, I've opened just the APM folder. In both instances,
typescript.tsserver.traceis set tomessagesin order to get back some latency numbers. I then close down all tabs to stop the TS server, and then open one file (in this case,x-pack/legacy/plugins/apm/public/components/shared/ApmHeader/index.tsx) to see how responsive feedback is. What I see is that it takes about 35s vs 8s to start up TypeScript, and when navigating toreact(cmd + click), it takes about 10s vs 300ms.One downside is that type checking the whole of X-Pack is now around 3m30s instead of the ~1m it was before, but type checking the APM plugin for instance takes around 15s, so it is likely still a net win for most of us.
Would like to get some others to try this out and some feedback from operations whether this is a sensible approach. Keeping this in draft because I don't want to ping all the code owners.