deepstreamIO / deepstream.io-client-js

The Browser / Node.js Client for deepstream.io
Other
294 stars 109 forks source link

Error when running under vue3 / vite #558

Closed slumtrimpet closed 3 years ago

slumtrimpet commented 3 years ago

"global" is not valid in client-side code. Here is one proposed patch that gets things working, but possibly a different refactor makes more sense.

slumtrimpet commented 3 years ago

Possibly a fix to get the build checks working could be:

var global = global || window;

But, the access of 'global' here is still hokey.

jaime-ez commented 3 years ago

Hi, you should use the webpack bundle that handles this automatically. Check your dev setup, raise an issue if you have any questions.

slumtrimpet commented 3 years ago

Hi, you should use the webpack bundle that handles this automatically. Check your dev setup, raise an issue if you have any questions.

The issue is VUE3 standard install doesn't use webpack anymore, it uses VITE. https://v3.vuejs.org/guide/installation.html#vite

EDIT: this is of course all Google'able, but here's a decent writeup on the difference: https://vuejsdevelopers.com/2020/12/07/vite-vue-cli/

jaime-ez commented 3 years ago

Ok, so you need to use the bundle file. See the readme and try to install the client as if you where on react native.

slumtrimpet commented 3 years ago

Ok, so you need to use the bundle file. See the readme and try to install the client as if you where on react native.

Gotcha! It's a bit of a WIP hack at the moment, but the following seems to make Vue3 + Vite + Typescript happy and I'm continuing with testing the platform.

import { DeepstreamClient } from "@deepstream/client";
import { DeepstreamClient as DeepstreamDistClient } from "@deepstream/client/dist/bundle/ds.js";
const client: DeepstreamClient = new DeepstreamDistClient("localhost:6020");
client.login();

Thanks for your help on this!

jaime-ez commented 3 years ago

great, please feel free to make pulls to the readme in order to alert other vite users