{"id":13131,"library":"esbuild-freebsd-arm64","title":"esbuild","description":"esbuild is an extremely fast JavaScript and CSS bundler and minifier, designed to dramatically improve build tool performance. Written in Go and compiling to native code, it achieves build times 10-100 times faster than traditional JavaScript-based bundlers like Webpack or Rollup. The current stable version is 0.28.0 (as of April 2026), with a sustainable release cadence ensuring frequent updates and feature additions. Key features include built-in support for JavaScript, TypeScript, JSX, and CSS, bundling of ESM and CommonJS modules, aggressive tree-shaking, minification, source map generation, and a straightforward API for both CLI and programmatic use. It also offers a plugin system for extending its core functionality. It is widely adopted for rapid development and production builds where speed is critical, often integrated into meta-frameworks and other build tools.","status":"active","version":"0.15.18","language":"javascript","source_language":"en","source_url":"https://github.com/evanw/esbuild","tags":["javascript"],"install":[{"cmd":"npm install esbuild-freebsd-arm64","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-freebsd-arm64","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-freebsd-arm64","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Binary executable for macOS ARM64. `esbuild` installs the appropriate platform-specific package automatically.","package":"@esbuild/darwin-x64","optional":true},{"reason":"Binary executable for Linux x64. `esbuild` installs the appropriate platform-specific package automatically.","package":"@esbuild/linux-x64","optional":true},{"reason":"Binary executable for Windows x64. `esbuild` installs the appropriate platform-specific package automatically.","package":"@esbuild/win32-x64","optional":true},{"reason":"WebAssembly fallback for platforms without a native binary, or for browser environments.","package":"esbuild-wasm","optional":true}],"imports":[{"note":"The primary API for bundling files. `esbuild` is primarily ESM-first for its programmatic API, though CommonJS `require` can be used with dynamic `import()` or by configuring your project for CommonJS.","wrong":"const esbuild = require('esbuild'); esbuild.build(...);","symbol":"build","correct":"import { build } from 'esbuild'"},{"note":"Used for transforming a single string of code (e.g., TS/JSX to JS) without touching the file system. Ideal for in-memory transformations. Like `build`, primarily ESM-first for modern usage.","wrong":"const esbuild = require('esbuild'); esbuild.transform(...);","symbol":"transform","correct":"import { transform } from 'esbuild'"},{"note":"Provides a development server API. Ensure the `esbuild` package is installed as a development dependency.","wrong":"const { serve } = require('esbuild');","symbol":"serve","correct":"import { serve } from 'esbuild'"},{"note":"While `esbuild` provides named exports for its API, the `esbuild` package often acts as a JavaScript shim for the native binary. When running via `node_modules/.bin/esbuild`, it launches an external process. The programmatic API uses named exports.","wrong":"import * as esbuild from 'esbuild'","symbol":"default import (for CLI via shim)","correct":"import esbuild from 'esbuild'"}],"quickstart":{"code":"import { build } from 'esbuild';\n\nconst entryPoint = 'src/app.ts';\nconst outFile = 'dist/bundle.js';\n\nasync function bundleApp() {\n  try {\n    await build({\n      entryPoints: [entryPoint],\n      bundle: true,\n      minify: true,\n      sourcemap: true,\n      target: ['es2020', 'node18'],\n      platform: 'browser', // Or 'node', 'neutral'\n      outfile: outFile,\n      logLevel: 'info',\n      // Define environment variables directly for substitution\n      define: {\n        'process.env.NODE_ENV': JSON.stringify('production'),\n        'process.env.API_KEY': JSON.stringify(process.env.API_KEY ?? 'default_api_key')\n      },\n      // Plugins can extend esbuild's functionality\n      plugins: [\n        // Example: a simple plugin to log start/end\n        {\n          name: 'logger',\n          setup(build) {\n            build.onStart(() => {\n              console.log(`Starting build of ${entryPoint}...`);\n            });\n            build.onEnd(result => {\n              if (result.errors.length > 0) {\n                console.error(`Build of ${entryPoint} failed with ${result.errors.length} errors.`);\n              } else {\n                console.log(`Successfully built ${entryPoint} to ${outFile} in ${result.timeInMs}ms.`);\n              }\n            });\n          },\n        },\n      ],\n    });\n    console.log('Build complete!');\n  } catch (e) {\n    console.error('Build failed:', e.message);\n    process.exit(1);\n  }\n}\n\nbundleApp();","lang":"typescript","description":"This quickstart demonstrates how to use esbuild's programmatic `build` API to bundle, minify, and generate a sourcemap for a TypeScript application, targeting both modern browser and Node.js environments. It also includes basic plugin usage for logging and defines environment variables."},"warnings":[{"fix":"Pin the exact version of `esbuild` in your `package.json` (e.g., `\"esbuild\": \"0.27.0\"`) or use a patch-only range (`^0.27.0` or `~0.27.0`) to avoid unexpected breaking changes from minor version increments in `0.x.x` releases. Ensure your operating system meets the new minimum requirements.","message":"esbuild 0.27.0 (and other `0.x.0` releases) introduced backwards-incompatible changes. These included updated Go compiler versions, which can subtly alter behavior in edge cases related to garbage collection, memory allocation, and executable formats. It also raised minimum operating system requirements (e.g., Linux kernel 3.2+, macOS 12+). [cite: v0.27.0 release notes, 16, 17, 18]","severity":"breaking","affected_versions":">=0.27.0"},{"fix":"Upgrade `esbuild` to version `0.25.0` or newer. If `esbuild` is a transitive dependency (e.g., via Angular), use `npm audit fix --force` or configure `package.json` `overrides` to enforce `\"esbuild\": \"^0.25.0\"`.","message":"esbuild versions 0.24.2 and earlier had a moderate severity vulnerability (CVE-2024-23334) in its development server, allowing external websites to send requests and read responses, potentially exposing sensitive information.","severity":"breaking","affected_versions":"<=0.24.2"},{"fix":"Ensure your project uses Node.js version 18 or later. Check the official Node.js release schedule for supported versions.","message":"The minimum required Node.js version for esbuild's JavaScript API was increased from Node 12 to Node 18 due to incompatibilities with JavaScript generated for `esbuild-wasm` and older Node.js versions (specifically `crypto.getRandomValues`).","severity":"breaking","affected_versions":">=0.19.12 (published in 2024)"},{"fix":"Add `platform: 'node'` to your `esbuild` configuration (CLI: `--platform=node`) to correctly handle Node.js-specific modules and behavior.","message":"When bundling for a Node.js environment, it is crucial to explicitly set the `platform` option to `'node'`. Failing to do so can lead to `Could not resolve` errors for Node.js built-in modules (e.g., `https`, `fs`) as esbuild will try to bundle them for a browser environment.","severity":"gotcha","affected_versions":"all"},{"fix":"Be aware of this internal transformation. Ensure your code does not rely on strict `let`/`const` block-scoping behavior at the top level in ways that might conflict with `var` hoisting in complex bundling scenarios. Test your bundled output carefully.","message":"esbuild sometimes rewrites top-level `let`, `const`, and `class` declarations as `var` declarations for correctness in bundling. While `const` mutations are prevented, this can be unexpected if strict variable scoping is assumed.","severity":"gotcha","affected_versions":"all"},{"fix":"Wrap `using` declarations within explicit block statements (`{...}`) inside `switch` cases to maintain correct scoping and syntax. E.g., `case 'read': { using readLock = db.read(); return readAll(readLock); }`.","message":"The `using` declarations inside `switch` case/default clauses, previously supported and implemented, are now a syntax error. This aligns with a specification change due to confusion around scope within `switch` statements.","severity":"deprecated","affected_versions":">=0.27.0 (specifically related to a change in ECMAScript proposal)"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Verify that the module is installed (`npm install some-module`), check for typos in the import path, and ensure correct casing. If it's a Node.js built-in module, ensure `platform: 'node'` is set in your build configuration.","cause":"esbuild cannot find the specified module in your `node_modules` or resolve its path.","error":"✘ [ERROR] Could not resolve \"some-module\""},{"fix":"Review the file and line number indicated in the error message. Ensure your code adheres to correct syntax for the target environment. Use a linter (e.g., ESLint) to catch syntax errors proactively.","cause":"There is a syntax error in your JavaScript, TypeScript, or JSX code that esbuild cannot parse.","error":"✘ [ERROR] Expected \";\" but found \"}\" (or similar syntax errors)"},{"fix":"Add `platform: 'node'` to your esbuild configuration. For the CLI, use `--platform=node`. For the API, set `platform: 'node'` in the build options object.","cause":"esbuild is attempting to bundle a Node.js built-in module (like `https`, `fs`, `path`) but is configured for a browser environment.","error":"The package \"https\" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use \"platform: 'node'\" to do that, which will remove this error."},{"fix":"Use a more specific naming scheme for your entry points or chunk names. For CLI, consider `--entry-names=[dir]/[name]` or `--chunk-names=[name]-[hash]`. Programmatically, define `entryNames` or `chunkNames` in your build options.","cause":"This typically occurs when dynamic imports or multiple entry points would result in output files with identical base names (e.g., two `index.js` files from different library paths).","error":"Error: Conflict: The output files \"index.js\" and \"index.js\" are being generated for different entry points. You need to use a different naming scheme."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"esbuild"}