For bundling JS web apps or libraries of more than moderate complexity, they all have serious issues:
- Webpack is just too complex; when you have issues with the build, you don't know where to even begin looking to fix things. In particular, tree-shaking seems to hard to get working in any reliable way. All the same, this is what we are still using in our project, but stuck at version 3.12 (the last version before 4)
- Rollup is sweet when it works. But, it demands ES modules. More seriously, recently I'm unable to get the Typescript plugins to work properly (or sometimes at all). It seems weird to me that such a basic bundling scenario is broken.
- Parcel can't handle advanced bundling requirements
- ESBuild was tried recently; despite it's promise and hype; it breaks down even for some relatively simple bundling setups; very disappointing
- SWC seems to not be progressing that well. Their docs are still sparse, and you don't hear of them much. So I'm not willing to invest time diving into it.
What bundler(s) are you using, and what's your experience with them?
I completely gave up on bundling and all forms of optimization beyond that. Turns out it doesn't matter as long as the total amount of source for your site is less than what twitter or Facebook use (it will be).
I recently had to take a dep on three.js and a few others items for a side project, and instead of reaching for one of the various toolchains, I grabbed the raw JS/module source and wrote my own import map by hand:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sc...
Note that you will need an ES module shim for iOS/Safari if you go this path: https://github.com/guybedford/es-module-shims
This bundler plugin simplify the Webpack config.
The html-bundler-webpack-plugin allows to use a HTML template as an entry point. In a HTML template can be referenced any source files of styles, scripts, images, fonts, etc. The plugin detects all source files referenced in a HTML template and extracts processed assets to the output directory.
View in a browser how it works: https://stackblitz.com/edit/stackblitz-starters-78r926?file=...