nteath's avatar

Not transpiling es6 spread operator

laravel-mix: 5.0.4

I am using the spread operator in my Vue component for vuex mapGetters and mapActions but it doesn't get transpiled to earlier versions of javascript, so as expected my application breaks on older browsers.

I can see that laravel-mix includes @babel/plugin-proposal-object-rest-spread out of the box. I also tried to include the @babel/plugin-transform-spread plugin and tried with a custom .babelrc:

{ "plugins": [ "@babel/plugin-proposal-object-rest-spread", "@babel/plugin-transform-spread" ] } but no luck.

The transpiled code always contains something like: ...Object(vuex__WEBPACK_IMPORTED_MODULE_0__["mapGetters"] ... etc

What am I missing here? Any help would be appreciated.

0 likes
1 reply
nteath's avatar
nteath
OP
Best Answer
Level 5

Ok found the solution. For anyone that might encounter the same issue.

In my script tags in components I had < script lang="babel" >

I believe this was used by an old plugin when es6 was not fully supported on IDEs ? Not 100% sure on that. But I removed the instruction from all the files and now everything gets transpiled correctly.

Please or to participate in this conversation.