Skip to content

Instantly share code, notes, and snippets.

@jthegedus
Last active November 29, 2017 11:46
Show Gist options
  • Save jthegedus/f5f912e124a2d07cf0b3f5850dd453da to your computer and use it in GitHub Desktop.
Save jthegedus/f5f912e124a2d07cf0b3f5850dd453da to your computer and use it in GitHub Desktop.
ES6+ in Cloud Functions for Firebase - preset-2015 with ES module syntax
// input - using ES module syntax
import * as functions from 'firebase-functions';
export let helloWorld = functions.https.onRequest((req, res) => {
let world = `from Babelified Cloud Functions!`;
res.status(200).send(`Hello ${world}`);
})
// Babel output - with Babel REPL settings:
// * prettify
// * preset-es2015
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.helloWorld = undefined;
var _firebaseFunctions = require("firebase-functions");
var functions = _interopRequireWildcard(_firebaseFunctions);
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key))
newObj[key] = obj[key];
}
}
newObj.default = obj;
return newObj;
}
}
var helloWorld = (exports.helloWorld = functions.https.onRequest(function(req, res) {
var world = "from Babelified Cloud Functions!";
res.status(200).send("Hello " + world);
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment