Question: How do I get the dependency chunk graph ahead of time without parsing the final bundle? Best would be as json.
Why:
With webpacks default chunk splitting strategy it creates common chunks that multiple other chunks depend on. E.g. two dynamic imports like
const foo = () => import('./foo');
const bar = () => import('./bar');
webpack may rewrite to (not exactly, but as a concept):
const foo = () => __webpack.r(['foo', 'bar']);
const bar = () => __webpack.r(['bar', 'bar.0']);
So webpack noticed that foo reuses parts of 'bar' and created a 'bar.0', with the modules just for bar and reuses everything in chunk 'bar'.
When I send a html page to the user where I definitely know it'll gonna need 'foo', i'd like to add:
<script src="chunk/foo.js"></script><script src="chunk/bar.js">
And when I send a html page to the user where I know it gonna need 'bar', i'd like to add:
<script src="chunk/bar.js"></script><script src="chunk/bar.0.js">
Just so the scripts are already loaded at html parse time and don't rely on extra roundtrips when javascript is first executed.
But how do I get the dependency chunk graph ahead of time without parsing the final bundle?