{"id":25265,"library":"esbuild-cf-functions-plugin","title":"esbuild CloudFront Functions Plugin","description":"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.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/beeequeue/esbuild-cf-functions-plugin","tags":["javascript","aws","cloudfront","functions","function","lambda","esbuild","compiler","bundler","typescript"],"install":[{"cmd":"npm install esbuild-cf-functions-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-cf-functions-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-cf-functions-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency - required as plugin hooks into esbuild builds","package":"esbuild","optional":true}],"imports":[{"note":"The package exports a single named function. CommonJS require works in Node >=18 but defaults to ESM.","wrong":"const CloudFrontFunctionsPlugin = require('esbuild-cf-functions-plugin')","symbol":"CloudFrontFunctionsPlugin","correct":"import { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin'"},{"note":"There is no default export. Use named import.","wrong":"import CloudFrontFunctionsPlugin from 'esbuild-cf-functions-plugin'","symbol":"default","correct":"import { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin'"},{"note":"TypeScript type available at the same path; not directly exported as value.","wrong":"","symbol":"CloudFrontFunctionsPluginOptions","correct":"type CloudFrontFunctionsPluginOptions = { runtimeVersion?: 1 | 2 }"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { CloudFrontFunctionsPlugin } from 'esbuild-cf-functions-plugin';\n\nbuild({\n  entryPoints: ['src/index.js'],\n  outdir: 'dist',\n  bundle: true,\n  minify: true,\n  plugins: [CloudFrontFunctionsPlugin()],\n}).catch(() => process.exit(1));","lang":"typescript","description":"Build a CloudFront Function-compatible bundle from src/index.js using default v1 runtime."},"warnings":[{"fix":"Upgrade Node.js to >=18 or pin to v0.2.x","message":"Node <18 no longer supported since v1.0.0","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Update esbuild to >=0.14.46","message":"esbuild peer dependency minimum raised to >=0.14.46 in v0.2.2","severity":"breaking","affected_versions":"<0.2.2"},{"fix":"Rely on plugin to set these correctly; do not specify format/target in esbuild config","message":"Plugin overrides format and target options – custom values will be ignored","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure CloudFront Functions runtime supports ES modules (v2) or adapt code accordingly","message":"Output format is always ESM (esmodules) – cannot output CommonJS","severity":"gotcha","affected_versions":">=0.1.1"},{"fix":"Pass { runtimeVersion: 2 } to CloudFrontFunctionsPlugin for ES2020+ features","message":"v1 runtime (default) may be phased out by AWS; new functions should use v2","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install -D esbuild-cf-functions-plugin","cause":"Package not installed or not added to devDependencies","error":"Cannot find module 'esbuild-cf-functions-plugin'"},{"fix":"Ensure you invoke the factory: plugins: [CloudFrontFunctionsPlugin()]","cause":"CloudFrontFunctionsPlugin() was called without parentheses or returned undefined","error":"The esbuild plugins must be an array of objects"},{"fix":"Remove target from esbuild config; plugin sets correct value","cause":"Custom target set alongside plugin overrides","error":"Target environment is not a supported ECMAScript version"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}