3

I do have following Errors when js file is minified

/* Minification failed. Returning unminified contents.
(36307,7-8): run-time error JS1010: Expected identifier: .
(36307,7-8): run-time error JS1195: Expected expression: .
(36817,7-8): run-time error JS1010: Expected identifier: .
(36817,7-8): run-time error JS1195: Expected expression: .
(36820,7-8): run-time error JS1010: Expected identifier: .
(36820,7-8): run-time error JS1195: Expected expression: .
 */

The JavaScript file script file below, However I found the JavaScript that contains "module.export" will not be minified and I also use online tool for minification, but the minified file does not contain "module.export" and it is removed during minification. Any help how to sort the minification problem of JavaScript file contain module.export

(function e(t, n, r) {

    module.exports = FilterCSS;

}, {
    "./default": 7,
    "./parser": 9,
    "./util": 10
}], 7: [function(require, module, exports) {
        /**
         * cssfilter
         *
         * @author ??<leizongmin@gmail.com>
         */

        function getDefaultWhiteList() {
            // ??????:
            // true: ?????
            // Function: function (val) { } ??true???????,?????????
            // RegExp: regexp.test(val) ??true???????,?????????
            // ??????????????
            var whiteList = {};

            whiteList['align-content'] = false; // default: auto
            whiteList['align-items'] = false; // default: auto

            *
            *
            @param {
                String
            }
            name
                *
                @param {
                    String
                }
            value
                *
                @param {
                    Object
                }
            options
                *
                @return {
                    String
                }
                */

            function onAttr(name, value, options) {
                // do nothing
            }

            /**
             * ???????????????
             *
             * @param {String} name
             * @param {String} value
             * @param {Object} options
             * @return {String}
             */
            function onIgnoreAttr(name, value, options) {
                // do nothing
            }

            var REGEXP_URL_JAVASCRIPT = /javascript\s*\:/img;

            /**
             * ?????
             *
             * @param {String} name
             * @param {String} value
             * @return {String}
             */
            function safeAttrValue(name, value) {
                if (REGEXP_URL_JAVASCRIPT.test(value)) return '';
                return value;
            }


            exports.whiteList = getDefaultWhiteList();
            exports.getDefaultWhiteList = getDefaultWhiteList;
            exports.onAttr = onAttr;
            exports.onIgnoreAttr = onIgnoreAttr;
            exports.safeAttrValue = safeAttrValue;

        }, {}], 8: [function(require, module, exports) {
        /**
         * cssfilter
         *
         * @author ??<leizongmin@gmail.com>
         */

        var DEFAULT = require('./default');
        var FilterCSS = require('./css');


        /**
         * XSS??
         *
         * @param {String} css ????CSS??
         * @param {Object} options ??:whiteList, onAttr, onIgnoreAttr
         * @return {String}
         */
        function filterCSS(html, options) {
            var xss = new FilterCSS(options);
            return xss.process(html);
        }


        // ??
        exports = module.exports = filterCSS;
        exports.FilterCSS = FilterCSS;
        for (var i in DEFAULT) exports[i] = DEFAULT[i];

        // ???????
        if (typeof window !== 'undefined') {
            window.filterCSS = module.exports;
        }

    }, {
        "./css": 6,
        "./default": 7
    }], 9: [function(require, module, exports) {
            /**
             * cssfilter
             *
             * @author ??<leizongmin@gmail.com>
             */

            var _ = require('./util');
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122

1 Answers1

1

Try like this:

['module'].exports = FilterCSS;

Also this:

[module].exports = FilterCSS;

It worked for me, but no idea why. Before this epiphany, I had solve similar issues with global variables, using something like this:

window['module'].exports=......

But, at least in my case, module was no global. No idea how I came up with this, and less idea how it worked. I'm new with javascript.

Salahuddin Ahmed
  • 4,854
  • 4
  • 14
  • 35