UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

32 lines (31 loc) 939 B
import { parseSync } from "oxc-parser"; function useDOMPlugin() { return { name: "one-vite-dom-plugin", async transform(code, id, options) { if (!code.includes("use dom")) { return; } try { const parsed = parseSync(id, code); let hasUseDom = false; for (let i = 0; i < parsed.program.body.length; ++i) { const item = parsed.program.body[i]; if (item.type === "ExpressionStatement") { if (item.directive === "use dom" || item.expression?.type === "Literal" && item.expression?.value === "use dom" || item.expression?.type === "StringLiteral" && item.expression?.value === "use dom") { hasUseDom = true; break; } } } if (!hasUseDom) { return; } } catch { return; } } }; } export { useDOMPlugin }; //# sourceMappingURL=useDomPlugin.mjs.map