It says:
A request for a normal module, which is resolved and built even before a require to it occurs. This can boost performance.
I don’t see how it can boost performance.
Why is a nested require()
much slower than the same root level require()
?
The plugin is for prefetching assets over the wire before the require is executed. For example prefetching code to render a different view in a single-page app. So while a user is looking at the current page the code for another page that is not in the original page payload is downloaded before the user attempts to navigate to that page.
@aackerman oh, that makes sense. But how does it boost Webpack build performance? (as per Analyse Tool hints)
@sokra heh I think we need more than a few lines to explain how this one works on our docs.
long chains of requires can form a chain where webpack will know about the last module very late. This could slow down the compilation because webpack has to wait for I/O (esp. resolving). The PrefetchPlugin starts modules earlier so I/O is less an concern.