问题
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