Forum Discussion
Webpack 5 compatibility and crypto dependency when importing @azure/msal-node
- Anonymous1 year ago
Hi, AnthonyF
Firstly, as Webpack 5 no longer includes polyfills for Node.js core modules by default, you will need to add them explicitly. You've already begun addressing the crypto module, but you'll also need to add polyfills for other modules.Below are screenshots from the relevant documentation:
For further details, please refer to:
Secondly, ensure that you have installed the necessary polyfill packages.
Here are some reference examples:
npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url buffer processHow to polyfill node core modules in webpack 5
Next, make sure your Webpack configuration is correctly set up to handle .mjs files:
Finally, here are some related documents I found that I hope will be helpful to you:
webpack 5 & next.js 10 - how to add resolve fallback to config - DEV Community
next.config.js Options: webpack | Next.js
Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, AnthonyF
Firstly, as Webpack 5 no longer includes polyfills for Node.js core modules by default, you will need to add them explicitly. You've already begun addressing the crypto module, but you'll also need to add polyfills for other modules.Below are screenshots from the relevant documentation:
For further details, please refer to:
Secondly, ensure that you have installed the necessary polyfill packages.
Here are some reference examples:
npm install --save-dev crypto-browserify stream-browserify assert stream-http https-browserify os-browserify url buffer process
How to polyfill node core modules in webpack 5
Next, make sure your Webpack configuration is correctly set up to handle .mjs files:
Finally, here are some related documents I found that I hope will be helpful to you:
webpack 5 & next.js 10 - how to add resolve fallback to config - DEV Community
next.config.js Options: webpack | Next.js
Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.