DEV Community

Cover image for 🚗 Sidecar for a Code splitting

🚗 Sidecar for a Code splitting

Anton Korzunov on May 06, 2019

Code splitting. Code splitting is everywhere. However, why? Just because there is too much of javascript nowadays, and not all are in use at the sa...
Collapse
 
jovidecroock profile image
Jovi De Croock

In your last example why do you load library/sidecar lazily but in your library use it as a static import?
Not really fully on that boat yet, great article by the way. Love reading your articles since every concept has a well-defined example attached to it.

Collapse
 
thekashey profile image
Anton Korzunov • Edited

It was more about:

  1. You was exporting a Thing from your library
  2. You separated a thing to Main and Sidecar
  3. You are exporting Main, just the one part, and the old Thing assembled back from new pieces. Library public API is not changed. This is no more than a minor bump.
  4. You are exporting a Sidecar via another endpoint
  5. ....
  6. You are assembling a Thing in a user space from Main and lazy Sidecar.

Technically you may keep import in a library code, but you will loose control on chunk name and prefetching.

As I said - this is a subject to complete and argue about.

Collapse
 
pierre profile image
Pierre-Henry Soria ✨

Amazing read! 👏 Thanks Anton! 💯