Ahh figured it out. To use ES6 features like import and const, and even ES7 features like await and async, use Typescript by renaming index.js to index.ts.
Here's my index.ts:
import * as functions from 'firebase-functions';
export const helloWorld = functions.https.onRequest((req, resp) => {
resp.send("Hello from Firebase!");
});
I was also prompted by Atom to generate a functions/tsconfig.json file. I'm not sure this was necessary, but here's what was generated:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": false,
"noImplicitAny": false,
"noImplicitUseStrict": false,
"removeComments": true,
"noLib": false,
"preserveConstEnums": true,
"suppressImplicitAnyIndexErrors": true,
"lib": ["es2015", "es2015.promise"]
},
"exclude": [
"node_modules",
"typings/browser",
"typings/browser.d.ts"
],
"compileOnSave": true,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Here's the output generated by firebase deploy --only functions:
=== Deploying to 'PROJECTNAME'...
i deploying functions
i functions: ensuring necessary APIs are enabled...
i runtimeconfig: ensuring necessary APIs are enabled...
✔ runtimeconfig: all necessary APIs are enabled
✔ functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (1.53 KB) for uploading
✔ functions: functions folder uploaded successfully
i starting release process (may take several minutes)...
i functions: creating function helloWorld...
✔ functions[helloWorld]: Successful create operation.
✔ functions: all functions deployed successfully!
✔ Deploy complete!
Project Console: https://console.firebase.google.com/project/PROJECTNAME/overview
Function URL (helloWorld): https://us-central1-PROJECTNAME.cloudfunctions.net/helloWorld