Engrain by ByteRush

JS.10.04 Senior

Circular dependencies and tree shaking

Comes up in: JavaScript, Web fundamentals

This concept is being written. It gets the full five steps — explanation, predict, interview angle, practice with tests, and review cards. Here is exactly what it will cover, so you can study it elsewhere in the meantime.

What it covers

  • cycles with ESM (TDZ errors) vs CJS (partial exports)
  • tree shaking needs static ESM and no side effects (sideEffects field)
  • barrel files cost

Words you will know

circular dependencytree shakingside effectbarrel file

What you will practise

  • diagnose a cycle-induced undefined import

Interview questions this answers

  • How does tree shaking work and what breaks it?