Try to not load terser in the main thread?
This commit is contained in:
parent
e5aa809a07
commit
9351d7ebeb
1 changed files with 4 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import type { MinifyOptions, MinifyOutput } from "terser";
|
||||
import { recieveMessageData, sendMessageData } from "./util";
|
||||
|
||||
const is_browser = typeof window !== "undefined";
|
||||
export function init() {
|
||||
|
||||
let worker: SharedWorker;
|
||||
|
|
@ -36,11 +37,13 @@ export function init() {
|
|||
worker.port.postMessage(data)
|
||||
});
|
||||
|
||||
} else {
|
||||
} else if (is_browser) {
|
||||
if (!terserModule) {
|
||||
terserModule = await import("terser")
|
||||
}
|
||||
return await terserModule.minify(files, options)
|
||||
} else {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue