preload-webpack-plugin icon indicating copy to clipboard operation
preload-webpack-plugin copied to clipboard

Add links based on webpackPreload/webpackPrefetch magic comments

Open gcoombe opened this issue 5 years ago • 1 comments

As of 4.6.0 webpack will generate links based on webpackPreload/webpackPrefetch magic comments. However where we are attempting to preload/prefetch chunks from an entrypoint loading will not start until the parent as finished (See https://github.com/webpack/webpack/issues/8342#issuecomment-438649676)

It would be great if chunks preloaded from an entrypoint were added as link tags by this plugin. I was thinking of adding an additional includeOption like initialAndChildren.

We would need to use data exposed in stats.entrypoints[].childAssets. The use of the stats api can slow down builds but only calling getStats if the consumer opts in through includeOption: initialAndChildren seems reasonable to me.

Happy to put up a PR if this is acceptable.

gcoombe avatar Jan 20 '20 18:01 gcoombe

Put together a quick PR https://github.com/GoogleChromeLabs/preload-webpack-plugin/pull/109, would be great to get some initial thoughts!

gcoombe avatar Jan 21 '20 06:01 gcoombe