I'm trying to get the core node module polyfill working with my electron-forge project which uses Webpack 5.
I'm using an npm package which utilises a few of the core node modules, so Webpack is complaining since it can't compile unless I polyfill the core modules. I've done what the docs say and added a fallback in the Webpack config, and installed literally every single polyfill, however the error just hasn't gone away.
This is what my webpack rules look like:
module.exports = [
// Add support for native node modules
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
{
test: /\.jsx?$/,
use: {
loader: 'babel-loader',
options: {
exclude: /node_modules/,
presets: ['@babel/preset-react']
}
}
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
{
test: /\.(woff|woff2|eot|ttf|otf|jpeg|svg|png)$/i,
type: 'asset/resource',
},
];
Anyone had any luck with this in the past?