PRAJIN PRAKASH
PRAJIN PRAKASH

Reputation: 1475

How import firebase cloud function config dynamically in NodeJS 14 with `type: module`? [ closed ]

I would like to achieve importing cloud function config dynamically but it won't working as expected.

import config from "firebase-functions";

It works ✔️

const {config} = await import('firebase-functions');

It won't work ❌

also tried the following but won't works.

import * as functions from "firebase-functions"; // function is already using as static import
or 
const functions = await import('firebase-functions');
functions.config ❌// => undefined
functions.auth ✔️
functions.firestore ✔️
//and analytics, app, auth, database, firestore, handler, https, pubsub, remoteConfig, storage, testLab, logger ✔️

Am not getting a way to dynamically import the config import along with function.

Upvotes: 0

Views: 287

Answers (1)

PRAJIN PRAKASH
PRAJIN PRAKASH

Reputation: 1475

Oh finaly it works.

const { default: functions} = await import('firebase-functions');

and

import functions from "firebase-functions";

giving functions.config

Upvotes: 1

Related Questions