Some notes on using esbuild

This is a fantastic article from Julia Evans about duking it out with modern front-end tooling. Julia has made a bunch of Vue projects and typically uses no build process at all:

 I usually have an index.html file, a script.js


This content originally appeared on CSS-Tricks and was authored by Chris Coyier

This is a fantastic article from Julia Evans about duking it out with modern front-end tooling. Julia has made a bunch of Vue projects and typically uses no build process at all:

 I usually have an index.html file, a script.js file, and then I do a <script src="script.js"> and that’s it.

Which I think is awesome and probably means those projects will last a damn long time. But, I understand a desire to move into some more modern dev tools, if nothing else to unlock the whole npm ecosystem. Basically, Julia wanted to do:

import Vue from 'vue';

That straight up implies npm and a bundler, because that syntax is bundler-specific (it’s invalid ES modules syntax). This used to pretty much imply webpack, rollup, or Parcel, but that’s starting to change and heavily suggest Vite instead.

But Julia didn’t want to reach for tooling that did too much ():

But I stopped using those tools and went back to my old <script src="script.js"> system because I don’t understand what those vue-cli-service and vite are doing and I didn’t feel confident that I could fix them when they break. So I’d rather stick to a setup that I actually understand.

So, with Vite being too much, Julia reached for esbuild. I can’t say I understand the details, but Vite uses esbuild internally for some things:

Vite uses esbuild instead of Rollup for dependency pre-bundling. This results in significant performance improvements in terms of cold server start and re-bundling on dependency invalidations.

So reaching for esbuild directly is a bit of a step down the complexity ladder.

It was so close to being a home run, but of course the dang complex nature of the front-end ecosystem struck again. The assumed copy of Vue that esbuild grabbed from the import Vue from 'vue'; was vue.runtime.esm.js, which is the version of Vue designed to be run in the browser, not the version that includes a compiler. Ughghk. Feels like they should be two separate packages or something. But Julia ultimately battled through that and it was a win:

I don’t understand everything esbuild is doing, but it feels a lot more approachable and transparent than the [webpack]-based tools that I’ve used previously.

All this is one more reason I’m still bullish on Skypack. You can use modern import statements like that and still not need a build process at all.

To Shared LinkPermalink on CSS-Tricks


This content originally appeared on CSS-Tricks and was authored by Chris Coyier


Print Share Comment Cite Upload Translate Updates
APA

Chris Coyier | Sciencx (2021-12-09T20:41:25+00:00) Some notes on using esbuild. Retrieved from https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/

MLA
" » Some notes on using esbuild." Chris Coyier | Sciencx - Thursday December 9, 2021, https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/
HARVARD
Chris Coyier | Sciencx Thursday December 9, 2021 » Some notes on using esbuild., viewed ,<https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/>
VANCOUVER
Chris Coyier | Sciencx - » Some notes on using esbuild. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/
CHICAGO
" » Some notes on using esbuild." Chris Coyier | Sciencx - Accessed . https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/
IEEE
" » Some notes on using esbuild." Chris Coyier | Sciencx [Online]. Available: https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/. [Accessed: ]
rf:citation
» Some notes on using esbuild | Chris Coyier | Sciencx | https://www.scien.cx/2021/12/09/some-notes-on-using-esbuild/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.