In a browser environment, the script argument in workerpool.pool(script) can also be a data URL like 'data:application/javascript;base64,...'. This allows embedding the bundled code of a worker in your main application, which is demonstrated in this example.
!!! Note that this example only works in the browser, not in node.js !!!
Install the dependencies:
npm install
Build the embedded worker (dist/worker.embedded.js) and the bundled version of app.js (dist/app.bundle.js):
npm run build
Then open app.html in your browser.
dist/worker.bundle.js using Webpackdist/worker.embedded.js. This file looks like:module.exports = 'data:application/javascript;base64,...';
```js
var workerDataUrl = require('./dist/worker.embedded');
// create a worker pool
var pool = workerpool.pool(workerDataUrl);
```
app.js is bundled using Webpack, and the bundle is loaded into app.html.