Estoy trabajando en un proyecto heredado con grunt. Creo por el paquete.json que la versión es 0.4.5 , pero no hago demasiado trabajo de front-end, por lo que es posible que haya cometido un error allí.
Esencialmente, estoy tratando de construir un objeto JSON a partir de JavaScript que tenga algunos pares de valores clave dinámicos.
Estoy haciendo esto
var params = { [localObject.propertyValue]: localObject.otherPropertyValue, "dateRange": { "start": localObject.startPropertyValue, "end": localObject.endPropertyValue } }Esto funciona perfectamente. Lo publico hasta el punto final y obtengo el resultado que quiero y he estado jugando con él toda la tarde usando
grunt --profile=devServer Sin embargo, cuando hago una grunt build , obtengo un error. Está alrededor del nombre de la propiedad calculada - [localObject.propertyValue] . Si dejo esto fuera, se construye sin problemas.
Este es el error. Estoy luchando por pensar en una forma diferente de agregar dinámicamente la clave y sé que nadie querrá que actualice grunt. Me preguntaba si alguien podría ayudar.
JS_Parse_Error { message: 'Unexpected token: name (scheduleSearchController)', filename: '../../.tmp/concat/js/app.js', line: 34463, col: 6, pos: 1254651, stack: 'Error\n at new JS_Parse_Error (/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:196:18)\n at js_error (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:204:11)\n at croak (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:674:9)\n at token_error (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:682:9)\n at unexpected (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:688:9)\n at as_property_name (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1276:13)\n at /node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1230:24\n at /node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:721:24\n at expr_atom (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1181:35)\n at maybe_unary (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:1357:19)' } >> Uglifying source .tmp/concat/js/app.js failed. Warning: Uglification failed.