process is not defined in new svelte app using vertx eventbus

218 views Asked by At

Created a new svelte app with:

npx degit sveltejs/template svelte-typescript-app
cd svelte-typescript-app
node scripts/setupTypeScript.js

Added this package @vertx/eventbus-bridge-client.js as dependency.

{
  "name": "svelte-app",
  "version": "1.0.0",
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
    "start": "sirv public",
    "validate": "svelte-check"
  },
  "devDependencies": {
    "@rollup/plugin-commonjs": "^17.0.0",
    "@rollup/plugin-node-resolve": "^11.0.0",
    "@rollup/plugin-typescript": "^8.0.0",
    "@tsconfig/svelte": "^1.0.0",
    "rollup": "^2.0.0",
    "rollup-plugin-css-only": "^3.0.0",
    "rollup-plugin-livereload": "^2.0.0",
    "rollup-plugin-svelte": "^7.0.0",
    "rollup-plugin-terser": "^7.0.0",
    "sirv-cli": "^1.0.0",
    "svelte": "^3.0.0",
    "svelte-check": "^1.0.0",
    "svelte-preprocess": "^4.0.0",
    "tslib": "^2.0.0",
    "typescript": "^4.1.3"
  },
  "dependencies": {
    "@vertx/eventbus-bridge-client.js": "^1.0.0"
  }
}

App.svelte looks like this:

<script lang="ts">
  import EventBus from "@vertx/eventbus-bridge-client.js";

  export let name: string;

  const eb = new EventBus("http://localhost:8888/eventbus");

  const handleClick = () => {
    eb.send("chat-message", {message: "hello"});
  }
</script>

<style></style>

<main>
  <h1>Hello {name}!</h1>
  <p>
    Visit the
    <a href="https://svelte.dev/tutorial">Svelte tutorial</a>
    to learn how to build Svelte apps.
  </p>

  <button on:click={handleClick}>Send message</button>
</main>

I bring up svelte app with yarn dev and this is what i see in browser console:

Uncaught ReferenceError: process is not defined
    app url.js:6
    <anonymous> bundle.js:6388
...

Why is svelte bundle looking for process?

PS: Backend is using vertx4 event bus bridge: https://vertx.io/docs/vertx-web/java/#_sockjs_event_bus_bridge

0

There are 0 answers