Better Programming

Advice for programmers.

Follow publication

Member-only story

3 Libraries I Use in Most JavaScript Frontend Projects

Oyster Lee
Better Programming
Published in
5 min readSep 17, 2021

Photo by Chris Liverani on Unsplash

I use a 2019 Macbook Pro, and despite the machine being a developer’s beast, I’m tired of staring at the spinning wheel during work hours.

When the hot-reload gets slow, the mac lags and requires me to do housekeeping frequently. Eventually, I played across a few libraries which became my savior — and I now use them in most of my frontend JavaScript projects.

1. ViteJS

I took over a legacy React project last month, and it has a lot of duplicated and redundant code.

The project was using Parcel 1 as a bundler and it took a long while to start and hot-reload. Even worse, the cache consumed my~500MB disk space! I didn’t notice it until I was running out of space. It has over 500 lines in routes.tsx every time I need to find the respective file I need to do Find in routes.tsx. Troublesome! Later I will show you how I automatically generate routes, from over 500 lines to 50 lines!

I decided to use Vite instead because it makes me feel like I am the fastest developer alive!

So the question here is:

Why ViteJS?

Imagine you are coding for a large-scale project, it could take up to minutes to spin up for the dev server, and for Hot Module Reload (HMR), sometimes it takes a couple of seconds to be reflected in the browser! Both of these issues are affecting developers’ mood and productivity.

Some dependencies are too large to process. Vite is using esbuild to pre-bundles the dependencies. Esbuild is written in Go and compiles to native code, so it compiles 10x — 100x faster than JS-based bundlers.

When you are editing non-plain JavaScript files, it won’t load all the source code simultaneously. This is one of the best parts of ESM, code-splitting!

Benchmark by Evan Wallace

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Oyster Lee
Oyster Lee

Written by Oyster Lee

Go and JavaScript Developer. Father of two. I write articles mostly about programming and productivity. https://linktr.ee/OysterD3

Responses (7)

Write a response

Thanks for sharing Oyster!

--

PNPM will install the dependencies into a global store, and the files are hard-linked from the project. This means if you have 10 projects using foo which having 1MB, it only consumes y...

Does it handle different versions from the same library as well?

--

Thank you!

--