Huakun Shen f89cf8fe6a
Feature: Headless Command (#44)
* chore: add check-types

* refactor: api package file structure update

* feat: add headless worker extension API

* feat: add HeadlessCmd to manifest schema

* feat: make each type of cmds optional in manifest

There may be more types of cmds in the future, this makes backward compatibility easier.

* feat: implement headless extension command in app

A demo cmd implemented as well.

* refactor: move api package's API server files

* refactor: reformat all
2025-01-05 21:12:56 -05:00

31 lines
730 B
TypeScript

import { watch } from "fs"
import { join } from "path"
import { refreshTemplateWorkerExtension } from "@kksh/api/dev"
import { $ } from "bun"
async function build() {
try {
// await $`bun build --minify --target=browser --outdir=./dist ./src/index.ts`
const output = await Bun.build({
entrypoints: ["./src/index.ts", "./src/headless.ts"],
outdir: "./dist",
minify: true,
target: "browser"
})
await refreshTemplateWorkerExtension()
} catch (error) {
console.error(error)
}
}
const srcDir = join(import.meta.dir, "src")
await build()
if (Bun.argv.includes("dev")) {
console.log(`Watching ${srcDir} for changes...`)
watch(srcDir, { recursive: true }, async (event, filename) => {
await build()
})
}