TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Esbuild – An extremely fast JavaScript bundler

679 pointsby taitemsover 3 years ago

55 comments

magaover 3 years ago
Often overlooked things when discussing esbuild here:<p>1. It&#x27;s not just a faster replacement for a single %tool_name% in your build chain: for the vast majority of cases, it&#x27;s the whole &quot;chain&quot; in a single cli command if you&#x27;re doing it right.<p>That is, you don&#x27;t just stick it inside, say, webpack as a faster replacement for babel (although you can). No, you look carefully through your webpack configs and its myriad of plugins, ask yourself whether you really need to inline css in jsx in png while simultaneously optimizing it for IE 4.0, realize you don&#x27;t, through out the whole thing, and use esbuild instead.<p>I have two 50K+ LOC projects using esbuild, and I would use it even if it was slower than webpack&#x2F;babel&#x2F;tsc simply not to worry about the build chain breaking due to an update to some obscure dependency or plugin.<p>2. It is fast because it&#x27;s written from scratch to do a set of particular things and do it fast, not just because it&#x27;s Go and parallelized.<p>If you look at the commit log you will notice a lot of performance tweaks. If you look into the issues, you will find a lot of requests for additional features rejected, often due to possible negative performance impact.<p>3. The most impressive part about esbuild development is not just that it&#x27;s one guy writing it: it is the level of support and documentation he manages to provide alongside.<p>The release notes alone are a good course into nitty-gritty details of the web ecosystem: all the addressed edge cases are explained in detail. To top it all off--all opened issues, no matter how uninformed they seem, find a courteous response.
评论 #28865639 未加载
评论 #28863856 未加载
评论 #28862486 未加载
评论 #28864204 未加载
评论 #28864624 未加载
评论 #28862635 未加载
评论 #28862913 未加载
评论 #28863899 未加载
评论 #28867408 未加载
评论 #28868928 未加载
CodeIsTheEndover 3 years ago
Work on esbuild started at the start of 2020. It is primarily authored and maintained by Evan Wallace, who, in addition to making this tremendous contribution to the JavaScript ecosystem, <i>is the CTO and co-founder of Figma</i>. Incredible output.
评论 #28862005 未加载
评论 #28861425 未加载
评论 #28862194 未加载
评论 #28862712 未加载
评论 #28862794 未加载
ksecover 3 years ago
Bun [1] is a JS bundler based on esbuild’s source, but written in Zig. And it is about 3x faster than esbuild. I think its author Jarred is on HN as well.<p>Probably worth a submission on its own but I am just waiting till it is fully open source.<p>Edit: ( Deleted those Stats, since it may not be a fair comparison and it was probably not meant to be a fair benchmark in the first place. The details are still in the linked tweets. I do not know the author or am I in anyway affiliate with Bun. )<p>I am also wondering how much of those optimisation could be used on ESbuild. Since Rails 7 <i>and</i> Phoenix 1.6 will be using esbuild and not Webpack.<p>[1] <a href="https:&#x2F;&#x2F;twitter.com&#x2F;jarredsumner&#x2F;status&#x2F;1390084458724741121" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;jarredsumner&#x2F;status&#x2F;1390084458724741121</a>
评论 #28863166 未加载
评论 #28863185 未加载
imjaredover 3 years ago
I&#x27;ve been trying to figure out how to build JS projects with the evolving tools (grunt =&gt; gulp =&gt; webpack =&gt; parcel =&gt; back to webpack) for years. I stumbled on esbuild and thought why not. Within about 15 minutes, I had solved pretty much all our build issues. Admittedly, our use case was simple-- we needed to transpile React-flavored TS to a npm package. In about 6 lines of code, I had a working bundle. There were no .esbuildrc or esbuild.config.js files, no babel dependencies, and no order of build operations to consider. The tool just worked and it was screaming fast. My first impression was that it _didn&#x27;t_ work because the process closed in my terminal so quickly.<p>After my first experiment with it, I rewrote our hundreds of lines Cloud Functions deploy script in about 15 lines (most of which is configuration options on the `build()` method).<p>I&#x27;m curious to explore the tool more. Kudos and thanks to the author for an unbelievably useful contribution.
评论 #28870261 未加载
louissm_itover 3 years ago
ESbuild is getting fantastic traction. It’s the default in Phoenix from 1.6 and comes as a default option in the current alpha of Rails 7, which you can get with a simple<p>rails new your_app -j esbuild<p>The only sort of issue I’ve had with it so far is you can’t use it with Inertiajs[1] as it does not support dynamic imports out of the box. Although I’m hesitant to call it an issue if its not in the scope of the project. Perhaps there are plugins I can use.<p>[1] - <a href="https:&#x2F;&#x2F;inertiajs.com" rel="nofollow">https:&#x2F;&#x2F;inertiajs.com</a>
评论 #28861094 未加载
评论 #28862846 未加载
评论 #28864669 未加载
qwertoxover 3 years ago
Why is it so fast? Mainly because:<p>- It&#x27;s written in Go and compiles to native code. [...] While esbuild is busy parsing your JavaScript, node is busy parsing your bundler&#x27;s JavaScript. By the time node has finished parsing your bundler&#x27;s code, esbuild might have already exited and your bundler hasn&#x27;t even started bundling yet. [...] Go is designed from the core for parallelism while JavaScript is not.<p>- Parallelism is used heavily.<p><a href="https:&#x2F;&#x2F;esbuild.github.io&#x2F;faq&#x2F;#why-is-esbuild-fast" rel="nofollow">https:&#x2F;&#x2F;esbuild.github.io&#x2F;faq&#x2F;#why-is-esbuild-fast</a>
评论 #28873709 未加载
dom111over 3 years ago
We recently switched on a few of our project from Webpack and the difference is incredible. Running a watch using this is practically instantaneous compared to our previous setup. I&#x27;ve been recommending it to all my colleagues and we&#x27;re replacing Webpack slowly but surely.<p>The main draw for me is the simplicity of the config too. Webpack config (even using things like Symfony&#x27;s Encore) is pretty convoluted and confusing to track. This, at least in my experience, has greater readability and is simpler to understand.
评论 #28861867 未加载
评论 #28862109 未加载
kureikainover 3 years ago
esbuild is fast but it has a lot of place you have to figure out yourself and get into your way of doing thing.<p>1. dev server: you have to write a bit of code for this server to act as webpack dev server 2. scss: need to install plugin, and plugin cannot use from command line then you need to write a bit of JavaScript 3. global function: if you do `process.env` now you need to inject into build script 4. node package: if the package use node stuff you have to define thing like `fs&#x2F;stream` into package.json<p>very quickly it get into your way of doing thing.<p>However, once you get past that base line, the cost is constant, the complexity just stop right there and not adding up.<p>Plus, the speed is amazing.
评论 #28861938 未加载
评论 #28864649 未加载
评论 #28867265 未加载
评论 #28861063 未加载
satvikpendemover 3 years ago
See also SWC, something similar to esbuild but written in Rust. NextJS uses SWC as well as Deno.<p>Rome is also being rewritten in Rust, it&#x27;s more of a complete set of packages that subsume Webpack, Babel and all the other parts of the JS &#x2F; TS development experience.
评论 #28861597 未加载
philluover 3 years ago
I&#x27;m using this to compile typescript lambda functions for AWS with great success. Combined with cdk and its NodeJsFunction you can even deploy&#x2F;compile without local docker.
评论 #28861433 未加载
petethepigover 3 years ago
Great job on the landing page — that simple animation tells an incredibly simple and compelling story all in 800x200 pixels.<p>I wish more products had landing pages that looked like that.
评论 #28862110 未加载
swhitfover 3 years ago
You know you are getting old when you watch the arrival of the fourth JavaScript build tool of your career. I still remember when everyone was waving goodbye to Gulp in favour of Webpack. Webpack was going to save us all from the hell of massive convoluted gulp.js files. Fast forward five years and it&#x27;s the same mess it was supposed to avoid. Slow, bloated and confusing.<p>I just switched to esbuild on our main project and the build time went from 7 minutes on CI to 1 second. Kinda stupid really. Anyway, here&#x27;s to the future, let&#x27;s hope it works out this time!
评论 #28862691 未加载
评论 #28863396 未加载
评论 #28862757 未加载
评论 #28862742 未加载
评论 #28862643 未加载
评论 #28883560 未加载
评论 #28862916 未加载
Aeolunover 3 years ago
What I need is a similar speedup for my Typescript and eslint checks. Bundling isn’t my main issue.
评论 #28861312 未加载
评论 #28863339 未加载
Zarkaosover 3 years ago
For our quite big JS codebase on React + typescript, we switched from Webpack to esbuild earlier this year. It actually changed our daily lives !<p>The watch rebuild time went from 3-5s (actually a lot when you save your code very often) to something like .5-1 s<p>The full build time went from 120s to less than 5s
moron4hireover 3 years ago
Full build with Rollup on all of my bundles for my project took around 10 minutes. IDK what my KLoC count is, but it&#x27;s probably in the 25 to 50K range, with very few dependencies. I had a lot of complexity in my build scripts to try to subdivide related bundles into individual build commands to get the day-to-day rebuilds down to the 1 to 2 minute range. I had to run TypeScript in watch mode separately to emit individual JS files from my TS code for each module, and then only let Rollup bundle the JS code (the available TS plugins were just too slow), so I had tons of garbage files all over everywhere and occasionally they would get out of synch. It was a mess and it was extremely difficult to explain everything to newcomers.<p>With ESBuild, everything, all the things, build in 0.25 seconds. Build script has massively reduced complexity, as there&#x27;s no point in running any command other than &quot;build all&quot;. There&#x27;s just the TS code and the output. I&#x27;m still running TypeScript in watch mode separately to get compilation errors on the fly (ESBuild doesn&#x27;t run the TS compiler itself, it has a custom-built translator that optimistically throws away type information), but I no longer configure it to emit translated code. And did I mention the build script is <i>massively</i> simpler?
junonover 3 years ago
Esbuild actually made writing frontend bearable for the first time in years. It alone reduced our iterative build times from 45 seconds to something like .5 seconds.
sorenjanover 3 years ago
Are there any tools that transform HTML and other files? For example, lets say I have an &lt;img&gt; tag with a src attribute that points to a local image. Can I automatically replace that with a &lt;picture&gt; tag with various formats (jpg, webp, avif) and sizes?
评论 #28862527 未加载
评论 #28861234 未加载
评论 #28861097 未加载
评论 #28861884 未加载
评论 #28861066 未加载
Tade0over 3 years ago
Such a shame that Angular doesn&#x27;t benefit from using such tools:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;evanw&#x2F;esbuild&#x2F;issues&#x2F;42#issuecomment-933959929" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;evanw&#x2F;esbuild&#x2F;issues&#x2F;42#issuecomment-9339...</a><p>So I&#x27;m currently stuck with a build that takes minutes, even though in principle it should require only seconds.
dugmartinover 3 years ago
I switched to it on all of my personal (TypeScript) projects after upgrading to Phoenix 1.6 (where it is required). I normally have a separate lint step during production builds so its lack of type checking isn&#x27;t an issue during development as VSCode catches and highlights type errors anyway.<p>It is crazy fast. It feels like the Turbo Pascal 3 of web development.
fabian2kover 3 years ago
I had ignored this space for a while as I didn&#x27;t see any need to fiddle with it. But there does seem to be quite a lot of movement now on Webpack alternatives. The speed improvements do look very interesting, though I&#x27;m not so sure how much of the delays I&#x27;m seeing with Webpack&#x2F;Create React App are from the Typescript checking. I mean Typescript is awesome, but it&#x27;s also not all that fast in building and type checking.<p>Vite seems to be one of the more interesting CRA alternatives. Though it uses esbuild only for development, and Rollup for production builds. It&#x27;ll be interesting to see how this develops, and if the fast bundlers keep catching up in terms of features without getting slower.
评论 #28861427 未加载
crubierover 3 years ago
Esbuild is amazing, but it’s worth mentioning SWC, which is written in Rust, even faster than Esbuild, and integrated within Deno, NextJS and other leading tools. Overall I am pretty bullish on the Rust&#x2F;Js&#x2F;Wasm&#x2F;Typescript ecosystem.
towndrunkover 3 years ago
Does esbuild support scss directly yet? I see on the site it mentions css. This is an important limitation for me.
评论 #28870142 未加载
评论 #28867385 未加载
kohlermover 3 years ago
That&#x27;s old news or? For complex projects moving to esbuild from say Webpack is not necessarily easy.
评论 #28861528 未加载
评论 #28870623 未加载
jerrygoyalover 3 years ago
see comparison with swc: <a href="https:&#x2F;&#x2F;swc.rs&#x2F;docs&#x2F;benchmark-transform" rel="nofollow">https:&#x2F;&#x2F;swc.rs&#x2F;docs&#x2F;benchmark-transform</a>
评论 #28862562 未加载
评论 #28861934 未加载
talkingtabover 3 years ago
I started with webpack using create react app, I tried parcel, I tried esbuild. I tried parcel 2. I use esbuild. As a sole developer it takes no thought, and it still lets me do odd things pretty easily - like I have a particular process for dealing with odd cases in mdx files. Not a ringing endorsement or an exhaustive analysis. I&#x27;m just happy I don&#x27;t have to spend time thinking about it. :-)
评论 #28866142 未加载
keb_over 3 years ago
I&#x27;ve been actively moving all my projects from rollup to esbuild where possible. You have to do a bit more plumbing to get a lot of the niceties provided by the rollup&#x2F;webpack ecosystem, but the resulting simplicity, speed, and size of esbuild make it worth it.
TekMolover 3 years ago
Isn&#x27;t the browser also an extremely fast Javscript bundler?<p>How many scripts does a site need to make it feel faster when bundled?<p>When I visit websites that are rendered serverside, they usually feel instant to me. Even when they load a dozen scripts or so.
评论 #28861722 未加载
评论 #28861134 未加载
评论 #28862038 未加载
评论 #28861062 未加载
评论 #28860944 未加载
评论 #28861173 未加载
mjacksonover 3 years ago
Although esbuild has been out for a while now, I think it&#x27;s relevant today because the benchmarks have been updated to include Parcel 2, which was just released earlier today.
strzibnyover 3 years ago
Both Rails 7 and Phoenix 1.6 is going off Webpack by default and I am so looking into the esbuild future. I never really liked Webpack to be honest.<p>I already replaced Webpack in my Phoenix project (you can compare default steps for building a release here <a href="https:&#x2F;&#x2F;nts.strzibny.name&#x2F;12factor-elixir-phoenix-releases&#x2F;" rel="nofollow">https:&#x2F;&#x2F;nts.strzibny.name&#x2F;12factor-elixir-phoenix-releases&#x2F;</a>) and cannot wait to do the same in Rails.
eezingover 3 years ago
Deno is using this: <a href="https:&#x2F;&#x2F;github.com&#x2F;swc-project&#x2F;swc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;swc-project&#x2F;swc</a>
armchairhackerover 3 years ago
How does esbuild compare to Bun, snowpack, Vite, and any other JS bundles? In performance, reliability, and extra features?
评论 #28869897 未加载
qeternityover 3 years ago
What’s the catch? Do they really have a secret sauce or are there limitations in esbuild to achieve these speed ups?
评论 #28861980 未加载
评论 #28861896 未加载
评论 #28862638 未加载
评论 #28862088 未加载
评论 #28862957 未加载
conaclosover 3 years ago
esbuild is a pleasure to use. Because of its speed you no longer need to separate test&#x2F;release build for simple libraries. I am using esbuild for transpiling my new TypeScript projects.<p>However, I am still have to use TSC to generate declaration files(dts). Are anyone aware of esbuold-like tool to do that job?
XCSmeover 3 years ago
I am using ParcelJS v2 (nightly), and my builds are really fast for a medium-sized project. It takes about 5s from scratch (no-cache) and &lt;500ms to update after a change.<p>Do I recommend Parcel? Not sure, it feels like every time I update the package something breaks (in their defense, it is still in Beta).
评论 #28865977 未加载
ianberdinover 3 years ago
Well, I spent few days to move large vue.js codebase from webpack 4 to Vite (esbuild). You know what? It isn’t as fast as that benchmarks shows us, even buggy and laggy. So upgraded to webpack 5 with caching to filesystem (I bet no one know) and it became even faster than Vite! I’m happy.
评论 #28869426 未加载
sesmover 3 years ago
&gt; Both Go and JavaScript have parallel garbage collectors, but Go&#x27;s heap is shared between all threads while JavaScript has a separate heap per JavaScript thread.<p>It actually implies that JS GC can be faster because it doesn’t require global locks and can collect garbage in parallel.
pier25over 3 years ago
Personally I&#x27;ve never found bundling speed to be a major bottleneck.<p>I do have some complicated Webpack setups that I don&#x27;t think can be solved with any other bundler.
darepublicover 3 years ago
It stings being in webpack and there isn&#x27;t much I can do about it in my current situation
Kiroover 3 years ago
How is it possible to be so fast?
评论 #28861241 未加载
评论 #28861380 未加载
评论 #28861054 未加载
calmyournervesover 3 years ago
esbuild is awesome! The level of detail in the release notes [1] always impresses me.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;evanw&#x2F;esbuild&#x2F;releases" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;evanw&#x2F;esbuild&#x2F;releases</a>
peanut_wormover 3 years ago
Is this the only popular JS build tool written in something other than JavaScript
评论 #28868755 未加载
escotover 3 years ago
So is esbuild vs parcel a bit of an accidental proxy battle between go and rust?
k__over 3 years ago
I&#x27;ve used it for a TypeScript project and it just worked.<p>A bit like Parcel, but faster.
jFriedensreichover 3 years ago
also kudos to the esbuild team to have an official mention of deno usage and support. it works great and turned out to be much simpler, flexible and reliable than the current Deno.emit .
joshxyzover 3 years ago
Yep, moved from webpack to esbuild + postcss. Great results.
sandGorgonover 3 years ago
has anyone used this in react-native ?
评论 #28861242 未加载
lovely_koalaover 3 years ago
Looks awesome! I&#x27;m gonna use it!
ep103over 3 years ago
Anyone able to compare this to Vite?
评论 #28862730 未加载
评论 #28862728 未加载
sAbakumoffover 3 years ago
from my PoV Vite.js is much more mature project than esbuild
hit8runover 3 years ago
What do you think of the importmap approach propagated by dhh on rails 7?
评论 #28866081 未加载
评论 #28861100 未加载
评论 #28861533 未加载
Salu3over 3 years ago
salu2
terpimostover 3 years ago
I must say that this got to be a new standard. Es build is what we need. Great thing. Huge thanks to creators!
truth_seekerover 3 years ago
I would rather use Parcel.
评论 #28861154 未加载
KingOfCodersover 3 years ago
On another thread were I said I don&#x27;t like build tools&#x2F;compilers in the same language as they work on, when the language is slow, I got voted down.<p>Here everyone: JS build tool in Go? Great!<p>+1 for parallelism of esbuild. I have a12 core machine and many tools either use one core or when forced to not benefit from more cores.<p>I also wish they would waste more memory, I have 32gb which re mostly unused even by large projects.<p>I stand by my opinion: dev tools should make it pleasant for developers not the tool writers.
throw_m239339over 3 years ago
Yet another one of these...<p>I&#x27;m sorry, but the node.js community needs to stop producing these stuff... it doesn&#x27;t do anything better than all the webpack vs gulp vs parcel vs snowpack vs rollup vs how many bundlers again?
评论 #28861768 未加载
评论 #28861698 未加载