ES6 javascript文件包的缩小-ASP.NET MVC

ES6 javascript文件包的缩小-ASP.NET MVC,javascript,asp.net-mvc,ecmascript-6,bundling-and-minification,Javascript,Asp.net Mvc,Ecmascript 6,Bundling And Minification,我正在使用ASP.NET应用程序,并在javascript文件上使用新的ES6语法。此外,我正在使用ScriptBundle来组织和缩小我的javascript文件 问题: /* Minification failed. Returning unminified contents. (91577,1-6): run-time error JS1195: Expected expression: class (91578,12-21): run-time error JS1004: E

我正在使用ASP.NET应用程序,并在javascript文件上使用新的ES6语法。此外,我正在使用
ScriptBundle
来组织和缩小我的javascript文件

问题:

 /* Minification failed. Returning unminified contents.
 (91577,1-6): run-time error JS1195: Expected expression: class
    (91578,12-21): run-time error JS1004: Expected ';': importLib
    (91578,25-26): run-time error JS1004: Expected ';': {
    (91609,1-2): run-time error JS1002: Syntax error: }
    (91613,12-21): run-time error JS1004: Expected ';': importLib
    (91613,25-26): run-time error JS1004: Expected ';': {
    (91627,1-2): run-time error JS1002: Syntax error: }
    (91631,12-21): run-time error JS1004: Expected ';': importLib
    (91631,24-25): run-time error JS1004: Expected ';': {
    (91645,1-2): run-time error JS1002: Syntax error: }
     */
    class FacebookLib {
    static importLib () {
        if (!HelperJSViewBag.getValue("OSPIntegration")) {
            try {
                window.fbAsyncInit = function () {
                    FB.init({
                        appId: HelperJSViewBag.getValue("facebookID"),
                        cookie: true,
                        xfbml: true,
                        version: 'v2.5'
                    });
                };

                (function (d, s, id) {
                    var js, fjs = d.getElementsByTagName(s)[0];
                    if (d.getElementById(id)) { return; }
                    js = d.createElement(s); js.id = id;
                    js.src = "//connect.facebook.net/" + HelperJSViewBag.getValue("Language") + "/sdk.js";
                    fjs.parentNode.insertBefore(js, fjs);
                }
                    (document, 'script', 'facebook-jssdk'));
            } catch (ex) {
                new Exception({
                    className: "ImportingFacebookLibrary",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing facebook library"
                });
            }
        }

    }
}

;
class DropboxLib {
    static importLib () {
        new Ajax().importScripts({
            url: "https://www.dropbox.com/static/api/2/dropins.js",
            insucess: function (data) {
                new Exception({
                    className: "ImportingDropboxLib",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing dropbox library"
                });
            },
            async: true
        });
    }
}

;
class GoogleLib {
    static importLib() {
        new Ajax().importScripts({
            url: "https://apis.google.com/js/client.js",
            insucess: function (data) {
                new Exception({
                    className: "ImportingGoogleLib",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing google library"
                });
            },
            async: true
        });
    }
}
问题是文件没有被缩小,我认为问题在于ES6语法,因为在我没有使用ES6语法的javascript文件中,文件被缩小得很好

代码提取:

 /* Minification failed. Returning unminified contents.
 (91577,1-6): run-time error JS1195: Expected expression: class
    (91578,12-21): run-time error JS1004: Expected ';': importLib
    (91578,25-26): run-time error JS1004: Expected ';': {
    (91609,1-2): run-time error JS1002: Syntax error: }
    (91613,12-21): run-time error JS1004: Expected ';': importLib
    (91613,25-26): run-time error JS1004: Expected ';': {
    (91627,1-2): run-time error JS1002: Syntax error: }
    (91631,12-21): run-time error JS1004: Expected ';': importLib
    (91631,24-25): run-time error JS1004: Expected ';': {
    (91645,1-2): run-time error JS1002: Syntax error: }
     */
    class FacebookLib {
    static importLib () {
        if (!HelperJSViewBag.getValue("OSPIntegration")) {
            try {
                window.fbAsyncInit = function () {
                    FB.init({
                        appId: HelperJSViewBag.getValue("facebookID"),
                        cookie: true,
                        xfbml: true,
                        version: 'v2.5'
                    });
                };

                (function (d, s, id) {
                    var js, fjs = d.getElementsByTagName(s)[0];
                    if (d.getElementById(id)) { return; }
                    js = d.createElement(s); js.id = id;
                    js.src = "//connect.facebook.net/" + HelperJSViewBag.getValue("Language") + "/sdk.js";
                    fjs.parentNode.insertBefore(js, fjs);
                }
                    (document, 'script', 'facebook-jssdk'));
            } catch (ex) {
                new Exception({
                    className: "ImportingFacebookLibrary",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing facebook library"
                });
            }
        }

    }
}

;
class DropboxLib {
    static importLib () {
        new Ajax().importScripts({
            url: "https://www.dropbox.com/static/api/2/dropins.js",
            insucess: function (data) {
                new Exception({
                    className: "ImportingDropboxLib",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing dropbox library"
                });
            },
            async: true
        });
    }
}

;
class GoogleLib {
    static importLib() {
        new Ajax().importScripts({
            url: "https://apis.google.com/js/client.js",
            insucess: function (data) {
                new Exception({
                    className: "ImportingGoogleLib",
                    exception: ex,
                    errors: true,
                    warnMessage: "warn: importing google library"
                });
            },
            async: true
        });
    }
}

捆扎前您是否使用过任何运输工具?ES6代码不会在浏览器中运行,通常ES6是使用类似的方式编译的。它目前没有得到很好的支持。我可以想象MVC中的缩小不知道这意味着什么。i、 它不支持ES6@RicardoRochagoogle chrome具有启用实验性javascript的功能(小心可能会断页),因此它可以在chrome上工作,但为了安全起见,您需要使用Babel或Traceur js来传输它。据我所知.NET MVC只绑定了js图像和css文件,因为您提供它们时没有任何传输。因此,最好在绑定之前将其转换为ES5。否则,您可以使用Typescript,它会在上自动转换为jscompilation@RicardoRocha有效的ES6应该是有效的TypeScript,因此它的问题可能比您预期的要小。如果不是TS,那么您将需要了解ES6语法的Babel或minifier。