Registry / aws / esbuild-cf-functions-plugin

esbuild-cf-functions-plugin

JSON →
library1.1.2jsnpmunverified

An esbuild plugin (v1.1.2, active development) that automatically configures bundling for AWS CloudFront Functions, supporting both v1 (ES5.1+) and v2 (ES2020+) runtimes. It sets the correct esbuild target, format (ES modules), and enables/disables features per runtime constraints. Requires Node >=18 and esbuild >=0.14.46. Differentiators: handles edge-case runtime polyfills and feature toggling that manual configs often miss, and outputs minimal ESM-compatible bundles.

npm install esbuild-cf-functions-plugin
INSTALL
IMPORT
SIG · ESBUILD-CF-FUNCTIO
E
esbuild-cf-functions-plugin
awsjavascriptv1.1.2
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.

CloudFrontFunctionsPlugin
import { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin'
const CloudFrontFunctionsPlugin = require('esbuild-cf-functions-plugin')
The package exports a single named function. CommonJS require works in Node >=18 but defaults to ESM.
default
import { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin'
import CloudFrontFunctionsPlugin from 'esbuild-cf-functions-plugin'
There is no default export. Use named import.
CloudFrontFunctionsPluginOptions
type CloudFrontFunctionsPluginOptions = { runtimeVersion?: 1 | 2 }
TypeScript type available at the same path; not directly exported as value.

Build a CloudFront Function-compatible bundle from src/index.js using default v1 runtime.

import { build } from 'esbuild'; import { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin'; build({ entryPoints: ['src/index.js'], outdir: 'dist', bundle: true, minify: true, plugins: [CloudFrontFunctionsPlugin()], }).catch(() => process.exit(1));
Debug
Known issues
breakingNode <18 no longer supported since v1.0.0
fix
Upgrade Node.js to >=18 or pin to v0.2.x
affects: <1.0.0
breakingesbuild peer dependency minimum raised to >=0.14.46 in v0.2.2
fix
Update esbuild to >=0.14.46
affects: <0.2.2
gotchaPlugin overrides format and target options – custom values will be ignored
fix
Rely on plugin to set these correctly; do not specify format/target in esbuild config
affects: >=0.1.0
gotchaOutput format is always ESM (esmodules) – cannot output CommonJS
fix
Ensure CloudFront Functions runtime supports ES modules (v2) or adapt code accordingly
affects: >=0.1.1
deprecatedv1 runtime (default) may be phased out by AWS; new functions should use v2
fix
Pass { runtimeVersion: 2 } to CloudFrontFunctionsPlugin for ES2020+ features
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'esbuild-cf-functions-plugin'
Package not installed or not added to devDependencies
fix
npm install -D esbuild-cf-functions-plugin
The esbuild plugins must be an array of objects
CloudFrontFunctionsPlugin() was called without parentheses or returned undefined
fix
Ensure you invoke the factory: plugins: [CloudFrontFunctionsPlugin()]
Target environment is not a supported ECMAScript version
Custom target set alongside plugin overrides
fix
Remove target from esbuild config; plugin sets correct value
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
esbuildoptionalPeer dependency - required as plugin hooks into esbuild builds
Agent activity
11 hits · last 30 days
node
10
Amazon
1
Resources
esbuild-cf-functions-plugin — npm install esbuild-cf-functions-plugin · libregistry