'How do I import setup colyseus with a svelte app?

I'm trying to start a colyseus app using Svelte.

I am import colyseus using:

import { Client } from 'colyseus.js'

This builds fine but gives me the following messages when running the app:

Creating a browser bundle that depends on "https", "http" and "url". You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node

- @colyseus/schema

LiveReload enabled
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
https (guessing 'https')
http (guessing 'http$1')
url (guessing 'url')

In the browser the app crashes with this console message:

Uncaught ReferenceError: https is not defined
    at main.js:8:2

I've tried to setup the rollup-plugin-polyfill-node referenced in the log but this doesn't fix the issue

I'm also a newbie with Svelte/rollup etc so a simple explanation of what I am doing wrong would be appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source