Innologica / vue2-daterange-picker

Vue2 date range picker
https://innologica.github.io/vue2-daterange-picker/
MIT License
330 stars 209 forks source link

Module parse failed: Unexpected token (46:12) #73

Closed yehudahkay closed 5 years ago

yehudahkay commented 5 years ago

Hi thanks this looks cool, i get the following issue in my build

ERROR in ./node_modules/vue2-daterange-picker/src/components/util.js Module parse failed: Unexpected token (46:12) You may need an appropriate loader to handle this file type. }
return {...default_locale, ...options }
}
nkostadinov commented 5 years ago

seems you are missing the spread operator polyfill.

yehudahkay commented 5 years ago

What do I need to do?

nkostadinov commented 5 years ago

could you try to add to your dependencies:

"core-js": "^2.6.5",

If this works for you I will add it to the components dependcies.

yehudahkay commented 5 years ago

No, I actually tried that before with version 3 now I tried with 2 as well

marcelinhov2 commented 5 years ago

I got the exact same thing. Did you handle it?

Thanks.

nkostadinov commented 5 years ago

I'm trying to reproduce this error without success for now. Are using this in the browser or in webpack project ? Do you have .babelrc or babel.config.js in your projects with preset: [ '@vue/app' ] in it

yehudahkay commented 5 years ago

I imagine it's related to webpack somehow. I am using laravel mix (a webpack wrapper) version 3

nkostadinov commented 5 years ago

The solution for laravel mix (I used that before) is

npm install --save-dev babel-plugin-transform-object-rest-spread

and than create a .babelrc file in your project directory

{
  "plugins": ["transform-object-rest-spread"]
}

I just want to make it work out of the box for all scenarios.

mwmasterweaks commented 5 years ago

image

same problem here

.babelrc

{ "plugins": ["transform-object-rest-spread"], "presets": [["env", { "modules": false }], "stage-3"] }

please help how to fix it

nkostadinov commented 5 years ago

@mwmasterweaks are you also using laravel mix ?

mwmasterweaks commented 5 years ago

I have no idea about laravel mix but all I know is I use webpack

nkostadinov commented 5 years ago

could you share you dependencies in package.json

mwmasterweaks commented 5 years ago

image

rpaggi commented 5 years ago

I imagine it's related to webpack somehow. I am using laravel mix (a webpack wrapper) version 3

Same problem here, I'm using Laravel Mix too.

The solution for laravel mix (I used that before) is

npm install --save-dev babel-plugin-transform-object-rest-spread

and than create a .babelrc file in your project directory

{
  "plugins": ["transform-object-rest-spread"]
}

I just want to make it work out of the box for all scenarios.

I've tried that, but doesn't work...

kot-begemot commented 5 years ago

Same thing here. I am using rails with webpack.

UPDATE

I went to file vue2-daterange-picker/src/components/util.js

and changed line 46 from

return {...default_locale, ...options }

to

return Object.assign({}, default_locale, options)

and BOOM the magic has happened.

Long story short this happens when es2015 is not loaded. Two ways to solve it

rogersxd commented 5 years ago

Hi, i'm using laravel-mix + webpack to transpile my files. My app.js is broken on safari browser =< version 11. I've tried to change the line 46, like @kot-begemot suggested. I've tried to set @babel/env, @vue/app and others presets and plugins on .babelrc. But doesn't work.

DelfsEngineering commented 5 years ago

Has this beed addressed? It would suck to trans-pile to a low code base just for this one module on one crappy browser.

rogersxd commented 5 years ago

@DelfsEngineering I solved the problem by transpiling the files correctly. Safari version 11 is not that old and deserves some attention.

DelfsEngineering commented 5 years ago

@DelfsEngineering I solved the problem by transpiling the files correctly. Safari version 11 is not that old and deserves some attention.

What Babel settings worked? I am not having a ton of luck. Thanks for the udpate.

nkostadinov commented 5 years ago

In the last version I think I fixed the older browser problem by including the dist files. What version of the package are you using ?

@DelfsEngineering if you are using an older version you can add this to vue.config.js :

module.exports = {
  transpileDependencies: [
    'vue2-daterange-picker',
  ],
.....