yaodingyd / react-flickity-component

A React.js component for using @desandro's Flickity
314 stars 51 forks source link

Unexpected token: name (src_FlickityComponent) #20

Closed bhushanscholastic closed 6 years ago

bhushanscholastic commented 6 years ago

Thanks for the react flickity component. I am getting below error when I try to build with npm run build command.

ERROR in 0.87a941d054f3f7a31f25.chunk.js from UglifyJs Unexpected token: name (src_FlickityComponent) [0.87a941d054f3f7a31f25.chunk.js:1079,6] Child html-webpack-plugin for "index.html": 1 asset

build script I am using is : cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress --hide-modules --display-optimization-bailout

If I remove -p option then build is successful. Is react flickity component supported by wedpack module? . I am using react boilerplate module to develop my application. Please advice?

dicktornfeldt commented 6 years ago

I think it's a problem with webpack not being able to uglyfing ES6, and react-flickity-component/src/index is in that syntax.

I solved it by converting react-flickity-component/src/index from ES6 to plain javascript with https://babeljs.io

yaodingyd commented 6 years ago

@bhushanscholastic react-boilerplate's webpack setting looks for jsnext:main over main as entry point. (IMO, this doesn't make sense: why using ES6 module and then UglifyJS). Anyway, if you want to fix your build, remove 'jsnext:main' in your node_module/react-flickity-component/package.json.

If you plan to use latest 2.0.0, then you cannot use it with react-boilerplate as it only supports react 15.

wanbinkimoon commented 6 years ago

Hi same issue here but i think my problem is compiling d3 – I first tried version 5 then downgrade to 4 – in react boilerplate . The error is in Unexpected token: name (CancelError) but no CancelError has a 'jsnext:main' prop.