This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[gatsby-plugin-image] causes Uncaught ReferenceError: global
is not defined
#30093
Labels
type: bug
An issue or pull request relating to a bug in Gatsby
Overview
gatsby-plugin-image
isn't playing nice with other plugins likegatsby-plugin-use-dark-mode
that require theglobal
variable.I might be wrong here but,
based on a minimal reproduction and some debugging,
I think that the issue lies with the plugin's Gatsby Node API calls that are affecting
the webpack configuration.
Reproduction
You can follow the instructions below or refer this example on CodeSandbox:
Start with
gatsby-starter-default
.Add these packages:
Upgrade packages (optional)
Add
gatsby-plugin-use-dark-mode
to the list of plugins.Invoke the
useDarkMode
hook in theLayout
component, destructurevalue
and wrap it in adiv
.Behavior
Actual
The development server throws no relevant warnings or errors in the terminal.
The browser console logs the following error message:
The same can be seen in the following screenshot:
Expected
This error should not exist and the site should run smoothly.
Environment
Running
gatsby info
on the reproduction.Conclusion
As mentioned previously, I think there issue lies with the changing of the Webpack configuration.
The polyfill for
global
seems to be affected, since the browser says it is notdefined
.The text was updated successfully, but these errors were encountered: