5 ms·
Esbuild is awesome! I tried it on my latest project and the speed has blown me away, even though it doesn't replace the TypeScript compiler for my usecase. Its
by jannes 6y ago
Esbuild is awesome! I tried it on my latest project and the speed has blown me away, even though it doesn't replace the TypeScript compiler for my usecase.
Its two biggest shortcomings are:
1. It can't compile const enums (TypeScript feature)
2. It can't compile down to ES5 (with some exceptions)
So I still need to run TypeScript + esbuild side-by-side. TypeScript compiles to ES5 and esbuild bundles the ES5 files.
Anyway, it is a massive improvement over TypeScript + webpack.
- e12e 6y agoCurious to how you set this up without going crazy (and CI working)? Just a line in package.json that runs tsc, then another one that runs esbuild on the output?
- jannes 6y agoIt's a pretty simple setup for now. For tsc it's a single line in package.json (+tsconfig with outdir: "dist"). For esbuild I am running the following Node script (saved as .mjs): import esbuild from 'esbuild'; let args = process.argv.slice(2); await esbuild.build({ watch: args.includes('-w'), entryPoints: [ 'dist/entry1.js', 'dist/entry2.js', 'dist/entry3.js', ], bundle: true, target: 'es5', outdir: 'bundles/', });
- duderific 6y agoWe really need it to support top level await, and the author doesn't seem to be that interested in supporting it at the moment. Hopefully he will come around soon.
- dbbk 6y agoInteresting, what is your use case for that?
- thitcanh 6y agoThe use case is that it exists: It’s already been vetted and it’s part of the language. Not supporting it means you don’t support the entire language.
- sknowieowl 6y agoIt's part of the language, but not so much thoroughly vetted. The Chrome/V8 implementation has bugs. https://github.com/evanw/esbuild/issues/253#issuecomment-773785579 https://github.com/evanw/esbuild/issues/253#issuecomment-773...
- thitcanh 6y agoI mean the feature itself has been vetted, i.e. it wouldn’t be in the language if enough people didn’t find it reasonably useful. TLA is a substantial feature implementation-wise so I expect TC39 to have thought “yeah that’s still worth it”
- sknowieowl 6y agoTLA was accepted in the specification before the module loading scenarios were fully baked. Probably best to use async IIFEs until the TLA spec bugs are sorted out and the fixes are subsequently implemented in the major browsers and released. Maybe a year from now.
- ratww 6y agoThe use case is not needing to wrap your code in an IIFE [1] when you would have a top-level await statement. It is useful in entry point of apps where you might need anything that uses async. It's also useful for having async modules. [2] They're also very helpful for debugging. Using await something in the console is way more convenient than something.then(). [1] https://developer.mozilla.org/en-US/docs/Glossary/IIFE https://developer.mozilla.org/en-US/docs/Glossary/IIFE [2] https://github.com/tc39/proposal-top-level-await/blob/HEAD/README.md https://github.com/tc39/proposal-top-level-await/blob/HEAD/R...
- constexpr 6y agoI'm the author of esbuild. Rest assured that I am very interested in supporting it and am actively working on it. It's just unfortunately very complicated to correctly, especially without affecting any of the other existing features. There are some recent updates at the bottom of this thread: https://github.com/evanw/esbuild/issues/253 https://github.com/evanw/esbuild/issues/253.