Live data from Hacker News

Esbuild – An extremely fast JavaScript bundler

esbuild.github.io

21–30 of 288 posts

Re: Esbuild – An extremely fast JavaScript bundler

#22

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 rails new your_app -j esbuild 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 projec…

Esbuild w/rails 7 is nice, but if you’re using rails, check out vite_ruby [1]. I used it in a side project and it comes with plugins for views HMR + all the good stuff that comes built into vite.

1: https://github.com/ElMassimo/vite_ruby

Re: Esbuild – An extremely fast JavaScript bundler

#23

Are there any tools that transform HTML and other files? For example, lets say I have an tag with a src attribute that points to a local image. Can I automatically replace that with a tag with various formats (jpg, webp, avif) and sizes?

In ESBuild you’ll need a plugin for this. The plugin API is really simple but you’ll likely be gluing other tools together to achieve it.

Re: Esbuild – An extremely fast JavaScript bundler

#24
post #21

What do you think of the importmap approach propagated by dhh on rails 7?

I think it’s a fantastic default. I’d argue most server rendered applications can get away with it. And if you ever need ESBuild you can install the js-bundling gem or pass “-j esbuild” for new Rails 7 apps.

Re: Esbuild – An extremely fast JavaScript bundler

#25
post #22

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 rails new your_app -j esbuild 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 projec…

Esbuild w/rails 7 is nice, but if you’re using rails, check out vite_ruby [1]. I used it in a side project and it comes with plugins for views HMR + all the good stuff that comes built into vite. 1: https://github.com/ElMassimo/vite_ruby

Yes 100% - I’m actually using Vite Ruby in a project as I really wanted to use Inertia + React and that was by far the easiest way to get everything up and running.

I’d go so far as to say I wish -j vite was an option in js-bundling :)

Re: Esbuild – An extremely fast JavaScript bundler

#28
post #4

Isn't the browser also an extremely fast Javscript bundler? How many scripts does a site need to make it feel faster when bundled? When I visit websites that are rendered serverside, they usually feel instant to me. Even when they load a dozen scripts or so.

What ESBuild offers over plain ESM is:

- fast TypeScript/JSX compile

- bundling shared code to reduce request waterfall/splitting to reduce redundancy

- bundle optimization (tree shaking/dead code elimination; minification is actually faster than not using it)

- a simple plugin system for use cases like other compiled frameworks like Vue or Svelte, or whatever else you might want in a build pipeline

Re: Esbuild – An extremely fast JavaScript bundler

#30
post #5

Earlier quoted context omitted.

> How many scripts does a site need to make it feel faster when bundled? Depends on what you're building. If you have many nested dependencies, you need to bundle them, and not rely on the browser to resolve them at runtime and do dozens of roundtrips to the server to fetch them.

I thought HTTP 2 fixed the problem of multiple downloads of small files/dependencies? The creator of Rails talks about it here: https://world.hey.com/dhh/modern-web-apps-without-javascript...

You can use the Network tab of your preferred browser to see the waterfall. HTTP2 did improve a lot, but it can’t magically resolve N-deep transitive imports without additional information. It was originally designed to have that information provided at the server level, but HTTP Push has been dead for a while. There are physical limitations at work, optimizing requests on the wire is still important.
Post reply on HN