In modern web development, speed is a feature. Slow build times frustrate developers and hinder productivity, while large, unoptimized bundles lead to slow-loading websites and a poor user experience. The build process itself has become a critical bottleneck. But what if you could compile, bundle, and minify your code in milliseconds, not minutes, and do it all through a simple API call?
Enter esbuild, an incredibly fast JavaScript bundler and minifier written in Go. Its performance is revolutionary. And now, with esbuild.do, you can harness this power programmatically as part of a seamless, API-driven workflow. Forget complex local setups and node_modules—it's time to embrace "Build as Code."
Before diving into the solution, let's appreciate the problem.
Optimizing both is not just a "nice-to-have"; it's essential for competitive applications.
esbuild was built from the ground up with a singular focus on speed. Unlike traditional bundlers written in JavaScript, esbuild is written in Go, a compiled language that runs on native code. It heavily leverages parallelism to utilize all available CPU cores, and its algorithms are designed for maximum efficiency.
The result? esbuild is often 10-100x faster than its counterparts. This isn't just an incremental improvement; it fundamentally changes what's possible with your build process.
While esbuild's CLI is fantastic for local development, modern infrastructure demands automation and integration. This is where esbuild.do shines. It exposes the full power of esbuild through a simple, robust API on the Agentic Workflow Platform.
Instead of running shell commands, you import and call an agent. This "Build as Code" approach offers significant advantages:
Let's see just how simple it is. Imagine you want to bundle a TypeScript entrypoint that imports a utility function, then minify the output for production. With esbuild.do, your entire build step looks like this:
import { esbuild } from "jsr:@do/esbuild";
// Define your entrypoint code as a string
const entrypointCode = `
import { add } from './math';
console.log('Result:', add(2, 3));
`;
// Define a virtual file system for any other files
const otherFiles = {
"./math.ts": "export const add = (a, b) => a + b;",
};
// Call the esbuild agent to bundle, transpile, and minify the code
const result = await esbuild.bundle({
entrypoint: entrypointCode,
files: otherFiles,
options: {
bundle: true, // Follow imports and bundle them
minify: true, // Minify the output code
platform: 'node', // Target the Node.js environment
target: 'esnext', // Use modern JavaScript syntax
},
});
console.log(result.code);
// Expected output: "console.log(\"Result:\",5);"
In this example, we performed a complex build operation—transpiling TypeScript, resolving modules from a virtual file system, bundling them into a single file, and minifying the result—with a single, clean API call. The output is a tiny, optimized string ready for execution.
esbuild.do is an agent on the .do platform that provides access to the esbuild JavaScript bundler as a simple API. It allows you to perform fast code bundling, minification, and transpilation without installing any local dependencies.
Using esbuild via an API is ideal for programmatic workflows, CI/CD pipelines, and serverless environments. It allows you to integrate lightning-fast bundling directly into your applications and services, treating your build process as code.
Our esbuild agent supports a wide range of inputs including JavaScript (.js), TypeScript (.ts), JSX, and TSX. It can output modern JavaScript targeted for browsers or Node.js environments.
Slow builds and bloated bundles are a tax on productivity and performance. esbuild.do offers a powerful escape hatch. By providing the world's fastest bundler as-a-service, we empower you to create more efficient CI/CD pipelines, build dynamic serverless applications, and deliver faster experiences to your users.
Stop waiting for your tools. Integrate esbuild.do into your workflow and experience the future of JavaScript bundling.