Lesson 16 of 30
Knowing bundling and tree shaking exist doesn't tell you which dependency is actually eating your bundle, or how big is too big — analysis and budgets are the missing diagnostic layer.
12 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A treemap view of a production bundle shows two separate rectangles both labeled with the same library name, at slightly different versions. What does this most likely indicate?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
You already know what bundling and tree shaking do. What that knowledge doesn't give you is a way to answer two very practical questions: what's actually taking up space in this bundle right now, and how big is too big. Those are analysis and budgeting problems, not bundling mechanics problems.
Bundle analysis means visualizing a real, built bundle to see which modules contribute which bytes — usually as a treemap, where each rectangle's area is proportional to that module's size. A size budget is a concrete number (per route, per chunk, or for the whole initial load) that a bundle isn't allowed to exceed, checked against something real instead of vibes.
Two numbers matter here, and they're not the same:
Budgets should be set against the compressed number, because that's the one tied to real download time.
lodash@4.17.21 (bundled once, ~24kb gzipped)
lodash@3.10.1 <- pulled in transitively by an old chart library
(a second, near-identical copy, another ~22kb gzipped)
A treemap view of a real bundle (from a tool like webpack-bundle-analyzer, source-map-explorer, or Vite's rollup-plugin-visualizer) would show this as two separate, similarly-sized rectangles both labeled lodash, not one. That's the tell: the same library is bundled twice because two different dependencies in the tree each pinned an incompatible version range, and the package manager couldn't safely dedupe them into one shared copy. Nobody wrote import lodash from "lodash" twice on purpose — it happened silently, several npm installs deep in someone else's dependency, and it shipped an extra ~22kb gzipped that does nothing.
This is exactly the class of problem a bundle analyzer is good at catching and a code review is not: no line of your own source code looks wrong, because the duplication lives entirely in the dependency graph.
"The bundle grew after a recent PR — how would you find out why?" is a real, practical question, and naming a bundle analyzer plus the duplicate-dependency-version failure mode is a much stronger answer than a vague "I'd check the imports."