Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BeeeQueue/esbuild-cf-functions-plugin
🔧 A plugin to configure ESBuild for building code compatible with CloudFront Functions
https://github.com/BeeeQueue/esbuild-cf-functions-plugin
Last synced: 3 months ago
JSON representation
🔧 A plugin to configure ESBuild for building code compatible with CloudFront Functions
- Host: GitHub
- URL: https://github.com/BeeeQueue/esbuild-cf-functions-plugin
- Owner: BeeeQueue
- Created: 2022-06-19T17:19:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T04:01:27.000Z (7 months ago)
- Last Synced: 2024-05-01T13:56:31.183Z (7 months ago)
- Language: TypeScript
- Size: 778 KB
- Stars: 14
- Watchers: 3
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-esbuild - esbuild-cf-functions-plugin
README
# `esbuild-cf-functions-plugin`
[![npm](https://img.shields.io/npm/v/esbuild-cf-functions-plugin)](https://www.npmjs.com/package/esbuild-cf-functions-plugin)
![node-current](https://img.shields.io/node/v/esbuild-cf-functions-plugin)
![esbuild-current](https://img.shields.io/badge/esbuild->=0.14.46-green)
[![Codecov](https://img.shields.io/codecov/c/github/BeeeQueue/esbuild-cf-functions-plugin?token=S8W0PQDUQ1)](https://app.codecov.io/github/BeeeQueue/esbuild-cf-functions-plugin)This plugin configures ESBuild for building code [compatible][runtime] with [CloudFront Functions][cf-functions].
As can be seen in the documentation, CloudFront Functions do not run on Node, but on AWS's custom JS runtime.
According to them, it
> ... is compliant with ECMAScript (ES) version 5.1 and also supports some features of ES versions 6 through 9.
This plugin does its best to enable and disable transpiling features as the documentation says is available for the [v1 runtime][runtime] and [v2 runtime][runtime-v2]. By default the v1 runtime is assumed.
**Check out the [example](./example)!**
## Usage
Installation
```shell
npm i -D esbuild-cf-functions-plugin
``````shell
pnpm i -D esbuild-cf-functions-plugin
``````shell
yarn add -D esbuild-cf-functions-plugin
``````js
// build.mjs
import { build } from "esbuild"
import { CloudFrontFunctionsPlugin } from "esbuild-cf-functions-plugin"void build({
entryPoints: ["src/index.ts"],
outdir: "dist",minify: true,
logLevel: "info",plugins: [CloudFrontFunctionsPlugin()],
})
```To enable v2 runtime features:
```js
plugins: [CloudFrontFunctionsPlugin({ runtimeVersion: 2 })],
```_The plugin overrides the `format` and `target` options, unless I did something wrong._
[cf-functions]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-javascript-runtime-features.html
[runtime]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-javascript-runtime-features.html
[runtime-v2]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/functions-javascript-runtime-20.html