Bunlong/react-papaparse

Webpack v5 compatibility

ax0n-pr1me opened this issue · 6 comments

Greetings

webpack v5 no longer includes polyfills by default and this breaks the react-papaparse v3 package.

Compiled with problems:X

ERROR in ./node_modules/react-papaparse/dist/react-papaparse.es.js 1:0-23

Module not found: Error: Can't resolve 'stream' in '/usr/src/app/node_modules/react-papaparse/dist'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
	- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "stream": false }

Same here for me.

@ax0n-pr1me @ray-vgw

If you were a direct user of webpack v4, upgrading to v5, you have a few options:

  1. stay on v4
  2. remove usage of polyfilled modules
  3. add polyfills

Reference: https://webpack.js.org/blog/2020-10-10-webpack-5-release/#automatic-nodejs-polyfills-removed.

Here are the polyfills that were formerly provided by webpack (note that the project is deprecated): https://github.com/webpack/node-libs-browser.

Thanks @Bunlong - that was my understanding as well. HNY22!

@ax0n-pr1me My pleasure. HNY22!

Hi,

in the case of react-papaparse, does "remove usage of polyfilled modules" just mean "don't use react-papaparse"?

@ax0n-pr1me @ericfournier2 @ray-vgw

It was fixed in latest version react-papaparse v3.18.2.

Thank you so much!