Fix pkg build

This commit is contained in:
hensm
2026-03-14 18:37:20 +00:00
parent ad9eb4bcac
commit 401754359a
3 changed files with 18 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ const argv = await yargs()
})
.option("node-version", {
describe: "Node.js version to target",
default: "16"
default: "22"
})
.conflicts("use-pkg", "package")
.parse(process.argv);
@@ -111,7 +111,7 @@ async function build() {
* Workaround for pkg asset detection
* https://github.com/thibauts/node-castv2/issues/46
*/
assets: "../../node_modules/castv2/lib/cast_channel.proto"
assets: "../../../node_modules/castv2/lib/cast_channel.proto"
}
};

View File

@@ -1,5 +1,5 @@
import { EventEmitter } from "events";
import { DnsSdBrowser } from "../../../dns_sd";
import { DnsSdBrowser } from "../../../dns_sd/index";
import type { ReceiverDevice } from "../../messagingTypes";
/**

View File

@@ -1,6 +1,20 @@
import path from "path";
import { EventEmitter } from "events";
const native = require("bindings")("dns_sd");
let native: any;
if ((process as any).pkg) {
// Seems to be some breaking change with the way bindings paths are resolved
// in @yao-pkg/pkg, so use `process.dlopen` directly when running in a pkg
// bundle.
native = { exports: {} } as any;
process.dlopen(
native,
path.join(path.dirname(process.execPath), "dns_sd.node")
);
native = native.exports;
} else {
native = require("bindings")("dns_sd");
}
export interface Service {
/** Service instance name */