Back to Tsx

Import elision

notes/esbuild/import-elision.md

4.23.91.8 KB
Original Source

Import elision

esbuild lowers qualified TypeScript import-equals declarations during parsing (parse/lower), binds imported roots as import identifiers (binding), and removes unused aliases through TypeScript-specific analysis and a fixed-point pass for alias chains (removal, fixed point).

Alias removal does not cascade to an originating external import: ignored JavaScript liveness leaves TypeScript use counts intact (usage accounting), and import trimming consults those counts (trimming).

Version 0.15.4 made qualified alias property accesses removable by general tree shaking (commit, tests); 0.18.17 made aliases rooted at imported bindings removable during TypeScript import analysis, so their removal no longer required tree shaking (commit, issue).