0.10.0 โข Published 6 months ago
cffc v0.10.0
CloudFront Functions Compiler (cffc)
cffc is a specialized TypeScript compiler extension that enables seamless development of CloudFront Functions using Typescript.
Amazon CloudFront Functions have strict requirements cffc extends the official TypeScript compiler (tsc
) with:
- ๐ Automatic export/import transformation
Features โจ
- ๐ TSC Extensions - Full TypeScript support with CloudFront-specific transforms
- ๐ซ noExport - Remove all export declarations
- ๐ Import Conversion - Transform ES imports to CommonJS
require()
- ๐งผ Module Cleanup - Remove
__esModule
markers andmodule.exports
Installation ๐ฆ
# Global installation
npm install -g cffc
# Local project installation
npm install --save-dev cffc
Usage
cffc -p tsconfig.cfFn.json
Flag | Description |
---|---|
-p | Path to tsconfig.json (default: tsconfig.json) |
--export | Disables export removal and keeps standard module behavior (ESM/CJS intact) |
Idea
This tool extends the TypeScript compiler (tsc) to convert modern TypeScript code into CloudFront-compatible JavaScript. It works in two main steps:
- Convert to ESNext: First, it compiles TypeScript into ESNext JavaScript, preserving modern syntax like import/export.
- Rewrite Syntax: Then, it applies custom transformations to rewrite the code:
- Converts import โ require()
- Removes export and module.exports
- Cleans up __esModule markers
- Strips unnecessary runtime code
This ensures the output is compatible with CloudFront Functions' strict ES5 runtime while maintaining a modern development workflow.