Polyfill Node.js built-in modules with Vite

Fabiano Taioli
2 min readJan 11, 2022
Photo by Clark Gu on Unsplash

Vite is a new tool that helps to jumpstart and streamline frontend Javascript development. The main advantage of Vite against other solutions like Parcel is a better speed and limiting transpilation only to a one time operation to dependencies, keeping your source untouched (if you don’t need to, because of JSX or typescript).

It consists of two major parts:

It’s very similar to Snowpack and the two projects share the same benefits.

While Snowpack uses Rollup for the developing phase and production bundling, Vite uses Esbuild during development and Rollup only to build for production. This with the final objective to totally replace Rollup with the more performant Esbuild when the latest will reach the same features level of Rollup.

A problem I have found using Vite in my project is how to poly-fill Node.js built-in modules for the browser.

Using Node.js built-in and globals (es util or process) in a browser project is discouraged but sometimes you…

--

--

Fabiano Taioli

Graduated in Computer Science at Univerity of Bologna. Lead software developer at Vista Tecnologie. Functional Programming enthusiast. On Linux since 2004.