Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Create & test Firebase Cloud Functions in TypeScript

License

NotificationsYou must be signed in to change notification settings

robisim74/firebase-functions-typescript-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Create & test Firebase Cloud Functions in TypeScript

This starter allows you to create & testFirebase Cloud Functions inTypeScript.

Get theChangelog.

Contents

1 Project structure

  • 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
  • .firebaserc: Firebase projects

2 Customizing

  1. UpdateFirebase CLI.

  2. Update.firebaserc with yourproject-id.

  3. Add your Firebase Functions toindex.ts and create different files for each one.

  4. Update inrollup.config.js file external dependencies with those that actually you use to build the ES bundle.

  5. Create unit tests intests folder.

3 Testing

The following command runs unit tests usingMocha that are in thetests folder:

npmtest

4 Building

Development

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

Production

The following command:

npm run build

createslib folder with the file of distribution:

└── functions    └──lib        └── index.js

5 Publishing

npm run deploy

6 What it is important to know

  1. Node.js

    The engine inpackage.json is set toNode.js 16

  2. ES 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 modules

  3. Bundling 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

License

MIT

About

Create & test Firebase Cloud Functions in TypeScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp