React-csv gives webpack error in custom plugin strapi 4

Hey there, I’m using strapi 4.1.0 - I’m working on a new plugin and I need a way of exporting the csv. I used React-CSV because I knew it worked in Strapi 3 - but now it’s giving me a webpack error.

Module parse failed: Unexpected token (102:6)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See
|     return (
>       <a
|         download={filename}
|         {}

Ive tried playing with the src/admin/webpack.config.js - nothing I tried worked. Does anyone know a good fix for this?

We had a similar issue using yarn workspaces. Our solution was adding an alias to webpack.config.js, something similar to

module.exports = (config, webpack) => {
  config.resolve.alias['react-csv'] = path.resolve('node_modules', 'react-csv');

  return config;