Firebase-js-sdk: Rollup message outdated when using sdk in node enviroment

Created on 3 Jul 2019  Â·  12Comments  Â·  Source: firebase/firebase-js-sdk

Environment

  • Operating System version: _____
  • Browser version: _____
  • Firebase SDK version: [email protected]
  • Firebase Product: _____ (auth, database, storage, etc)

Problem

When using this sdk (not the admin one) in a node environment the suggested fix is outdated. It suggests for rollup:

If using Rollup, use the rollup-plugin-node-resolve plugin and set "module" to false and "main" to true: https://github.com/rollup/rollup-plugin-node-resolve

However according to the usage on their readme it says that the module and main fields are depreciated and replaced by mainFields. Can we see a update to this error message which uses mainFields

core

Most helpful comment

Solution was to use firebase/app instead of firebase.

Op di 16 jul. 2019 07:31 schreef Cory McArthur notifications@github.com:

Figured it out: Here's what I did to fix it @p3sn
https://github.com/p3sn and @winstonzhao
https://github.com/winstonzhao
Uninstalled all of my @firebase/app, /auth, /firestore, /functions,
/performance packages and ran
npm i firebase
which installed "firebase": "^6.3.0",

Then imported each

import { firebase } from '@firebase/app';import '@firebase/auth';import '@firebase/firestore';import '@firebase/functions';import '@firebase/performance';

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-js-sdk/issues/1938?email_source=notifications&email_token=AAWAKLBCC4PJ7YN55OZPVO3P7VMLXA5CNFSM4H5DROG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7XXYQ#issuecomment-511671266,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWAKLAOOYEQ55BHYDI75VDP7VMLXANCNFSM4H5DROGQ
.

All 12 comments

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

Maybe related, I see this message:

Rollup: Missing Export
'openDb' is not exported by node_modules/@firebase/installations/node_modules/idb/build/idb.js

I'm using StencilJS and Ionic.

Maybe related, I see this message:

Rollup: Missing Export
'openDb' is not exported by node_modules/@firebase/installations/node_modules/idb/build/idb.js

I'm using StencilJS and Ionic.

I'm getting the same error using the same things.

Those are not at all related, I was commenting that the console error message for building the standard firebase sdk in a node/ non-browser environment using rollup needs to be updated. It is not the error that is the problem it is the fact the suggested fix in the error message is outdated.

@p3sn and @winstonzhao did you figure this out? I'm just now seeing this myself. Stencil, Ionic, and Firebase.
Thanks

Figured it out: Here's what I did to fix it @p3sn and @winstonzhao
Uninstalled all of my @firebase/app, /auth, /firestore, /functions, /performance packages and ran
npm i firebase
which installed "firebase": "^6.3.0",

Then imported each

import { firebase } from '@firebase/app';
import '@firebase/auth';
import '@firebase/firestore';
import '@firebase/functions';
import '@firebase/performance';

Then in my stencil.config.ts file:

commonjs: {
    namedExports: {
      // left-hand side can be an absolute path, a path
      // relative to the current directory, or the name
      // of a module in node_modules
      'node_modules/idb/build/idb.js': ['openDb'],
      'node_modules/firebase/dist/index.cjs.js': ['initializeApp', 'firestore']
    }
  },

Figured it out: Here's what I did to fix it @p3sn and @winstonzhao
Uninstalled all of my @firebase/app, /auth, /firestore, /functions, /performance packages and ran
npm i firebase
which installed "firebase": "^6.3.0",

Then imported each

import { firebase } from '@firebase/app';
import '@firebase/auth';
import '@firebase/firestore';
import '@firebase/functions';
import '@firebase/performance';

Then in my stencil.config.ts file:

commonjs: {
    namedExports: {
      // left-hand side can be an absolute path, a path
      // relative to the current directory, or the name
      // of a module in node_modules
      'node_modules/idb/build/idb.js': ['openDb'],
      'node_modules/firebase/dist/index.cjs.js': ['initializeApp', 'firestore']
    }
  },

I did the same after asking on Slack. I didn't have to do the second step.
Also, at work what we do is have a firebase.ts file which just imports all of the auxiliary imports like auth etc. in a single file and export firebase. This way you don't have to include all n lines.

Solution was to use firebase/app instead of firebase.

Op di 16 jul. 2019 07:31 schreef Cory McArthur notifications@github.com:

Figured it out: Here's what I did to fix it @p3sn
https://github.com/p3sn and @winstonzhao
https://github.com/winstonzhao
Uninstalled all of my @firebase/app, /auth, /firestore, /functions,
/performance packages and ran
npm i firebase
which installed "firebase": "^6.3.0",

Then imported each

import { firebase } from '@firebase/app';import '@firebase/auth';import '@firebase/firestore';import '@firebase/functions';import '@firebase/performance';

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/firebase-js-sdk/issues/1938?email_source=notifications&email_token=AAWAKLBCC4PJ7YN55OZPVO3P7VMLXA5CNFSM4H5DROG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7XXYQ#issuecomment-511671266,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWAKLAOOYEQ55BHYDI75VDP7VMLXANCNFSM4H5DROGQ
.

Well, the Rollup warning message is updated: https://github.com/firebase/firebase-js-sdk/pull/1949 and should go into the next release. If anyone's still having problems with the other error (seems to be solved?), feel free to open a separate issue so we can track it.

Warning message fix was released in 6.3.1.

@p3sn and @winstonzhao did you figure this out? I'm just now seeing this myself. Stencil, Ionic, and Firebase.
Thanks

I fixed it by importing firebase/app instead of firebase.

This popped for me today, and I had to make the namedExport path's relative:

commonjs: {
    namedExports: {
      './node_modules/idb/build/idb.js': ['openDb'],
      './node_modules/firebase/dist/index.cjs.js': ['initializeApp', 'firestore']
    }
  },
Was this page helpful?
0 / 5 - 0 ratings