fix: replace require('qrcode') with await import() for ESM compatibility

require() is not defined in ESM modules. The production build (tsc)
outputs ESM, causing 'require is not defined' → 500 → 'QR unavailable'.
Vitest/tsx shimmed require() so tests passed but production was broken.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-03-01 18:04:23 +01:00
co-authored by Claude Opus 4.6
parent 211abe60ca
commit 8764a684ac
4 changed files with 21 additions and 263 deletions
+1 -2
View File
@@ -362,8 +362,7 @@ export class TunnelManager extends EventEmitter {
if (!code) throw new Error('No QR token available');
if (this.cachedQrSvg?.shortCode === code) return this.cachedQrSvg.svg;
// eslint-disable-next-line @typescript-eslint/no-require-imports -- dynamic optional dependency
const QRCode = require('qrcode');
const QRCode = await import('qrcode');
const svg: string = await QRCode.toString(`${tunnelUrl}/q/${code}`, {
type: 'svg',
margin: 2,