Currently, I am utilizing a spread operator within my mapGetters object. It is crucial to use a specific babel-preset-stage for proper ES6 compilation. Even after installing babel-preset-stage-2 via npm, I encountered the following error:
ERROR in ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/AnotherResult.vue
Module build failed: SyntaxError: Unexpected token (13:8)
11 | export default {
12 | computed: {
> 13 | ...mapGetters ([
| ^
14 | 'doubleCounter',
15 | 'stringCounter'
16 | ])
A quick search on GitHub revealed that many others have faced similar issues and suggested trying out babel-preset-stage-3 along with other webpack configurations.
Provided below is an excerpt from my package.json:
{
"name": "vue-cli",
"description": "A Vue.js project",
"author": "Maximilian Schwarzmüller <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfb2bdb3bebcb4a6ef9fb8b2beb6b3f1bcb0b2">[email protected]</a>>",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"bootstrap": "^3.3.7",
"vue": "^2.0.1",
"vue-router": "^2.0.1",
"vuex": "^3.1.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.0.0",
"babel-preset-stage-2": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"vue-loader": "^9.7.0",
"webpack": "2.1.0-beta.25",
"webpack-dev-server": "2.1.0-beta.0"
}
}
The contents of my .babelrc file are as follows:
{
"presets": [
["es2015", {"modules": false}],
["stage-3", "env"]
],
"plugins": ["transform-object-rest-spread"]
}
Despite implementing these new configurations, the code refuses to compile. Any suggestions or insights on this matter would be greatly appreciated.
Thank you!