Use TypeScript with Firebase Cloud Functions
Key Takeaways
This video teaches how to use TypeScript with Firebase Cloud Functions and modularize them with Webpack for easier debugging
Full Transcript
when we write firebase cloud functions we normally do it in plain JavaScript but this tends to make them hard to debug what if we could actually write them in typescript and also throw on web pack to make them a little more modular in this quick lesson I'm going to show you how to set up your cloud function environment for typescript and web pack and then we'll deploy a few cloud functions to firebase I first want to point out that there's an article on medium that was the main inspiration for this video so I'll add a link to that the description and if you're brand new to cloud functions I recommend checking out any of the blue videos on my channel which are specifically focused on firebase cloud functions so to get started I'm assuming you have an existing project that you're working on and you'll bring up the command line and run firebase and knit functions then select all the default options during that project setup this is going to create a new directory in the root of the project called functions and that's an isolated node environment where we can build our cloud functions so the next step is to CD into that directory and then we'll create a new directory called source and we'll put a file in there called index TS instead of index j s then we can go ahead and remove the index j s file for now web pack will actually generate the index.js file automatically based on our underlying typescript code and that's the file that actually gets deployed the firebase now let's open up the package JSON file then we can install typescript and web pack and we'll specify them only for that development environment so your final node environment should look something like this and we can add a TS config file nothing really special here you can go with the default options and customize it any way you want then the last step is to create the web pack config this will tell web pack how to compile our type script to a single index.js file that can be deployed to firebase check out the link in the description for more detail on this code so now we can actually start building cloud functions we can do this by creating directories inside the source directory based on that concerns that we want to separate in this example I'm separating my email cloud functions from my images cloud functions so now we can start writing cloud functions just like we normally would the only differences we can use typescript and we also use the webpack import syntax if you've developed angular apps before this should look very familiar because it's the exact approach used by the angular CLI in this example I just created a couple of cloud functions that don't do anything named update image and resize image and just for this example we'll go ahead and add one more useless cloud function in that email directory so now we need to register these functions in the main indexed ES file in the source directory this process is very similar to an NG module we just import the functions that we want to deploy and then register that in this file any constant that's exported in this file will be picked up by web pack and that'll be included in our main index CAS file that gets deployed so now that we have our functions defined we can go ahead and deploy them there's only one extra step we just have to call the web pack command which will compile the code into that index.js file if we check it out we can see it's mostly a bunch of web pack code but our actual functions that we wrote are embedded in there and the final step is to deploy a firebase by running firebase deploy only functions and after a few seconds we should get a confirmation on the command line and if we go into the firebase console we should see these three functions there as well overall this gives you a much more easy to maintain and debug environment for writing cloud functions that's it for typescript and firebase cloud functions if this video helped you please like and subscribe and if you want help building your own custom cloud functions consider becoming a pro member at angular firebase com thanks for watching and I'll see you soon you [Applause] [Music]
Original Description
Learn how to make your Firebase Cloud Functions easier to debug with TypeScript and modular with Webpack.
Medium Article: https://medium.com/netscape/firebase-cloud-functions-with-typescript-and-webpack-7781c882a05b
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Fireship · Fireship · 38 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
▶
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Angular 4 Development and Production Environments with Firebase
Fireship
OAuth with Angular and Firebase Tutorial
Fireship
Anonymous Authentication with Angular and Firebase - Lazy Registration
Fireship
Angular Router Guards for Firebase Users
Fireship
Angular Firebase CRUD App with NoSQL Database Tutorial
Fireship
Upload Files from Angular to Firebase Storage
Fireship
How to Deploy an Angular App to Firebase Hosting
Fireship
Sharing Data between Components in Angular
Fireship
Loading Spinners for Asynchronous Firebase Data
Fireship
Angular 4 Transactional Email with Google Firebase Cloud Functions
Fireship
Firebase Database Rules Tutorial
Fireship
Autocomplete Search with Angular4 and Firebase
Fireship
Reddit Inspired Upvoting System with Angular and Firebase NoSQL
Fireship
Angular Drag-and-Drop File Uploads to Firebase Storage
Fireship
Text Translation with Firebase Cloud Functions onWrite and Angular 4
Fireship
Custom Usernames with Firebase Authentication
Fireship
Twitter-Inspired Follow Unfollow Feature with Firebase and Angular 4
Fireship
Simple Pagination with Firebase and Angular 4
Fireship
How to Connect Firebase Users to their Data - 3 Methods
Fireship
Add Toast Message Notifications to your Angular App
Fireship
Facebook-Inspired Reactions System with Angular and Firebase
Fireship
Learn NgModule in Angular with Examples
Fireship
Lazy Loading Components in Angular 4
Fireship
Stripe Checkout Payments with Angular and Firebase - Part 1
Fireship
Process Stripe Payments with Firebase Cloud Functions - Part 2
Fireship
Selling Digital Content in Angular with Stripe Payments - Part 3
Fireship
Angular 4 Full Text Search with Algolia - Part 1
Fireship
Algolia with Firebase Cloud Functions - Part 2
Fireship
Firebase Phone Authentication in Angular 4
Fireship
Top 7 RxJS Concepts for Angular Developers
Fireship
Learn Angular Animations with 5 Examples
Fireship
Advanced Firebase Data Filtering (Multi-Property)
Fireship
Realtime Maps with Mapbox + Firebase + Angular
Fireship
Angular Reactive Forms with Firebase Database Backend
Fireship
Send Push Notifications in Angular with Firebase Cloud Messaging
Fireship
Top 7 Ways to Debug Angular 4 Apps
Fireship
Infinite Scroll with Angular and Firebase
Fireship
Use TypeScript with Firebase Cloud Functions
Fireship
Realtime Graphs and Charts with Plotly and Firebase
Fireship
Role-Based User Permissions in Firebase
Fireship
User Presence System in Realtime - Online, Offline, Away
Fireship
Location-based Queries with GeoFire and Angular Google Maps
Fireship
Angular ngrx Redux Quick Start Tutorial
Fireship
Angular Ngrx Effects with Firebase Database
Fireship
Progressive Web Apps with Angular
Fireship
Angular Ngrx with Firebase Google OAuth User Authentication
Fireship
RxJS Quick Start with Practical Examples
Fireship
Send SMS Text Messages with Twilio and Firebase
Fireship
Firebase Database Performance Profiling
Fireship
Native Desktop Apps with Angular and Electron
Fireship
Subscription Payments with Stripe, Angular, and Firebase
Fireship
Firestore with AngularFire5 Quick Start Tutorial
Fireship
Angular HTTP Client Quick Start Tutorial
Fireship
Google Sign-In with Firestore Custom User Data
Fireship
Star Review System from Scratch with Firestore + Angular
Fireship
Angular Chatbot with Dialogflow (API.ai)
Fireship
Learn @ngrx/entity and Feature Modules
Fireship
Infinite Scroll Pagination with Firestore
Fireship
Faster Firestore via Data Aggregation
Fireship
Contentful - CMS for Angular Progressive Web Apps
Fireship
Related Reads
📰
📰
📰
📰
How I made a scroll-scrubbed video portfolio fast (Next.js 15 + GSAP + canvas)
Dev.to · Pratham Sharma
5 Reasons HTML Is About to Change Frontend Development
Medium · Programming
5 Reasons HTML Is About to Change Frontend Development
Medium · JavaScript
copilot browser tools make the frontend reviewable
Dev.to · Paulo Victor Leite Lima Gomes
🎓
Tutor Explanation
DeepCamp AI