Keyang / node-csvtojson

Blazing fast and Comprehensive CSV Parser for Node.JS / Browser / Command Line.
MIT License
2.02k stars 271 forks source link

React Build Script Issue - strip-bom 3 #255

Closed paulkarcher closed 6 years ago

paulkarcher commented 6 years ago

Hello, I am receiving the following error when trying to create a production build for a react application with react-scripts which uses version 1.1.11 of the csvtojson package.

$ react-scripts build
Creating an optimized production build...
Failed to compile.

Failed to minify the code from this file: 

        ./node_modules/strip-bom/index.js:2 

Read more here: http://bit.ly/2tRViJ9

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I think it's because version 3 of strip-bom uses an ES6 function declaration and the react build script expects the source be using ES5 (as noted here). I was able to create a successful build by changing the 2nd line inside the node module source of strip-bom to this:

module.exports = function (x) {

I don't know how important react support is for this library, but I figured I would bring it up. This is the commit where the strip-bom version was updated: https://github.com/Keyang/node-csvtojson/commit/ac1b871af413a728ff49af93f5c9086faebc96f2

React applications using react-scripts to build can still create production builds with csvtojson 1.1.9 for now.

paulkarcher commented 6 years ago

Here is a link as well to an older discussion on ES5 transpilation in the strip-bom repository: https://github.com/sindresorhus/strip-bom/issues/7

Keyang commented 6 years ago

thanks for pointing this out. released in 1.1.12

paulkarcher commented 6 years ago

No problem at all, happy to help.

Looks like that did the trick, thank you for such a quick fix!