fix: bundle QR dependencies for channel login
This commit is contained in:
@@ -21,7 +21,10 @@ const openclawRequire = createRequire(join(openclawResolvedPath, 'package.json')
|
||||
const projectRequire = createRequire(join(openclawPath, 'package.json'));
|
||||
|
||||
function resolveOpenClawPackageJson(packageName: string): string {
|
||||
const specifier = `${packageName}/package.json`;
|
||||
return resolveOpenClawModule(`${packageName}/package.json`);
|
||||
}
|
||||
|
||||
function resolveOpenClawModule(specifier: string): string {
|
||||
// 1. Try openclaw's own deps (works in packaged mode + openclaw transitive deps)
|
||||
try {
|
||||
return openclawRequire.resolve(specifier);
|
||||
@@ -32,7 +35,7 @@ function resolveOpenClawPackageJson(packageName: string): string {
|
||||
} catch (err) {
|
||||
const reason = err instanceof Error ? err.message : String(err);
|
||||
throw new Error(
|
||||
`Failed to resolve "${packageName}" from OpenClaw context. ` +
|
||||
`Failed to resolve "${specifier}" from OpenClaw context. ` +
|
||||
`openclawPath=${openclawPath}, resolvedPath=${openclawResolvedPath}. ${reason}`,
|
||||
{ cause: err }
|
||||
);
|
||||
@@ -40,8 +43,8 @@ function resolveOpenClawPackageJson(packageName: string): string {
|
||||
}
|
||||
|
||||
const baileysPath = dirname(resolveOpenClawPackageJson('@whiskeysockets/baileys'));
|
||||
const qrCodeModulePath = openclawRequire.resolve('qrcode-terminal/vendor/QRCode/index.js');
|
||||
const qrErrorCorrectLevelPath = openclawRequire.resolve('qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js');
|
||||
const qrCodeModulePath = resolveOpenClawModule('qrcode-terminal/vendor/QRCode/index.js');
|
||||
const qrErrorCorrectLevelPath = resolveOpenClawModule('qrcode-terminal/vendor/QRCode/QRErrorCorrectLevel.js');
|
||||
|
||||
// Load Baileys dependencies dynamically
|
||||
const {
|
||||
|
||||
Reference in New Issue
Block a user