13 ms·
Esbuild 0.9
- bpierre 6y agoIf you want to use config files with esbuild, esbuild-config is for you: https://github.com/bpierre/esbuild-config https://github.com/bpierre/esbuild-config (disclaimer: I am the author)
- encryptluks2 6y agoLove how this is used with Hugo: https://gohugo.io/hugo-pipes/js/ https://gohugo.io/hugo-pipes/js/
- earthboundkid 6y agoYes. When ESBuild came out, I made a feature request to get it added to Hugo, and I was surprised at how well it has worked out. Goes to show you should always open an issue!
- arcatek 6y agoWe now use it to build Yarn, and it's been working very well. Still some rough edges that prevent us from adopting it at work (like the lack of dynamic imports when the import expression references variables), but I'm slowly making progress in implementing workarounds for that through loaders, and the first results are encouraging. At its worst, with a Webpack/Esbuild hybrid approach, we get at least 2x better perfs.
- scaladev 6y agoHell yes, esbuild is an amazing tool. I not only use it in most CRA projects (where it replaces webpack and builds everything at least two times faster), but it's also easy to use for plain HTML pages to add some interactivity without writing thousands of lines of webpack black magic: esbuild App.tsx --define:process.env.NODE_ENV=\\\"production\\\" --bundle --minify --target=es6 --outfile=out.js where App.tsx is your entry point. Include out.js into the page and you're done.
- akhilcacharya 6y agoThis is exceptional - what’s the downside when using it with CRA?
- lsmurray 6y agodo you have instructions for integrating with cra
- scaladev 6y agoUnfortunately it's not officially supported (as usual in CRA world), so you have to resort to one of the config rewriters. I've been using this⁰ and only had one problem with numeric enums in TypeScript. I don't remember the exact issue, but it was caused by my own stupidity, and was easy to fix. [0] https://github.com/pradel/create-react-app-esbuild/tree/main/packages/craco-esbuild https://github.com/pradel/create-react-app-esbuild/tree/main...
- picardo 6y agoesbuild can be a good alternative to Webpack in some cases, but Webpack solves a lot of edge cases well. For example, just today I debugged an issue where a library had used `require` in an ES module instead of `import`, and that broke the build with esbuild. So I had to fork the library to fix that issue. Webpack handles that case without problems. I can think of at least a few cases like that where Webpack works better, but esbuild is (hopefully) going to catch up. It'd be ideal if Webpack and other bundler tools ditched their homegrown build tools and replaced them with esbuild.
- earthboundkid 6y ago> Webpack solves a lot of edge cases well I would quibble with the word "solves". Webpack is a tool building tool. With Webpack, you can build a tool to solve your edge case problem, as long as you're willing to spend a lot of time and dig through random Github issues for your dependencies. Webpack itself however does basically nothing.
- 6y ago
- AbuAssar 6y agoesbuild makes it pretty clear that writing the JS ecosystem in JS is a bad choice*. now we need to rewrite tsc/babel/npm/eslint/etc... in a language that compile down to native binary that is also cross platform (like go or rust), to gain the same performance improvements across the entire JS tool-chain. * based on the benchmark on their landing page.
- deanclatworthy 6y agoI think this comment undervalues the quality of engineering that Evan has put into esbuild. It’s not only quick because it’s written in golang, but also due to the decisions taken in architecture and an opinionated tool that does mainly one thing well.
- jakelazaroff 6y agoI don’t read OP as devaluing Evan’s work. Presumably the TypeScript/Webpack/etc teams are also doing great engineering work — but because they’re writing in JS, the performance ceiling is significantly lower.
- afavour 6y agoI don’t know about that. Just look at the performance difference between NPM and Yarn: both built with JS, but for me at least Yarn is way, way faster. I’m sure it would make sense to rewrite certain things in Rust or Go (then possibly pull them into Node as native modules) but they’re not magic. Good engineering will win out no matter what.
- earthboundkid 6y agoGood engineering is definitely key, but I think interpreted languages are a bad fit for developer tools (though they are extremely popular for writing developer tools). On the surface, writing JS tools in JS is good because hey, you definitely know JS, right? But in practice it is bad because I don't want the JS I am writing in any way constrained by the JS you wrote. The problem with any interpreted language is that to run the tool you need all the source and all the dependencies plus the interpreter in something like their intended versions to be present in the right locations on disk. This is a huge PITA, and if you're say writing JavaScript targeting ES5 but your tools are targeting ES2020 or vice versa, there can be painful yak shaving sessions getting everything on the same page. Essentially all developer tools should be static binaries.
- dilsmatchanov 6y agowaiting for js bundler written in Rust
- btd 6y agoyou know about swc right? https://swc.rs/ https://swc.rs/
- dilsmatchanov 6y agoomg lol
- nicoburns 6y agoI'd recommend esbuild over SWC. It's much more mature.
- wdb 6y agoYes, but a bunch of the Typescript support is closed sourced . No idea, if that's important for you.
- searchableguy 6y agoType checker, yes. I don't think esbuild comes with a built-in typechecker either. Is there anything else I am missing?
- wdb 6y agoI was referring to swc
- deleted 6y ago[deleted]
- brendyn 6y agoIt's important to me. Could you please link me to where these nonfree bits are?
- carwyn 6y agoHow does this compare to https://www.snowpack.dev/ https://www.snowpack.dev/ ?
- bpierre 6y agoSnowPack is more of an all-in-one kind of tool (with dev server, HMR, etc.). Also it uses esbuild internally :-) https://www.snowpack.dev/guides/optimize-and-bundle#option-1%3A-built-in-optimizations https://www.snowpack.dev/guides/optimize-and-bundle#option-1...
- picardo 6y agoSnowpack is a bundler, not a build tool. It works with a variety of file formats, and it uses esbuild to compile JS/TS assets.
- deleted 6y ago[deleted]
- qbasic_forever 6y agoSnowpack uses esbuild internally now, there's a good rundown of it and other awesome snowpack features like streaming imports in their 3.0 release announcement: https://www.snowpack.dev/posts/2021-01-13-snowpack-3-0 https://www.snowpack.dev/posts/2021-01-13-snowpack-3-0
- nicoburns 6y agoESbuild is excellent for using with TypeScript and Node.js. We were previously using Nodemon to restart the server on changes. ESbuild is fast enough that rather than having to change our workflow and run a tsc --watch process in addition to Nodemon (which would be rather a pain given that we have 5-6 microservices), we simply use ESbuild to recompile the entire service before restarting the code (it takes about 0.1 seconds to compile everything, so it effectively doesn't impact our workflow at all).
- madjam002 6y agoAmazing stuff, I was thinking of doing pretty much exactly this this morning. Out of interest, if you’re bundling with Esbuild before running, how do you cope with native dependencies?
- nicoburns 6y agoWe don't use esbuild's "bundle" (--bundle) option, which means that our files get processed one-by-one and end up as separate files in the `dist` directory that we output to and that dependencies aren't processed at all and are just `required` like normal by our transpiled code. Our build command (in a bash script file to avoid string escaping issues) is: find src -type f \( -name '*.js' -o -name '*.ts' -o -name '*.sql' \) -print0 \ | xargs -0 ./node_modules/.bin/esbuild --platform=node --format=cjs --outdir=dist --loader:.sql=text
- madjam002 6y agoThanks for sharing, I’ve just given it a go with one of my larger projects and WOW!! Typescript incremental compilation was taking around 2 seconds on every save, then Nodemon would restart etc. I’ve plugged in Esbuild, I have used bundle mode though to see what it’s like, it works fine if I external all of my node modules, it builds in 0.23 seconds (approx 350 source files in my project). Nodemon now watches for TS file changes and exec’s the esbuild on every start. Thank you for the pointer to this as this will be a much needed productivity boost! I’ll try bundling some node modules when I have some time but it will take more work as I use Yarn PnP (I’ve found a plug-in so will definitely try that)
- parhamn 6y agoAs soon as esbuild gets react hot reloading capabilities I’m jumping ship. Although that might be out of scope and there is Vite. I’m hoping to avoid vite and go pure esbuild. Fantastic tool. It will make JavaScript distribution a much more pleasant experience across the board when it gets wider adoption.
- ccmcarey 6y agoThink that's out of scope - doesn't snowpack (which uses esbuild) cover this though? https://www.snowpack.dev/ https://www.snowpack.dev/
- keraf 6y agoSnowpack uses ESM for development which allows really fast HMR. And ESBuild is used for production builds. Best of both worlds.
- lhorie 6y agoHe said in the past that he's not interested in implementing HMR[0] [0] https://github.com/evanw/esbuild/issues/97 https://github.com/evanw/esbuild/issues/97
- parhamn 6y agoMakes logical sense from a library/unixy perspective. They offered similar reasoning for not including a file watcher at first but they eventually added that. HMR is pretty much the last missing piece to make this the only JS bundling and dev tool you need. It would be a bad decision to omit it.
- qbasic_forever 6y agoCheck out tools like vite or snowpack, which use esbuild internally. They're the HMR developer experience you're looking for.
- izelnakri 6y ago
- snemvalts 6y agoFor those who are actively using esbuild with TypeScript, how do you check the types?
- emptysea 6y agoI run tsc with noEmit passed as a flag. Esbuild is replaces my previous tsc, babel, uglify setup and is much faster.
- brundolf 6y agoWhat some people do is use types purely for editor purposes, and let the build process just throw them away. We did this at my last company using Babel
- nicoburns 6y agoIn 3 ways: - Using the Language Server Plugin in editors - `npx tsc --noEmit` in a pre-commit hook - `npx tsc --noEmit` in CI
- mceachen 6y agoI have a "lint" pre-test step that builds with tsc and runs eslint. I also have a `tsc --watch` running in a vscode window that highlights syntax and typing errors as I develop.
- qbasic_forever 6y agoThe JS & frontend world is _seriously fun_ right now. If you blew it all off as a quagmire of complexity, sketchy engineering, treadmill of tools, etc... it's time to re-evaluate everything. I have more fun and feel more productive working on modern frontend stuff with tools like esbuild than any other GUI programming I've done in 30 years.
- Scramblejams 6y agoYep, I tried front-end way back and hated it. Can you mention some other tech that should be covered in my re-evaluation?
- teryyy 6y agoTailwindCSS, Svelte, and Snowpack are probably worth a shot, all pretty much bleeding edge
- 1_player 6y agoThe problem with front end development is that it's all bleeding edge and nothing that's stable and is improved for more than one hype cycle. Suggesting more bleeding edge tech is not a good argument to demonstrate that front end development got better. In my experience, it changed, it improved on many aspects, but it's still a pile of unstable crap running on the power of hype and over-enthusiastic junior engineers.
- qbasic_forever 6y agoI get your frustration (and shared it a year ago), but you're really doing something like react a disservice by dismissing it like that as just hype. On the contrary react has evolved significantly over the years, introducing things like JSX (templating HTML + JS in the same file, now standard in every other component system), build tooling like create-react-app (zero config tooling, now standard in every JS build tool), functional component model with hooks (now copied by every other component library), and on the horizon stuff like server-side components. It has only gotten more stable, more proven, and easier to use over time.
- uses 6y agoI tried this a week or so ago, and it was indeed 100x or 1000x as fast as my webpack setup. Shocking, really. I couldn't get dynamic imports / code splitting working, which seemed to not be fully implemented yet. I also wasn't sure how to make polyfills happen.
- jmondi 6y agoI really really wish this supported experimental decorators with reflection metadata so we could use this in our Angular and NestJS apps.
- jayair 6y agoWe love esbuild and we use it internally for SST https://github.com/serverless-stack/serverless-stack https://github.com/serverless-stack/serverless-stack. The work Evan does is seriously impressive.
- kraig 6y agoas a heavy user of CDK, sst looks pretty cool. i'm curious why you didn't go the direction of adding this functionality to CDK directly? i'd like to use some of the functionality in here like live lambda development, but i also don't want to take on converting my org's already built CDK extensions and deal with migrations.
- jayair 6y agoThanks! We had to change the build process of Lambdas to support deploying a mock version of the function. And we need to add a new command that deployed the debug stack. Here's how it works internally — https://docs.serverless-stack.com/live-lambda-development https://docs.serverless-stack.com/live-lambda-development Your existing CDK app should work with SST. The main difference is that SST deploys per stage (or environment). This allows you to do `sst start` that goes to one environment and `sst deploy --stage prod` that goes to another.
- privatenumber 6y agoesbuild has flipped the JS community on its head. Not only as an impressive JS bundler, but through all the next gen tooling esbuild is powering. For example, you can now speed up your Webpack build with esbuild by replacing babel-loader/ts-loader/Terser: https://github.com/privatenumber/esbuild-loader https://github.com/privatenumber/esbuild-loader (It also blows my mind that Evan is the CTO is Figma. How is he so productive!?)
- swyx 6y agoi said on twitter that esbuild is the best possible ad for working for figma that they could have ever done. (if this is what they do for fun... imagine what they do at work, etc). arguably he's doing his job just working on this thing all by himself
- capableweb 6y ago> (It also blows my mind that Evan is the CTO is Figma. How is he so productive!?) When Evan first joined Figma, he saw how much time the engineers spent on waiting for webpack and fighting JS configuration files. Then one time, during an outage, the developers tried to push a fix but the build was failing because babel-deduplicate-int had changed their API interface but only did a minor version bump when published to NPM, and Figma engineers are at the edge of technology so they use version ranges, not fixed versions. When Evan heard this he pored up some whisky and created esbuild in two nights. And the JS developers rejoiced. Now the developers were so productive, that Evan already had nothing to do. No one was fighting, all engineers were happy and playing ping-pong like any everyday was Friday. So now the only thing keeping all the JS engineers happy at Figma, is the continued success and improvement of esbuild. So Evan just spends his time with esbuild now. (This is all fictional, of course)
- tmpz22 6y agoYeah that's a red flag "all work stops while executive does x then all processes must change to revolve around x"
- 6y ago
- anfrank 6y agoRelease note says pinning version with "^0.8.0", should be "~0.8.0" right?
- machiaweliczny 6y ago^ is for minor version, ~ for patch, you can pin exact version without using anything, so "0.8.0"
- anfrank 6y agoAh it seems ^ and ~ do not apply to versions pre 1.0.0
- astashov 6y agoI switched my pet project (about 15000 lines of code) from Webpack to esbuild, and reduced the build time from 30 seconds to 2 seconds. The trickiest part was to make Tailwind CSS work. I used to do that via postcss plugin, but just running that plugin even without Webpack takes 15 seconds. Finally, with some modifications in my CSS I made it work, and purged the unused styles just by using PurgeCSS API manually. The setup got a bit hairier than with Webpack, but it builds damn fast now.
- deergomoo 6y agoI believe the Tailwind team are currently working on addressing the performance issues. The project lead was recently tweeting about the new approach [0]; instead of building a huge CSS file and stripping out the unused classes, the new version will only generate the used classes to begin with. [0] https://twitter.com/adamwathan/status/1366514152517337089 https://twitter.com/adamwathan/status/1366514152517337089
- jbrandhorst 6y agoMind sharing some details? I've been working on this myself and I don't have much JS ecosystem experience. I found the same issue around using tailwindcss as a postcss plugin (it basically tripled my build time), so would love to hear alternative solutions.
- threatofrain 6y agoHow does Esbuild achieve such insane differences in speed?
- wffurr 6y agohttps://esbuild.github.io/faq/#why-is-esbuild-fast https://esbuild.github.io/faq/#why-is-esbuild-fast
- amatic 6y agoIt is written in go and compiled. Go is responsible for high parallelism. The fact it is compiled is an advantage over javascript-based bundlers because they are re-compiled every time you start building the source code (did I get that right?).
- swyx 6y agopartially. we should not overstate the impact of Go. if you read his design principles doc, he also prioritized parallelization and minimizing JS AST passes. those are surely at least as important as language choice.
- FlorianRappl 6y agoI would love to switch to esbuild, but unfortunately some basics are still not in there. I read some people switched, but I wonder how they have projects requiring 30+ seconds when not utilizing bundle splitting. Maybe I am missing something... Are you outputting esm files or what? Would be great to get some insights how people are mitigating the lack of bundle splitting in non-esm output right now. Thanks!
- tony 6y agoFor those relying on babel - what are the options? One thing I haven't seen yet is support for SCSS and CSS Modules. It looks like projects on those would need to switch to emotion+styled-components or styled-system, which would be a big move. If anyone uses relay, I started an issue here about using it with next-gen bundlers like esbuild: https://github.com/facebook/relay/issues/3319 https://github.com/facebook/relay/issues/3319 For those who don't know, relay is a graphql system by facebook. It seems dependent on babel (to my knowledge?) Two developments on this front: 1. @sciyoshi built an esbuild proof of concept for relay: https://gist.github.com/sciyoshi/34e5865f2523848f0d60b4cdd49382ee https://gist.github.com/sciyoshi/34e5865f2523848f0d60b4cdd49... 2. Meanwhile, the compiler has been being quietly rewritten in rust: https://github.com/facebook/relay/tree/master/compiler https://github.com/facebook/relay/tree/master/compiler. They're also claiming that it will include type generation.
- crazypython 6y agoI just use the very large subset of JavaScript supported natively by all major JS engines and avoid a transpiler entirely. Infinity times faster. That's subset is ES9/ES2018. https://wwwperiodictable.surge.sh/ https://wwwperiodictable.surge.sh/
- johnghanks 6y agoGood for you. Now try getting a job with that on your resume.
- abrookewood 6y agoAn extremely fast JavaScript bundler and minifier esbuild.github.io/
- nXqd 6y agoThis is an amazing work :)
- Sephr 6y agoWhen can we have const back? At some point esbuild started to transpile all const/let/var statements to var, which can potentially cause a slight performance decrease in some hot code paths (or at least a slight memory usage increase as noted in https://stackoverflow.com/a/52749016/78436 https://stackoverflow.com/a/52749016/78436).
- windowojji 6y agoCan you elaborate on this? const and let should be interchangeable from a performance perspective because it's not like the engine needs your input to know whether a binding is reassigned ever (that's a fundamentally easy thing for a compiler to check) so I must conclude that you're seeing performance benefits from using block scoped variables with TDZ that disappear when you use function scoped variables with var?
- deleted 6y ago[deleted]