[英]ASP.NET Core BundleMinifier removes async modifier after minification
I added bundleconfig.json
to ASP.NET Core application.我将bundleconfig.json
添加到 ASP.NET Core 应用程序。 It has the following structure:它具有以下结构:
[
{
"outputFileName": "wwwroot/js/main.min.js",
"inputFiles": [
"wwwroot/js/scripts/first.js",
"wwwroot/js/scripts/second.js"
],
"minify": {
"enabled": true,
"renameLocals": true
},
"sourceMap": false
}
]
Both scripts has been minified and merged into main.min.js
.两个脚本都已缩小并合并到main.min.js
。 But after minification all async
modifiers has been removed from result script.但在缩小后,所有async
修饰符都已从结果脚本中删除。
Function such as功能如
async function foo() {
await /* some promise */;
}
have been turned into:已经变成:
function foo() {await /*some promise*/;}
How do I avoid removing async
modifier?如何避免删除async
修饰符?
I'v reproduced the issue and tried to minify a simple js file that using ES6 specifications
and later.我重现了这个问题,并试图缩小一个使用ES6 specifications
及更高版本的简单 js 文件。
Test.js测试.js
async function foo() {
await bar();
}
async function bar() {
for (var i = 0; i < 10; i++) { // do some work
}
}
Then i tried to minify the file with Bundler and Minifier tool then this error thrown:然后我尝试使用Bundler 和 Minifier工具缩小文件,然后抛出此错误:
This means Bundler and Minifier doesn't support ES6 specifications and later.这意味着Bundler 和 Minifier 不支持 ES6 规范及更高版本。
For confirmation i started searching about this issue in the Github and i found these same behaviors为了确认,我开始在Github 中搜索这个问题,我发现了这些相同的行为
I can surely claim that this is The Transpilers Issue我可以肯定地说这是Transpilers问题
Transpilers, or source-to-source compilers, are tools that read source code written in one programming language, and produce the equivalent code in another language.转译器或源到源编译器是读取以一种编程语言编写的源代码并生成以另一种语言编写的等效代码的工具。
The most common and widely use one is TypeScript最常见和使用最广泛的一种是TypeScript
TypeScript
in some cases Transpiles ES6
and later to ES5
在某些情况下, TypeScript
会将ES6
及更高版本转换为ES5
For example: if you set Target to ES6
and ES2015
it Transpiles to ES5
.例如:如果您将 Target 设置为ES6
和ES2015
它会转换为ES5
。 However, if You Target to ES2020
does NOT Transpile your code.但是,如果您的目标是ES2020
则不会转译您的代码。
async
but thrown error Bundler & Minifier不会删除诸如async
类的未知关键字,但会引发错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.