Menu

Post image 1
Post image 2
1 / 2
0

esbuild Has a Free API That Compiles JavaScript 100x Faster Than Webpack

DEV Community: esbuild·Alex Spinov·3 days ago
#4vWfTJ0K
#dev#esbuild#build#true#fullscreen#article
Reading 0:00
15s threshold

esbuild is the Go-powered JavaScript bundler that transformed the build tool landscape. Its API is minimal but incredibly powerful. The Build API import * as esbuild from " esbuild " ; await esbuild . build ({ entryPoints : [ " src/index.ts " ], bundle : true , minify : true , sourcemap : true , splitting : true , format : " esm " , target : [ " es2020 " ], outdir : " dist " , metafile : true , // Generate build analysis }); Enter fullscreen mode Exit fullscreen mode The Transform API: In-Memory Compilation const result = await esbuild . transform ( tsCode , { loader : " tsx " , target : " es2020 " , jsx : " automatic " , minify : true , }); console . log ( result . code ); // Compiled JS console . log ( result . map ); // Source map Enter fullscreen mode Exit fullscreen mode No filesystem. No config files. Pure in-memory transformation. Plugin API: Extend Everything const httpPlugin = { name : " http-import " , setup ( build ) { // Intercept HTTP imports build . onResolve ({ filter : /^https ?…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More