When I try to deploy my functions, firebase complains about this:
const admin = require('firebase-admin');
const functions = require('firebase-functions');
const C = require('../both/constants.js');
exports.myFunc = functions.database.ref('aRef').onCreate((event) => {
// blah blah
}
Error: Error parsing triggers: Cannot find module '../both/constants.js'
But not this:
const admin = require('firebase-admin');
const functions = require('firebase-functions');
// This is the invite that goes to organizations.
exports.myFunc = functions.database.ref('aRef').onCreate((event) => {
const C = require('../both/constants.js');
}
Why is that?
Update: It would appear this happens because the function will not look for the dependency until runtime. This is of course an issue because the dependencies are still needed. I should mention my project looks like this:
both
constants.js
functions
index.js
myFunc.js
Update 2 Now that I'm moving my stack entirely to Firebase functions, I got back to working on this issue again. The module needs to be published for it to work within the function. Just FYI for anyone who happens upon this psot.