You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 4, 2018. It is now read-only.
When skipping the es6 transpilation step and just using exports.* in the functions/ dir using 6.11.* compatible code the deploys work just fine with the nextJS function. However, when including the transpilation step with es6 imports, the deploys error out:
⚠ functions[nextJS]: Deploy Error: Function load error: Error: cannot communicate with function.
⚠ functions[helloWorld]: Deploy Error: Function load error: Error: cannot communicate with function.
⚠ functions[helloWorld2]: Deploy Error: Function load error: Error: cannot communicate with function.
Error: Functions did not deploy properly.
error Command failed with exit code 1.
So this code works:
constfunctions=require('firebase-functions');constnext=require('next');constdev=process.env.NODE_ENV!=='production';constapp=next({ dev,conf: {distDir: 'next'}});consthandle=app.getRequestHandler();exports.helloWorld=functions.https.onRequest((req,res)=>{constworld=`from ES6 in Cloud Functions!`;res.status(200).send('Hello'+world);});exports.helloWorld2=functions.https.onRequest((req,res)=>{constworld=`!!!!!!!!`;res.status(200).send('Hello'+world);});exports.nextJS=functions.https.onRequest((req,res)=>{console.log('File: '+req.originalUrl);// log the page.js file that is being requestedreturnapp.prepare().then(()=>handle(req,res));});
But this code...
import*asfunctionsfrom'firebase-functions';importnextfrom'next';constdev=process.env.NODE_ENV!=='production';constapp=next({ dev,conf: {distDir: 'next'}});consthandle=app.getRequestHandler();exportconsthelloWorld=functions.https.onRequest((req,res)=>{constworld=`from ES6 in Cloud Functions!`;res.status(200).send(`Hello ${world}`);});exportconsthelloWorld2=functions.https.onRequest((req,res)=>{constworld=`!!!!!!!!`;res.status(200).send(`Hello ${world}`);});exportconstnextJS=functions.https.onRequest((req,res)=>{console.log('File: '+req.originalUrl);// log the page.js file that is being requestedreturnapp.prepare().then(()=>handle(req,res));});
When transpiled doesn't work:
'use strict';Object.defineProperty(exports,"__esModule",{value: true});exports.nextJS=exports.helloWorld2=exports.helloWorld=undefined;var_firebaseFunctions=require('firebase-functions');varfunctions=_interopRequireWildcard(_firebaseFunctions);var_next=require('next');var_next2=_interopRequireDefault(_next);function_interopRequireDefault(obj){returnobj&&obj.__esModule ? obj : {default: obj};}function_interopRequireWildcard(obj){if(obj&&obj.__esModule){returnobj;}else{varnewObj={};if(obj!=null){for(varkeyinobj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key];}}newObj.default=obj;returnnewObj;}}vardev=process.env.NODE_ENV!=='production';varapp=(0,_next2.default)({dev: dev,conf: {distDir: 'next'}});varhandle=app.getRequestHandler();varhelloWorld=exports.helloWorld=functions.https.onRequest(function(req,res){varworld='from ES6 in Cloud Functions!';res.status(200).send('Hello '+world);});varhelloWorld2=exports.helloWorld2=functions.https.onRequest(function(req,res){varworld='!!!!!!!!';res.status(200).send('Hello '+world);});varnextJS=exports.nextJS=functions.https.onRequest(function(req,res){console.log('File: '+req.originalUrl);// log the page.js file that is being requestedreturnapp.prepare().then(function(){returnhandle(req,res);});});
Link to repo
When skipping the es6 transpilation step and just using exports.* in the functions/ dir using 6.11.* compatible code the deploys work just fine with the nextJS function. However, when including the transpilation step with es6 imports, the deploys error out:
So this code works:
But this code...
When transpiled doesn't work: