Giter Site home page Giter Site logo

jthegedus / firebase-functions-babel-example Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 3.0 76 KB

Use ES6+ features with Babel to target the correct environment for Cloud Functions for Firebase

License: Other

JavaScript 100.00%
babel preset-env firebase-functions firebase cloud-functions

firebase-functions-babel-example's Introduction

THIS REPO HAS BEEN MOVED

This example has been merged into my blog-examples repo. This repo will no longer be updated.


Firebase Functions with Babel config to target the correct Execution Environment

styled with prettier

Use Babel to target the correct execution environment for Cloud Functions for Firebase and use modern languages features (ES6+) to develop.

Here is the accompanying Medium post;

TLDR;

Develop your Cloud Functions in a different directory to the default ./functions directory. I suggest ./firebaseFunctions. Then use @babel/core, @babel/cli and babel/preset-env with some npm scripts to compile to the Cloud Functions server runtime of NodeJS v6.11.5. The output directory is the default ./functions directory which is created on compilation in the deploy step (yarn deploy).

Installation

git clone https://github.com/jthegedus/firebase-functions-babel-example
cd firebase-functions-babel-example
yarn install

Login to the Firebase CLI

If you are using a global install of the firebase-tools CLI then skip to the Deploy to Firebase step.

Login to the local firebase-tools:

yarn login

Local Testing

yarn serve

NB: Our code must run through the compilation step each time it is changed, even when hosted locally. We therefore lose the ability of firebase serve reserving our function when code is changed, as it's changed in another file and dir.

Deploy to Firebase

yarn deploy

N.B.: You will need to connect the project to your Firebase project. Edit the name in .firebaserc

A note on Code Compatibility

Everything was tested on Ubuntu 17.04. If you wish for Windows native support please submit an issue so we can work on a Windows branch. Please report any macOS errors as I do not have access to a device to test. My development environment can be found here.

firebase-functions-babel-example's People

Contributors

jthegedus avatar mwarger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

firebase-functions-babel-example's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.