2017-07-07 218 views
1

當我嘗試在我的應用程序中使用Ecmascript-6功能時,縮小失敗。ASP.NET MVC 5捆綁和縮小JavaScript ES6

如果我嘗試使用箭頭功能:

$.get('/clients/all').done(response => { 
 
    // Do something with the response 
 
})

我得到以下錯誤:

/* Minification failed. Returning unminified contents. 
(8,45-46): run-time error JS1195: Expected expression: > 
(36,6-7): run-time error JS1195: Expected expression:) 
(37,1-2): run-time error JS1002: Syntax error: } 
*/ 
與其他ES6功能

等。

你知道ItemTransform for ES6嗎?

回答

0

仍然沒有用於ES6 +的.NET捆綁軟件包。

But as a workaround you can use: babeljs.io > Try It Out > Presets: ES2015.

下面的代碼:

var gridNames = Enumerable.From(verifiedKeys).Select(x => `demo_${x}`).ToArray(); 

將被翻譯成:

var gridNames = Enumerable.From(verifiedKeys).Select(function (x) { 
    return "demo_" + x; 
}).ToArray(); 

鏈接:https://babeljs.io/repl和檢查:Presets > ES2015