Skip to content

Commit

Permalink
fix: import pusher on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
manchenkoff committed Jul 24, 2024
1 parent d14e33b commit 47485de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/plugin.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ 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'

declare global {
interface Window {
Echo: Echo
Pusher: typeof Pusher
}
}

Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 47485de

Please sign in to comment.