-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Adopt dynamic-imports for node module #30685
Comments
cc @Tyriar for evaluating what it means to load |
Great. For having types without loading you can use some on-thin-ice-trick which is keeping the |
Actually in the process of doing that exact thing microsoft/TypeScript#15902, getting a weird error though:
Soon the types will be handles entirely by the module, it would be a shame to have to keep them in Microsoft/vscode as well when that happens. |
Opened microsoft/TypeScript#17200 |
Closing this as most work is done except for |
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:
--performance
flagIn 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)
The text was updated successfully, but these errors were encountered: