WebWorker在压缩ES6模块中失败

时间:2018-03-29 15:08:44

标签: javascript webpack imagefilter

控制台错误

blob:https://[path-to-worker] Uncaught ReferenceError: e is not defined

它引用的e在worker.js中是self

SRC

module.exports = function (self) {
    self.addEventListener('message', function (e) {
        importScripts(e.data.transformationURL);

        var canvasData = e.data.canvasData;

        var length = e.data.length;
        var index = e.data.index;

        transform(canvasData.data, length, e.data.options);

        self.postMessage({
            result: canvasData,
            index: index
        });

        self.close();
    });
};

压缩

e.addEventListener("message", function(t) {
  importScripts(t.data.transformationURL);
  var n = t.data.canvasData,
    r = t.data.length,
    o = t.data.index;
  transform(n.data, r, t.data.options), e.postMessage({
    result: n,
    index: o
  }), e.close()
})

0 个答案:

没有答案