Attaching a function to window object in Webpack 5
Solution 1:
Try to add node.global: true to your config:
node: {
global: true
}
Solution 2:
DoneDel0's comment was the correct solution for me.
node: {
global: true
}
The reasoning behind this is webpack 5 does no longer include a polyfills for node modules, so you have to manually set each.
https://webpack.js.org/configuration/node/#nodeglobal
However its good to note that the docs does suggest using ProvidePlugin instead of global.