我写了一组gulp命令来缩小JS代码。除非我在特定 JS 文件上包含以下代码段,否则它工作正常。
//============================== Ledger Card Modal =================================== //KR: Check
vm.ledgerCardWindowOption = function (matterReferenceNo) {
var busy = busyIndicatorService.setAsBusy('CompanyName.main');
vm.ledgerCardGlyphicon = true;
$scope.modalInstance = $modal.open({
scope: $scope,
templateUrl: 'app/ledgerCard/ledgerCardView.html',
backdrop: 'static',
controller: 'ledgerCardController as vm',
windowClass: 'ledgercard-modal-window',
resolve: {
ledgerCardModal: function () {
var data = { matterReferenceNo: matterReferenceNo, formType: "Modal" };
return data;
}
}
});
$scope.modalInstance.opened.then(() => busy.resolve(), () => busy.resolve()); // This is the bad line
};
//============================== Ledger Card Modal End ===================================
//==============================auto height fix===================================
错误信息:
events.js:72
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:1533:18)
at js_error (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:1541:11)
at croak (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2088:9)
at token_error (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2096:9)
at unexpected (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2102:9)
at expr_atom (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2617:13)
at maybe_unary (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2791:19)
at expr_ops (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2826:24)
at maybe_conditional (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2831:20)
at maybe_assign (eval at <anonymous> (C:dev.net14DevelopmentPhase2CompanyName.WebMainnode_modulesuglify-jstoolsnode.js:30:4), <anonymous>:2855:20)
我已经指出了上面代码中的坏行,但我无法弄清楚那里出了什么问题。谁能解释一下我?
您正在使用ES6
功能,您需要使用transpilier
来转换这些代码ES5
。
https://www.npmjs.com/package/gulp-babel
在uglify
之前,将ES2015
转换为ES5
。