feat: rebuild desktop sync as linked server accounts, fix packaged plugin bundles and UI scaling

This commit is contained in:
LukeGus committed 2026-09-26 00:41:25 -05:00
1 parent 7c02daccf4
commit 6cd9a2846d
242 files changed
+39127 -8558

No files matched your search

+44
View File
@@ -2,6 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { build } from "../packages/plugin-sdk/cli/commands/build.mjs";
const cleanups: Array<() => void> = [];
@@ -39,4 +40,47 @@ describe("termix-plugin build", () => {
expect(pkg).toEqual({ type: "module" });
expect(fs.existsSync(path.join(dir, "dist", "backend.js"))).toBe(true);
});
it("loads a bundled CommonJS package that requires a host-provided one, with Vite's build constants", async () => {
vi.spyOn(console, "log").mockImplementation(() => {});
const dir = fixturePlugin();
const dep = path.join(dir, "node_modules", "cjs-dep");
fs.mkdirSync(dep, { recursive: true });
fs.writeFileSync(
path.join(dep, "package.json"),
JSON.stringify({ name: "cjs-dep", main: "index.js" }),
);
// What react-xtermjs does: a CommonJS require of React's JSX runtime.
fs.writeFileSync(
path.join(dep, "index.js"),
'const runtime = require("react/jsx-runtime");\nexports.render = () => runtime.jsx("div", {});\n',
);
fs.mkdirSync(path.join(dir, "src", "frontend"), { recursive: true });
fs.writeFileSync(
path.join(dir, "src", "frontend", "index.ts"),
'import { render } from "cjs-dep";\nexport const rendered = render();\nexport const dev = import.meta.env.DEV;\nexport const mode = process.env.NODE_ENV;\n',
);
await build({ cwd: dir });
// Stand in for the import map: point the external at a stub module.
const stub = path.join(dir, "jsx-runtime.mjs");
fs.writeFileSync(
stub,
"export const jsx = (type) => ({ type });\nexport const jsxs = jsx;\n",
);
const bundle = fs
.readFileSync(path.join(dir, "dist", "frontend.js"), "utf8")
.replaceAll(
'"react/jsx-runtime"',
JSON.stringify(pathToFileURL(stub).href),
);
const runnable = path.join(dir, "dist", "runnable.mjs");
fs.writeFileSync(runnable, bundle);
const mod = await import(pathToFileURL(runnable).href);
expect(mod.rendered).toEqual({ type: "div" });
expect(mod.dev).toBe(false);
expect(mod.mode).toBe("production");
});
});