neophob / wpc-emu

Williams Pinball machine emulator, Play it @
https://playfield.dev
Apache License 2.0
70 stars 12 forks source link

Fix web worker setup #35

Closed freezy closed 5 years ago

freezy commented 5 years ago

This allows bundling the web worker in third-party clients by passing a worker instance to the initialize function of the WPC API.

A Webpack setup would look like this:

  1. Install worker-loader: npm install worker-loader --save-dev
  2. Import and instantiate the worker:
    import Worker from 'worker-loader!wpc-emu/lib/webclient/webworker.js';
    const wpcEmuWebWorkerApi = WpcEmuWebWorkerApi.initialiseWebworkerAPI(new Worker());
    // wpc api available!

Note that you don't need a separate entry point for the worker when building with Webpack anymore.

This patch is backwards-compatible.

neophob commented 5 years ago

thanks! that resolves one of my quirks!