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 (
sideEffectsfield) - barrel files cost
Words you will know
What you will practise
- diagnose a cycle-induced undefined import
Interview questions this answers
- How does tree shaking work and what breaks it?