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 wasWebpackError: ReferenceError: __WEBPACK_EXTERNAL_MODULE_firebase_app__ is not defined
followed byERROR: Job failed: exit code 1
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 aroundcontext, request
in my gatsby-node.js file. That error went away on the next pipeline attempt, butWebpackError: ReferenceError: __WEBPACK_EXTERNAL_MODULE_firebase_app__ is not defined
remainsShow 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!