Bunlong / react-papaparse

react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
https://react-papaparse.js.org
MIT License
363 stars 60 forks source link

Webpack v5 compatibility #111

Closed ax0n-pr1me closed 2 years ago

ax0n-pr1me commented 2 years ago

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 }
ray-vgw commented 2 years ago

Same here for me.

Bunlong commented 2 years ago

@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.

ax0n-pr1me commented 2 years ago

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

Bunlong commented 2 years ago

@ax0n-pr1me My pleasure. HNY22!

ericfournier2 commented 2 years ago

Hi,

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

Bunlong commented 2 years ago

@ax0n-pr1me @ericfournier2 @ray-vgw

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

Thank you so much!