Tree Shaking - CI/CD用語集の定義
tree shaking は未使用の export を bundle から取り除き、出荷されるコードを無駄なく保ちます。
tree shaking は、どこからも import されない export を除去し、最終的な bundle を縮小する dead code elimination の手法です。何を安全に破棄できるかを知るために、ES modules の静的構造に依存します。
ES module の import と export は静的に解析可能なため、bundler はある export が決して使われないことを証明して省略できます。tree shaking は side effect のない ESM コードでのみうまく機能します。パッケージに sideEffects: false を付けると役立ちます。CI では、tree shaking 後に bundle サイズが budget 内に収まっていることを検証できます。
関連ガイド
Dead Code Elimination - CI/CD Glossary DefinitionDead Code Elimination: Dead code elimination is a compiler optimization that removes code that can never exec…
Bundle Size - CI/CD Glossary DefinitionBundle Size: Bundle size is the total byte count of the files a bundler emits, often measured both raw and gz…
Bundle Analysis - CI/CD Glossary DefinitionBundle Analysis: Bundle analysis is inspecting a build output to see which modules contribute to size, usuall…