Microsoft.AspNet.Web.Optimization JavaScript bundling fails to minify template literals

我只是一个虾纸丫 提交于 2020-03-01 06:48:51

问题


Using the latest version of Microsoft.AspNet.Web.Optimization v1.1.3 I am unable to get bundling to minify the JavaScript if it includes template literals. For example if I include the following in one of my bundle scripts:

var name = 'Bob';
var formattedName = `${name} says hello`;

The resulting bundle will join all files but it won't minify code, and gives me this error:

/* Minification failed. Returning unminified contents.
(2,13-14): run-time error JS1014: Invalid character: `
(2,15-16): run-time error JS1004: Expected ';': {
(2,30-31): run-time error JS1014: Invalid character: `
(3,1-2): run-time error JS1107: Expecting more source characters
*/

I understand this feature was only introduced in ECMAScript2015 and it's clearly not supported but is there a clean workaround other than reverting back to the old string concatenation methods?

var name = 'Bob';
var formattedName = name + ' says hello';

Also, will template literal support go into future versions of Microsoft.AspNet.Web.Optimization?

来源:https://stackoverflow.com/questions/42934252/microsoft-aspnet-web-optimization-javascript-bundling-fails-to-minify-template-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!