2
  1. Summarize the problem: When I merge a commit to Gitlab and run a pipeline, there is a script failure when trying to deploy. more specifically: WebpackError: ReferenceError: __WEBPACK_EXTERNAL_MODULE_firebase_app__ is not defined -The goal of this post is to hopefully get a better understanding of what I am doing wrong here, as I am trying to follow the errors to find the solution on my own, but have not been successful thus far. -The expected result is that, because the pipeline had previously worked up until this point, that it would continue to do so. The strange part about this pipeline failure is that I did not actually install any packages on the merge that caused the failure. I went ahead and updated packages and some previous errors went away (for instance, there was a failure involving the sharp library that has now gone away) but now firebase app has become the focus. The only actual error I saw in the output was WebpackError: ReferenceError: __WEBPACK_EXTERNAL_MODULE_firebase_app__ is not defined followed by ERROR: Job failed: exit code 1

  2. Describe what you've tried: as stated before, I initially thought if I just updated all dependencies, this would help get me a better idea of what was going wrong. I thought I was on the right track when I noticed more progress along the pipeline than before, and there was this issue error (node:260) [DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS] DeprecationWarning: The externals-function should be defined like ({context, request}, cb) => { ... } (Use `node --trace-deprecation ...` to show where the warning was created) so I followed the error message's advice and added curly brackets around context, request in my gatsby-node.js file. That error went away on the next pipeline attempt, but WebpackError: ReferenceError: __WEBPACK_EXTERNAL_MODULE_firebase_app__ is not defined remains

  3. Show some code: I believe the gatsby-node.js file is what is relevant here, so here it is:

exports.onCreateWebpackConfig = ({ stage, actions, getConfig }) => {
  if (stage === 'build-html') {
    actions.setWebpackConfig({
      // Don't bundle modules that reference browser globals such as `window` and `IDBIndex` during SSR.
      // See: https://github.com/gatsbyjs/gatsby/issues/17725
      externals: getConfig().externals.concat(function ({ _context, request }, callback) {
        // Exclude bundling firebase* and react-firebase*
        // These are instead required at runtime.
        if (/^@?(react-)?firebase(.*)/.test(request)) {
          console.log('Excluding bundling of: ' + request);
          return callback(null, 'umd ' + request);
        }
        callback();
      }),
    });
  }
};

I can provide other details if needed, and would appreciate any advice that anyone has to offer. Thanks!

izzy
  • 85
  • 1
  • 7
  • Does this help you? https://stackoverflow.com/questions/61334290/gatsbyjs-with-firebase-webpackerror-referenceerror-idbindex-is-not-defined – Ferran Buireu Mar 14 '21 at 11:28
  • not quite, the build stage is where the error happens, instead of in develop – izzy Mar 14 '21 at 20:43
  • Are you using Gatsby v3? – Ferran Buireu Mar 14 '21 at 20:47
  • yes, I just recently updated to v3 and was reading through their docs here https://www.gatsbyjs.com/docs/reference/release-notes/migrating-from-v2-to-v3/ – izzy Mar 14 '21 at 20:49
  • I've faced also some webpack issues with the v3 (not related to Firebase but similar output message). Hope you find the solution soon but I'm kinda lost with that ;/ – Ferran Buireu Mar 14 '21 at 20:57

1 Answers1

0

Downgraded Gatsby back to v2 (as well as all the relevant gatsby plugins) and the error went away

izzy
  • 85
  • 1
  • 7