Optimize Bundle Size

This commit is contained in:
MengYX
2020-02-06 14:05:46 +08:00
parent 05cdd7b896
commit e3ca175258
5 changed files with 204 additions and 64 deletions

View File

@ -96,8 +96,6 @@
// 严格模式 用于尾调用优化
"use strict";
const worker = require("workerize-loader!./decrypt/common");
const dec = require('./decrypt/common');
export default {
name: 'app',
components: {},
@ -132,12 +130,15 @@
this.finishLoad();
});
if (document.location.host !== "") {
this.thread_num = Math.max(navigator.hardwareConcurrency, 1);
//todo: Fail on Hot Reload
const worker = require("workerize-loader!./decrypt/common");
this.thread_num = navigator.hardwareConcurrency || 1;
for (let i = 0; i < this.thread_num; i++) {
this.workers.push(worker().CommonDecrypt);
this.idle_workers.push(i);
}
} else {
const dec = require('./decrypt/common');
this.workers.push(dec.CommonDecrypt);
this.idle_workers.push(0)
}