I am geting to build my project with gulp and uglify-js but it fails and can’t build. And I can’t find what is wrong with this small code snippet.
Function:
function getOneSignalToken() {
window.bridge.post('onesignaltoken', {}, (results, error) => {
$('#onesignal_token').html(results.token);
});
}
Error
events.js:160
throw er; // Unhandled 'error' event
^
Error at new JS_Parse_Error (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :1545:18) at js_error (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :1553:11) at croak (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2092:9) at token_error (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2100:9) at unexpected (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2106:9) at expr_atom (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2633:9) at maybe_unary (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2795:19) at expr_ops (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2830:24) at maybe_conditional (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1),:2835:20) at maybe_assign (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2859:20) at maybe_assign (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2867:32) at expression (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2878:20) at expr_list (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2644:24) at subscripts (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2778:30) at subscripts (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2755:20) at subscripts (eval at (/Users/erik/Desktop/Erik/code/nat5/node_modules/uglify-js/tools/node.js:28:1), :2755:20) Eriks-MacBook-Pro:nat5 erik$
Converting to pre es6/es2015 syntax
(results, error) => {...}
will become
function(results, error) {...}
To use gulp with new style es2015 see: https://markgoodyear.com/2015/06/using-es6-with-gulp/
And if you want to upgrade uglify-js to support es6 use the uglify-es npm package: https://www.npmjs.com/package/uglify-es