arc-plugin-esbuild
raw JSON → 3.0.0 verified Fri May 01 auth: no javascript
A plugin for the Architect serverless framework that uses esbuild to bundle Lambda functions with dependency inclusion and tree-shaking. Version 3.0.0 introduces esbuild as the runtime, which is a breaking change requiring explicit runtime configuration. Active development with regular releases, targeting Node 14.13+ or 16+. Ships TypeScript types. Differentiator: integrates directly into Architect's `app.arc` config, supports config files for esbuild plugins, and allows custom build directories.
Common errors
error Error: [esbuild] Plugin arc-plugin-esbuild: buildDirectory must be set before runtime. Available: 'src' ↓
cause Missing or misconfigured buildDirectory in app.arc @esbuild pragma.
fix
Add
@esbuild
buildDirectory src to app.arc. error TypeError: Cannot destructure property 'get' of 'undefined' or null. ↓
cause Missing @http pragma or incorrect indentation in app.arc.
fix
Ensure app.arc has proper pragmas and indentation:
@http
get /. error Error: 'esbuild' is not in the npm registry. ↓
cause Missing peer dependency esbuild.
fix
Run
npm install esbuild --save-dev. Warnings
breaking v3.0.0 changed esbuild from a build step to the runtime. You must set @aws runtime esbuild in your app.arc file. ↓
fix Add `@aws
runtime esbuild` to app.arc.
deprecated The `plugin` build method is deprecated in favor of the new runtime mode. ↓
fix Migrate to runtime mode by setting @aws runtime esbuild.
gotcha Hydration (shared code) is not supported with custom runtimes. You must inline all shared code or use a build directory. ↓
fix Set `buildDirectory src` in @esbuild to avoid hydration issues.
gotcha The `external` option defaults to `aws-sdk`. If you need other external packages, you must list them explicitly. ↓
fix Add `external @prisma/client aws-sdk` to @esbuild pragma.
Install
npm install arc-plugin-esbuild yarn add arc-plugin-esbuild pnpm add arc-plugin-esbuild Imports
- arc-plugin-esbuild wrong
import in JavaScriptcorrectAdd to app.arc: @plugins arc-plugin-esbuild
Quickstart
npm i --save-dev arc-plugin-esbuild
touch app.arc
echo '@app
myapp
@aws
runtime esbuild
@http
get /
@plugins
arc-plugin-esbuild' > app.arc
# Create a handler file
mkdir -p src/http/get-index
touch src/http/get-index/index.ts
# index.ts content:
export async function handler(req: any) {
return { statusCode: 200, body: 'Hello!' };
}