fix: remove ESM export from lib.js for QML compatibility

QML's JS engine does not support ES module export/import syntax.
Replace bare export with a CommonJS guard that only runs under Node.js,
so the plugin loads in QML while tests still work.
This commit is contained in:
Vybe (Coding Agent) 2026-05-18 18:39:39 +00:00
parent 0c2376b3bb
commit c9d1baf7c4
2 changed files with 6 additions and 2 deletions

View file

@ -15,4 +15,7 @@ function makeExitNodeCommand(hostname) {
return ["tailscale", "set", "--exit-node=" + hostname]
}
export { parsePeers, makeExitNodeCommand }
// CommonJS export for Node.js tests (ignored by QML)
if (typeof module !== "undefined" && module.exports) {
module.exports = { parsePeers, makeExitNodeCommand }
}

View file

@ -1,6 +1,7 @@
import { test } from "node:test"
import assert from "node:assert"
import { parsePeers, makeExitNodeCommand } from "../tailscalectl/lib.js"
import lib from "../tailscalectl/lib.js"
const { parsePeers, makeExitNodeCommand } = lib
test("parsePeers extracts exitNode from ExitNodeOption", () => {
const peerMap = {