缩小ES6 javascript文件Bundle - ASP.NET MVC

时间:2017-09-15 10:40:37

标签: javascript asp.net-mvc ecmascript-6 bundling-and-minification

我使用的是ASP.NET应用程序,并且我在我的javascript文件中使用了新的ES6语法。另外,我使用ScriptBundle来整理和缩小我的javascript文件。

问题:

问题是文件没有被缩小,我认为问题是因为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
        });
    }
}

0 个答案:

没有答案