-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polyfill common Node.js packages for webpack 5 #15948
Comments
I'm giving a try to Webpack 5 in my project and the build in failing because of the
Should it be add in the default polyfill? If not, is there a workaround without having to touch the webpack configuration? |
So overall we're going to automatically polyfill these cases still to provide backwards compat, however you'll really want to figure out where it comes from and get rid of the dependency given that it hogs in around 300kb of JS. |
Would it be possible to add build warnings for polyfilled modules? Right now, when polyfills are missing, it will just crash and tell you on which specific Node module its bailing. Good time to find out where you're pulling in something potentially unwanted, I learnt that the hard way, but it was very helpful info. However, I fear in the future, if Next silently polyfills it, we end up in basically the same situation as now: manually having to check individual packages or worse, not ever even thinking about it because it "just works". Relevant discussion here: #15999 |
That's the plan yeah. Initially I'm just going to add the polyfills so that backwards compat is preserved. |
…#16022) This adds the following Node.js core polyfills only when the import is used: - `path` - `stream` - `vm` - `crypto` - `buffer` Fixes #15948 We'll have a separate issue about adding warnings for the usage of these modules in the browser, some polyfills like crypto are quite heavy and generally not needed for most applications (included accidentally through node_modules).
Warning message has wrong syntax. If user is not expert (and then new) with Webpack, this will push him to loose time to this kind of details neglected. I know it is difficult for expert to explain themself the easy way by choose appropriate linked existing words and syntax, but it is something good for the project if the doc and warning message are clearer as possible. |
This comment has been minimized.
This comment has been minimized.
Any tips on a good way to track down which module may be pulling in the heavy crypto polyfill? I'm facing tracking that down now |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Webpack 5 stopped polyfilling Node.js packages, however, their usage is prolific throughout the npm ecosystem.
We should provide default polyfills for the most common usages:
process
andbuffer
: Add polyfill for process and Buffer in webpack 5 #15499path
The text was updated successfully, but these errors were encountered: