0.10.0 โ€ข Published 6 months ago

cffc v0.10.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

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 and module.exports

Installation ๐Ÿ“ฆ

# Global installation
npm install -g cffc

# Local project installation
npm install --save-dev cffc

Usage

cffc -p tsconfig.cfFn.json
FlagDescription
-pPath to tsconfig.json (default: tsconfig.json)
--exportDisables 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:

  1. Convert to ESNext: First, it compiles TypeScript into ESNext JavaScript, preserving modern syntax like import/export.
  2. 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.

0.10.0

6 months ago

1.1.0

6 months ago