Create & test Firebase Cloud Functions in TypeScript
MIT License
Create & test Firebase Cloud Functions in TypeScript
This starter allows you to create & test Firebase Cloud Functions in TypeScript.
Get the Changelog.
Update Firebase CLI.
Update .firebaserc
with your project-id
.
Add your Firebase Functions to index.ts
and create different files for each one.
Update in rollup.config.js
file external dependencies with those that actually you use to build the ES bundle.
Create unit tests in tests
folder.
The following command runs unit tests using Mocha that are in the tests
folder:
npm test
Start tsc compiler with watch option:
npm run build:dev
Start the emulator firebase emulators:start --only functions
npm run serve:dev
For the other supported emulators, please refer to the official documentation: Run Functions Locally
The following command:
npm run build
creates lib
folder with the file of distribution:
└── functions
└──lib
└── index.js
npm run deploy
Node.js
The engine in package.json
is set to Node.js 16
ES Modules
Node.js 16 supports ES Modules: so you have "type": "module"
in package.json
, format: 'es'
in rollup.config.js
and tsconfig.js
used by tsc compiler targets ES2021 with ES2020 modules
Bundling with Rollup
Firebase Cloud Functions do not require the deployment of a single bundle. In any case the building with Rollup offers some advantages:
MIT