Live data from Hacker News

Some notes on using esbuild

jvns.ca

11–20 of 205 posts

Re: Some notes on using esbuild

#11
Great read, kudos for using strace to understand what esbuild does! I should do that more often.

This is another reason to favor small and simple tools that do one thing: you can “take it apart” and understand it by using another simple tool. (Simple in a relative sense, e.g. compared to Webpack).

By the way for those who don’t know what strace is, it’s a command line utility that prints out system calls of another process, like opening files or network connections.

Re: Some notes on using esbuild

#12
All the (great) recommendations in this comment section are a great example of how the js ecosystem works. there are so many great new technologies available for building apps, but standardization and discoverability are far from solved.

There are new esm based cdns (similar things have been around since the browserify days), awesome new build tools like esbuild, skypack, and swc that are faster and/or simpler than webpack. new language features have been standardized that reduce the need for various types of libraries, etc.

For anyone who doesn't spend an unreasonable time following these developments discovery of all this cool new things seems very tough.

On the opposite side of things, as a developer of a library I think is really useful, figuring out how to help people find it, I have no idea where to start.

Re: Some notes on using esbuild

#13
I can't decide if the root cause of this problem is in esbuild or in Vue. The fact you can't do "import vue from 'Vue';" with esbuild means either it's module resolver is terrible, or Vue is doing something super-weird with the way it bundles artifacts. Either way, something is seriously wrong.

FWIW, "import react from 'React';" works fine with esbuild with no config, so I'm inclined to think this is a problem in Vue.

Re: Some notes on using esbuild

#14
post #13

I can't decide if the root cause of this problem is in esbuild or in Vue. The fact you can't do "import vue from 'Vue';" with esbuild means either it's module resolver is terrible, or Vue is doing something super-weird with the way it bundles artifacts. Either way, something is seriously wrong. FWIW, "import react from 'React';" works fine with esbuild with no config, so I'm inclined to think this is a problem in Vue…

> The fact you can't do "import vue from 'Vue';" with esbuild

You misunderstood, they say this is exactly how it works. But they wanted a specific build instead of the default one of vue (the one with the runtime compiler, not default because it has performance penalties).

Re: Some notes on using esbuild

#15
As a developer who is in this ecosystem so long that it makes me shrug when I think about it, I loved the humble writing style and loved the fact that she could teach me a thing or two.

Being able to say "I don't know how this works" requires a lot of experience too, not just confidence.

Especially in an interview, people saying "I don't know anything about what you asked", depending on the requirements, can end the interview but could also make the candidate gain a lot of points.

Thanks for the write-up!

Re: Some notes on using esbuild

#16
If you're going to have a build step at all, instead of hand rolling your build commands and configs, just use Vite[1] already. It uses esbuild for development and rollup for production (since esbuild is not featureful enough for a lot of production use cases), you get instantaneous startup, hot module replacement, static asset imports, etc. for free. It's from Evan You, the creator of Vue, but it also supports React, which works pretty well with it in my experience. Btw SvelteKit also uses Vite.[2]

[1] https://vitejs.dev/

[2] https://svelte.dev/blog/sveltekit-beta#From_Snowpack_to_Vite

Re: Some notes on using esbuild

#18
I've recently being helping a friend who is starting with Node.js, and I strongly recommended him (and anyone else getting started now) to use all `import` instead of `require`.

I would say it takes a bit more of work because the tutorials are normally written on commonJS (require), but otherwise it's just a different kind of work. Both of them have their peculiarities and issues, and CommonJS might also bite you big time. So if you have to choose, and both give you a bit of pain (for now), I'd suggest to choose the one that is more future-proof.

About the article on Esbuild and ESM vs CommonJS, some other personal notes:

- Node.js' `import` is more strict than frontend tools' `import`. You can do `import myfile from './myfile'` on the front-end but you need to specify the ".js" on the backend.

- You can no longer use __dirname with ES6 modules. That's a feature, and I found that I normally have enough control over where the script is run from that I just prefer write all relative paths instead of bothering shiming it.

- The Esbuild from the author is great and I use something similar for simpler projects and libraries I develop. However for making WebApps, I prefer to also have Hot Module Reload. It's like Prettier, at the beginning it feels unnatural and overbearing, but after you get used to it you realize what a huge order of improvement it is vs the way you were used to.

Re: Some notes on using esbuild

#19
post #16

If you're going to have a build step at all, instead of hand rolling your build commands and configs, just use Vite[1] already. It uses esbuild for development and rollup for production (since esbuild is not featureful enough for a lot of production use cases), you get instantaneous startup, hot module replacement, static asset imports, etc. for free. It's from Evan You, the creator of Vue, but it also supports React…

Addressed in TFA:

> But I stopped using those tools and went back to my old 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.

Re: Some notes on using esbuild

#20
post #16

If you're going to have a build step at all, instead of hand rolling your build commands and configs, just use Vite[1] already. It uses esbuild for development and rollup for production (since esbuild is not featureful enough for a lot of production use cases), you get instantaneous startup, hot module replacement, static asset imports, etc. for free. It's from Evan You, the creator of Vue, but it also supports React…

I don't understand the point of vite. I tried using it and the "build" took over 30 seconds. esbuilds takes less than 1 second for the same project.

> esbuild is not featureful enough for a lot of production use cases

What makes you say that? I keep hearing people say this, but I haven't run into any problem that make esbuild not ready for production.

Post reply on HN