Registry / azure / esbuild-azure-functions

esbuild-azure-functions

JSON →
library2.0.1jsnpmunverified

A blazingly fast builder for Azure Functions powered by esbuild, version 2.0.1. It compiles TypeScript Azure Functions into optimized bundles, reducing cold starts and deployment times. Active development as of 2023, with a focus on speed and small bundle sizes compared to traditional Azure Functions tooling. Supports watch mode and provides plugins for __dirname and require shimming. Requires esbuild v0.17.5+ as a peer dependency.

npm install esbuild-azure-functions
INSTALL
IMPORT
SIG · ESBUILD-AZURE-FUNC
E
esbuild-azure-functions
azurejavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

build
import { build } from 'esbuild-azure-functions'
const build = require('esbuild-azure-functions')
ESM-only since v2.0.0; CommonJS require will fail.
buildSync
import { buildSync } from 'esbuild-azure-functions'
import { buildSync } from 'esbuild'
Synchronous build variant for simple scripts.
type BuildOptions
import type { BuildOptions } from 'esbuild-azure-functions'
import { BuildOptions } from 'esbuild-azure-functions'
Use 'import type' to avoid runtime errors in TypeScript.
Version
import { version } from 'esbuild-azure-functions/package.json'
Library version is not re-exported from the main entry.

Shows basic build and watch mode for Azure Functions using esbuild-azure-functions.

import { build } from 'esbuild-azure-functions'; // Build all functions in the 'functions' directory build({ entryPoints: ['functions/**/*.ts'], outdir: 'dist/functions', platform: 'node', target: 'node14', bundle: true, minify: true, sourcemap: true, }).catch((err) => { console.error('Build failed:', err); process.exit(1); }); // For watch mode, pass watch: true build({ entryPoints: ['functions/**/*.ts'], outdir: 'dist/functions', watch: true, }).catch((err) => { console.error('Build failed:', err); process.exit(1); });
esbuild-azure-functions --version
Debug
Known issues
breakingVersion 2.0.0 updated esbuild peer dependency to v0.17.5, which may break custom esbuild plugins or configurations.
fix
Ensure your project's esbuild version is >=0.17.5 and update any custom plugins accordingly.
affects: >=2.0.0
breakingIn v2.0.0, the package switched to ESM-only, breaking CommonJS require() calls.
fix
Use 'import' syntax or set 'type':'module' in package.json.
affects: >=2.0.0
gotchaThe 'watch' option expects a boolean; passing an object or string may silently fail or be ignored.
fix
Set watch: true to enable watch mode. Custom watchers are not supported.
affects: >=1.0.0
gotchaThe library does not automatically include Azure Functions runtime dependencies; you must bundle them explicitly or rely on the Azure Functions host.
fix
Define external dependencies in esbuild options (e.g., external: ['@azure/functions']) to exclude from bundle.
affects: >=1.0.0
deprecatedVersion 1.x is no longer maintained and lacks ESM support.
fix
Upgrade to v2.0.0 or later.
affects: <2.0.0
Errors
Common errors & fixes
Error: You need to provide at least one entry point
No entryPoints specified in the build options object.
fix
Add an 'entryPoints' array to the build options, e.g., entryPoints: ['functions/**/*.ts'].
TypeError: esbuild_azure_functions_1.build is not a function
Using CommonJS require() on an ESM-only module.
fix
Switch to 'import { build } from 'esbuild-azure-functions'' and ensure your project uses ESM.
Could not resolve '@azure/functions'
The Azure Functions npm package is not installed or is not marked as external.
fix
Add '@azure/functions' to the 'external' list in esbuild options, or install it and bundle it.
Invalid option 'watch': expected a boolean
watch parameter was set to a non-boolean value like a string or object.
fix
Set watch: true or watch: false explicitly.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency for the bundling functionality
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
esbuild-azure-functions — npm install esbuild-azure-functions · libregistry