From 6de6bb5b5a69413d0fbf3d97454b445d75b276b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Zori=C4=87?= Date: Wed, 3 Jun 2026 20:41:44 +0200 Subject: [PATCH] fix: prevent bundlers from resolving optional posthog-js at build time Use an opaque variable specifier plus webpackIgnore/vite-ignore magic comments so no bundler tries to resolve posthog-js during the build. Apps that don't install posthog-js will no longer fail to compile. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/web.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/web.ts b/src/web.ts index 80444ac..6f8d0a0 100644 --- a/src/web.ts +++ b/src/web.ts @@ -212,7 +212,8 @@ export class WTS extends TelemetryClient { } sessionRecordingStarted = true; - import("posthog-js") + const mod = "posthog-js"; + import(/* webpackIgnore: true */ /* @vite-ignore */ mod) .then(({ default: posthog }) => { posthog.init(posthogKey, { api_host: cfg.apiHost,