Skip to content

GatsbyJS with Firebase - WebpackError: ReferenceError: IDBIndex is not defined #2946

@olafsulich

Description

@olafsulich

[REQUIRED] Describe your environment

  • Operating System version: MacOS 10.14.6
  • Browser version: Chrome Version 77.0.3865.90 (Official Build) (64-bit)
  • Firebase SDK version: 7.13.1
  • Firebase Product: (auth, firestore, storage, functions,hosting)

[REQUIRED] Describe the problem

Steps to reproduce:

Gatsby.js cannot build the final app.js file due to issue in any of the firebase packages.
I have read this issue: #2222, but it don't work in my case, maybe I'm doing something wrong...
I have exacly the same issue as in the above post.

Relevant Code:

Error in the console:

WebpackError: ReferenceError: IDBIndex is not defined
  
  - idb.mjs:87 Module../node_modules/idb/lib/idb.mjs
    node_modules/idb/lib/idb.mjs:87:1
  
  - index.esm.js:1 Module../node_modules/@firebase/installations/dist/index.esm.js
    node_modules/@firebase/installations/dist/index.esm.js:1:1
  
  - index.esm.js:1 Module../node_modules/@firebase/analytics/dist/index.esm.js
    node_modules/@firebase/analytics/dist/index.esm.js:1:1
  
  - index.esm.js:1 Module../node_modules/firebase/analytics/dist/index.esm.js
    node_modules/firebase/analytics/dist/index.esm.js:1:1
  
  - index.ts:1 Module../src/firebase/index.ts
    src/firebase/index.ts:1:1
  
  - index.esm.js:32 emit
    node_modules/@firebase/analytics/dist/index.esm.js:32:1

Gatsby-config:

exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
  if (stage === 'build-html') {
    actions.setWebpackConfig({
      externals: getConfig().externals.concat(function(_context, request, callback) {
        if (/^(react-)?firebase(.*)/.test(request)) {
          return callback(null, `umd ${request}`);
        }
        callback();
      }),
    });
  }
};

firebase index file

imports....

firebase.initializeApp(firebaseConfig);
export const firestore = firebase.firestore();
export const auth = firebase.auth();
export const storage = firebase.storage();

Project repo: https://github.com/olafsulich/Projecty

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions