istarkov / google-map-clustering-example

clustering example for google-map-react
http://istarkov.github.io/google-map-clustering-example/
200 stars 76 forks source link

Webpack #6

Open m0rdreck opened 7 years ago

m0rdreck commented 7 years ago

Hello i try to use this with webpack but i have one error on GMap file

Module build failed: SyntaxError: C:/js/components/maps/GMap.js: Unexpected token (34:22)

32 | > 33 | {

34 | clusters.map(({ ...markerProps, id, numPoints }) => ( | ^ 35 | numPoints === 1 36 | ? <SimpleMarker key={id} {...markerProps} /> 37 | : <ClusterMarker key={id} {...markerProps} />

Do you have an idea for this ? i have same error on ...cluster

istarkov commented 7 years ago

I think it's because of object rest spread in babel has changed in order to work by specification. so { ...markerProps, id, numPoints } this is incorrect now, spread argument must be last. So you need to change the order of arguments.

m0rdreck commented 7 years ago

Change order no change error.

i think the error is in the syntax. he cannot accept to build ...var version of webpack ?

My loader can make this problems ?

    {
        test: /\.jsx?$/,
        include: path.join(__dirname, 'js'),
        exclude: node_modules_dir,
        loaders: ['react-hot-loader/webpack', 'babel?presets[]=es2015&presets[]=react'],
        presets: ['es2015', 'stage-0', 'react', 'react-hmre']
    },
istarkov commented 7 years ago

Im not sure that loader in your example uses the presets section below, so without stage-x preset object spread will not work for you.

m0rdreck commented 7 years ago

you have right, i test to use babel rest spread transform. thank for your time

m0rdreck commented 7 years ago

all is good 👍 i just add babel rest spread transform thank