Setting up ESBuild
Why do we need to bundle our code, and how can ESBuild help?
Importing and merging files in order of dependencies
Tree-shaking to remove any 'dead' or unused code
Including any assets like CSS, SVGs, fonts, etc
Code-splitting to group related code in a file
What is ESBuild?#
ESBuild is fairly new to the scene compared to many of the other popular bundlers like Webpack or Rollup. Bundlers are notoriously slow due to the sheer amount of work they perform; big projects can take minutes to bundle. ESBuild was created to fix this problem. What takes other bundlers seconds or minutes may take ESBuild milliseconds. This is possible for a few reasons: ESBuild was written using the Go programming language which compiles to native code, it uses parallelism extensively, and memory is more efficiently used. Though ESBuild is still in a pre-1.0 release (not production-ready), I feel confident in the direction it is headed and development is moving fast towards a stable 1.0 release.