Tom MacWright

tom@macwright.com

Migrating a Remix site to Vite

The good

  • We manage a WebWorker, which previously required that we create a separate entry point and build it with esbuild and handle the “fingerprinting” of the file (to manage its CDN caching) ourselves. Vite just bundles it based on the import, like it would with code-splitting. Much more robust, much simpler.
  • Vite has a sentryVitePlugin that works much better than Sentry’s Remix integration and is reassuringly general-purpose.
  • We already build around a lot of patterns in epic-stack, so following Kent’s lead with his Vite PR made everything a lot easier.
  • Vite’s HMR is magical and fast and I am mostly on board with its approach of barely bundling packages in development.

The bad

  • We hit an issue that has been reported in Vite, Jotai, and TanStack Query repos around source map handling that required a manual workaround.
  • After fixing that, our build with sourcemap: true now runs out of memory on Render, consistently. The servers that build Val Town from source are plenty powerful and this is pretty surprising.

In summary: I love the idea of Vite, but the fairly extensive pull request I wrote for the switch is going on the backburner. I’ll revisit when Remix makes Vite the default compiler, at which point hopefully Vite is also a little lighter on its memory usage and they’ve fixed the bug around source map error locations.