mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
Move terser off of the main thread
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import SvelteSeo from "svelte-seo";
|
||||
import { bookmarkify, parseMeta } from "./bookmarklets";
|
||||
import type { Config } from "./config";
|
||||
|
||||
import { init } from "$lib/workers/terser";
|
||||
import { SITE_URL } from '$lib/metadata';
|
||||
|
||||
/** @type {import('./$types').Snapshot<string>} */
|
||||
@@ -12,12 +12,14 @@
|
||||
restore: (v: string) => (value = v),
|
||||
};
|
||||
|
||||
let minify = init().minify
|
||||
|
||||
let value = "";
|
||||
let output = "";
|
||||
let options: Config = {};
|
||||
async function process(str: string) {
|
||||
options = await parseMeta(str);
|
||||
let res = await bookmarkify(str, options);
|
||||
let res = await bookmarkify(str, options, minify);
|
||||
if (typeof res == "string") {
|
||||
output = res;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
|
||||
import MagicString from "magic-string";
|
||||
import { Parser } from "acorn";
|
||||
import { minify } from "terser";
|
||||
import { type MinifyOptions, type MinifyOutput } from "terser";
|
||||
|
||||
let sourceMap = false;
|
||||
|
||||
import { configSchema } from "./config.schema";
|
||||
import type { Config } from "./config";
|
||||
// console.log(configSchema)
|
||||
export async function bookmarkify(code: string, options: Config) {
|
||||
export async function bookmarkify(code: string, options: Config, minify: (files: string | string[] | {
|
||||
[file: string]: string;
|
||||
}, options?: MinifyOptions | undefined) => Promise<MinifyOutput>
|
||||
) {
|
||||
|
||||
// try {
|
||||
if (options.script) {
|
||||
|
||||
Reference in New Issue
Block a user