From 47485ded72cea4b96cdac087a63192206b9f1f37 Mon Sep 17 00:00:00 2001 From: manchenkoff Date: Wed, 24 Jul 2024 22:49:42 +0200 Subject: [PATCH] fix: import pusher on demand --- src/runtime/plugin.client.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/runtime/plugin.client.ts b/src/runtime/plugin.client.ts index 2e3b068..8272da3 100644 --- a/src/runtime/plugin.client.ts +++ b/src/runtime/plugin.client.ts @@ -3,7 +3,6 @@ import type { Channel, Options, ChannelAuthorizationCallback } from 'pusher-js' import type { ChannelAuthorizationData } from 'pusher-js/types/src/core/auth/options' import { createConsola, type ConsolaInstance } from 'consola' import type { FetchOptions } from 'ofetch' -import Pusher from 'pusher-js' import { useEchoConfig } from './composables/useEchoConfig' import type { Authentication, ModuleOptions } from './types' import { defineNuxtPlugin, createError, useCookie } from '#app' @@ -11,7 +10,6 @@ import { defineNuxtPlugin, createError, useCookie } from '#app' declare global { interface Window { Echo: Echo - Pusher: typeof Pusher } } @@ -137,6 +135,9 @@ export default defineNuxtPlugin(async (_nuxtApp) => { const config = useEchoConfig() const logger = createEchoLogger(config.logLevel) + const Pusher = (await import('pusher-js')).default + + // @ts-expect-error window has no Pusher property window.Pusher = Pusher window.Echo = new Echo(prepareEchoOptions(config, logger))