
esbuild Has a Free API That Compiles JavaScript 100x Faster Than Webpack
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 }); 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 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 ? : \/\/ / }, ( args ) => ({ path : args . path , namespace : " http-url " , }
Continue reading on Dev.to Webdev
Opens in a new tab



