- Notifications
You must be signed in to change notification settings - Fork28
Create & test Firebase Cloud Functions in TypeScript
License
robisim74/firebase-functions-typescript-starter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Create & test Firebase Cloud Functions in TypeScript
This starter allows you to create & testFirebase Cloud Functions inTypeScript.
Get theChangelog.
- functions:
- src folder for the Functions
- index.ts entry point for all your Firebase Functions
- tests folder for theMocha tests
- package.jsonnpm options
- rollup.config.jsRollup configuration for building the ES bundle
- tsconfig.jsonTypeScript compiler options
- .mocharc.jsonMocha options
- .eslintrc.jsonESLint configuration
- src folder for the Functions
- .firebaserc: Firebase projects
UpdateFirebase CLI.
Update
.firebaserc
with yourproject-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 usingMocha that are in thetests
folder:
npmtest
Starttsc compiler withwatch option:
npm run build:dev
Start the emulatorfirebase 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
createslib
folder with the file of distribution:
└── functions └──lib └── index.js
npm run deploy
Node.js
The engine in
package.json
is set toNode.js 16ES Modules
Node.js 16 supports ES Modules: so you have
"type": "module"
inpackage.json
,format: 'es'
inrollup.config.js
andtsconfig.js
used bytsc compiler targets ES2021 with ES2020 modulesBundling withRollup
Firebase Cloud Functions do not require the deployment of a single bundle. In any case the building withRollup offers some advantages:
- Tree shaking of unused code
- No request for other files at runtime
MIT
About
Create & test Firebase Cloud Functions in TypeScript
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.