If you're going to have a build step at all, instead of hand rolling your build commands and configs, just use Vite[1] already. It uses esbuild for development and rollup for production (since esbuild is not featureful enough for a lot of production use cases), you get instantaneous startup, hot module replacement, static asset imports, etc. for free. It's from Evan You, the creator of Vue, but it also supports React…
For greenfield projects? Certainly. For existing projects? Oh, you're in for a world of pain.
I'm all for breaking with the old and ushering the new era in, but there should be an upgrade path for as many possible combinations of the old as possible.
As luck would have it I decided to convert our project to vite to see if it's feasible.
So far it's:
- Absolute imports don't work and are broken in any number of subtle ways
We use typescript with a setup that resolves `/our-stuff` to `./src`.
Also this is served from `http://our-server/our-stuff` because we're a part of a larger app.
Good luck making this work with vite. Somehow it insists that you should replace all absolute imports with `/@/` and setup an alias for that. All other options (like using vite-tsconfig-paths) will not work because vite's `base` config will break this.
I "solved" it by listing all directories in `src` and converting them into vite aliases.
- Now I'm stuck with `[vite] Internal server error: failed to resolve "extends":"../../tsconfig.json" in /mui-theme/tsconfig.json`
How to fix it? Hell if I know.
At this point I'm just giving up, and looking into how to maybe upgrade to webpack 5.