-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Description
With TypeScript 2.4 we can now use dynamic imports to improve startup performance. The idea is to lazy load certain modules that aren't (always) needed for starting up. Generally, lazy loading requires some amd-bundle-gymnastics but with node-modules everything is easy. The motivation is that 20% of code loading (from cached data) is spend loading node-modules.
To see how long it takes to load a certain module do the following:
- start code with the
--performanceflag - in code hit F1 and show startup performance
- below the table with startup times are different sections outlining times to load and execute all modules we have. Look at everything taking 10ms or longer
In short, the idea here to explore using dynamic imports for lazying. Already today this can be done with late require-calls but you lose typing inference with that. Dynamic imports give you both, late and lazy loading and type safety/inference.
Sample times when not having cached data (very first startup, ~200 of 1500ms)
Sample times when having cached data (also node modules are cached, ~100 of 500ms)

