GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — opencode/packages/plugin/src/gui/vite.ts at dev · yusha/opencode Expand file tree/ Copy pathvite.tsMore file actions 61 lines (56 loc) · 2.3 KB / Copy pathvite.tsFile metadata and controls61 lines (56 loc) · 2.3 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 import { isBuiltin } from "node:module" import path from "node:path" import type { Plugin } from "vite" import solid from "vite-plugin-solid" import { pluginSharedModules, pluginWindowModules } from "./modules.js" /** Where `gui()` reads a plugin's GUI and writes its `./gui-experimental` bundle. */ export interface GuiOptions { /** The module whose default export is the plugin's `Plugin.define`. Defaults to `src/gui.tsx`. */ readonly entry?: string /** The CommonJS bundle to write, the file `./gui-experimental` exports. Defaults to `dist/gui-experimental.cjs`. */ readonly outFile?: string } // The modules the app provides to a plugin's GUI, each the app's own instance; the bundle must not include a copy. const provided = new Set<string>([...pluginSharedModules, ...pluginWindowModules]) /** * Builds a plugin's `./gui-experimental` bundle with Vite: compiles Solid JSX, writes one CommonJS file with every * dynamic `import()` inlined, since the app loads no second chunk, and keeps the modules the app provides external, * with Electron and Node built-ins. Another module of Effect, Solid or OpenCode fails the build: the app does not * provide it, and a bundled copy would not share the app's instance. * * @param options - The entry and the bundle to write. * @returns The Vite plugins. * * @example * ```ts * // vite.config.ts * export default defineConfig({ plugins: [gui()] }) * ``` */ export function gui(options: GuiOptions = {}): Plugin[] { const outFile = options.outFile ?? "dist/gui-experimental.cjs" return [ solid(), { name: "opencode-gui", enforce: "pre", config: () => ({ build: { outDir: path.dirname(outFile), emptyOutDir: false, lib: { entry: options.entry ?? "src/gui.tsx", formats: ["cjs"], fileName: () => path.basename(outFile), }, rollupOptions: { output: { exports: "named", inlineDynamicImports: true } }, }, }), resolveId(source) { if (provided.has(source) || source === "electron" || isBuiltin(source)) return { id: source, external: true } if (/^(effect|solid-js|@opencode)\//.test(source)) this.error(`${source} is not a module the OpenCode app provides to plugin GUIs: ${[...provided].join(", ")}`) }, }, ] } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |