Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jurjen's avatar

ES6 issue with Spark mixin after upgrade

After upgrading Laravel to 5.4 and Spark to 4.0 I run in to the following issue when running npm run production.

error /js/app.js from UglifyJs
Unexpected token punc «(», expected punc «:» [./spark/resources/assets/js/mixins/plans.js:7,4][/js/app.js:5757,8]

This is line 7 in ./spark/resources/assets/js/mixins/plans.js:

data() {

Seems like the Spark mixins are ignored by the babel loader but I'm not sure how to include them. Does anybody have an idea?

0 likes
6 replies
spar_x's avatar

did you figure it out? I'm having the exact same problem.. i raised an issue about it which explains how it began happening (not happening on a fresh install but happening after I began using the es6 spread operator)

https://github.com/laravel/spark/issues/715

jurjen's avatar

No haven't figured it out yet. Still using the older versions of Laravel and Spark. The link you shared doesn't work for me.

I also had issues getting the spread operator to work. Had to install babel-preset-stage-2 and create a .babelrc file with the following contents to get the spread operator to work:

{
  "presets": ["stage-2"]
}
spar_x's avatar
spar_x
Best Answer
Level 2

Yes I got the spread to work easily enough.. either stage-2, stage-3 or adding the transform-object-rest-spread, but then I would have a similar error to you as I detailed in that issue above

After fiddling for hours I just now finally got it to work by adding

this is my .babelrc

{
  "presets": [
    "es2015",
    "stage-3"
  ]
}

and these are the dependencies that have made it work for me

    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-3": "^6.24.1",
    "uglify-es": "^3.0.3",

what a headache!

1 like
jurjen's avatar

Indeed! Great, will give this a try. Thanks!

Xation's avatar

@vesper8 Thx, you save my day. Using VueX with the spread like ...mapActions I got the same error.

/js/app.2f5631ff29a5e9c4d550.js from UglifyJs
Unexpected token: punc (() [/js/app.2f5631ff29a5e9c4d550.js:363,8]

I try first to install uglify-es and babel-plugin-transform-object-rest-spread but not working.

Now It's working with the presets and dependencies

Please or to participate in this conversation.