Bundle
Creates and manages bundled JavaScript/TypeScript files using esbuild. Supports various output formats, sourcemaps, and platform targets.Properties
string
required
Entry point for the bundle. Path to the source file to bundle (e.g., “src/handler.ts”).
string
Output directory for the bundle. Directory where the bundled file will be written.
string
Output filename for the bundle. Full path to the output file, overrides outdir if specified.
'iife' | 'cjs' | 'esm'
Bundle format:
iife: Immediately Invoked Function Expressioncjs: CommonJSesm: ECMAScript Modules
string | string[]
Target environment. Examples: ‘node16’, ‘node18’, ‘es2020’
boolean
Whether to minify the output.
boolean | 'inline' | 'external' | 'both'
Whether to generate sourcemaps:
inline: Include sourcemap in bundleexternal: Generate separate .map fileboth: Generate both inline and external
string[]
External packages to exclude from bundle. Array of package names to mark as external.
'browser' | 'node' | 'neutral'
Platform to target:
browser: Browser environmentnode: Node.js environmentneutral: Platform-agnostic
Returns
string
Path to the bundled file. Absolute or relative path to the generated bundle.
string
SHA-256 hash of the bundle contents. Used for cache busting and content verification.
string
The content of the bundle (the .js or .mjs file).