Description
Do you want to request a feature or report a bug?
Report a Bug
What is the current behavior?
When creating a new instance I see the following error in browser console:
pusher-js.js?v=405c2cf0:36109 Uncaught (in promise) TypeError: Object(...) is not a function
at Object.randomInt (pusher-js.js?v=405c2cf0:36109:57)
at new pusher_Pusher (pusher-js.js?v=405c2cf0:36654:43)
at new pusher_with_encryption_PusherWithEncryption (pusher-js.js?v=405c2cf0:36826:13)
at +page.svelte:17:9
If the current behavior is a bug, please provide the steps to reproduce and
if possible a minimal demo of the problem via https://jsfiddle.net or similar.
What is the expected behavior?
Pusher to intialize and work correctly
Which versions of Pusher, and which browsers / OS are affected by this issue?
Did this work in previous versions of Pusher? If so, which?
I tried many versions 7.4.0, 8.0.2 and 8.4.0-rc2
** MORE DETAILS
It is a sveltekit app which use vite.
It was working fine with sveltekit 1.x vite 4.x but now I need to upgrade.
The biggest difference is that the support for node modules was dropped, I am using the polyfill node modules from vite-plugin-node-polyfills
Following is my entire vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig({
plugins: [sveltekit(), nodePolyfills({
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: false,
},
})]
});
I was struggling with this for a while so I tried many different things that I found in answers in stackoverflow.
I will highly appreciate any help. or a working sveltekit example if possible.