mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Try to not load terser in the main thread?
This commit is contained in:
@@ -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 {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user