faceyspacey / webpack-flush-chunks

💩 server-to-client chunk discovery + transportation for Universal Rendering
MIT License
355 stars 33 forks source link

feat(src/flushChunks.js): Support Webpack 4 Aggressive Chunking #59

Closed ScriptedAlchemy closed 6 years ago

ScriptedAlchemy commented 6 years ago

Supports complex code splitting done by webpack, allows for better code sharing between universal components.

55

ScriptedAlchemy commented 6 years ago

Now installable via @next npm i webpack-flush-chunks@next

faceyspacey commented 6 years ago

round of applause @zackljackson well done!!

ScriptedAlchemy commented 6 years ago

Props to @vxna for pointing out a big which caused flushing failures when chunks had a non-existent name.

Because we are supporting aggressive code splits. We have scenarios where chunks only have chunk IDs and no chunk names. Due to the intricacies and importance of the chunk ordering, we first have to resolve the chunks via a mixed reference point. String or Integer. If its a string, we resolve it as usual, however, if its an integer, then we need to resolve the filename directly rather than using the filename to resolve the chunk name.

What this means is I have to first treat everything as a chunk name, then pass it into a function which resolves files by ID, check for if its a number - if so, execute another resolution step to locate the filename.