I need to include a node_module (nanoid) in babel-loader in order to down transpile it to ES5. This used to work in Webpack 4:
module.exports = {
...
module: {
rules: [
test: /\.(js|jsx)$/,
exclude: /node_modules\/(?!nanoid)/,
loader: 'babel-loader',
],
},
...
};
but since I updated to Webpack 5 I get this error in the console:
Uncaught ReferenceError: module is not defined
at eval (index.js:7)
at eval (index.js:8)
at Module../node_modules/nanoid/url-alphabet/index.js (bundle.js:3489)
Webpack throws no error while compiling, but running the bundle in the browser throws the above-mentioned error.