3 ms·
ESM is actually quite simple. The problem is just that people don't know the basics and tools are encumbered by years of cruft and varying behavior. Check out h
by sureIy 1y ago
ESM is actually quite simple. The problem is just that people don't know the basics and tools are encumbered by years of cruft and varying behavior. Check out how many "module" and "moduleResolution" behaviors TypeScript alone has.
The trick is to start fresh and to know the basics:
- use type=module
- import with extensions
- use a sensible shared tsconfig (this is the hard part)
- don't use junk tools like webpack and jest
- zoover2020 1y agoWhat is s sensible tsconfig according to you?
- sureIy 1y agoI use @sindresorhus/tsconfig, but there are a handful of possible improvements over it (see open issues)
- dhruvrajvanshi 1y ago> - don't use junk tools like webpack I used to have that opinion, but now, going through a months long project modernizing our codebase's build tooling, I'm not so sure. Vite isn't so amazing either if you stray away from the happy path (html entry points). I guess no build tool is amazing. At the end of the day, the only thing I can say is all build tools suck. Write less build code if you can get away with it. Eventually I had to settle on rspack (the spiritual successor to webpack) because vite wouldn't do what I wanted it to do. You could say it was the wrong tool for the job, but it took me a while to figure that out, given how scary it is to not use the frontend build tool. I still wish we could've used it because then we'd be using an industry standard tool. Getting back to criticizing Vite (sorry have to vent haha) in my experience, vite's API is also built on weird foundations. It exposes rollup and postcss options in it's config, which sometimes do similar things as it's own config options. It generates tons of small chunks with no obvious way to control it without giving up on nice things.
- myvoiceismypass 1y agoAlso, should be noted that vitest does not require you to be using vite for bundling and is much much faster / easier to configure than jest these days. (It also has a jest-compatible API)