Setup
Pre-requisites
The cf-functions CLI tool uses the AWS SDK and therefore requires AWS account credentials configured on the machine in use.
Installation
yarn add --dev cf-functions ts-node typescript
Configuration
ESM
This package is pure ESM, meaning you must use
ESM when setting up your project too. Ensure the package.json in your project has module
for type.
// package.json
{
"type": "module",
...
}
Typescript
To allow ESM support, set the module to NodeNext
as per below. It's also recommended to set the target to es5
as that
is the closest Ecmascript version to the CloudFront JS runtime.
// tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "NodeNext",
...
},
...
}
cf-functions.ts
A configuration file named cf-functions.ts
containing project configuration is required. The
default location for the config file is the current working directory at runtime.