mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-01 17:57:36 +08:00
Breaking changes here https://github.com/mochajs/mocha/releases/tag/v8.0.0 seem fine. DISABLE_THIRD_PARTY_CHECK=Update Mocha Bug: chromium:1101784 Change-Id: Idc75c94f9a923e2b0ca13d1d1331540cb1c5d3a3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2279830 Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Workerpool embedded worker example
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 !!!
Run
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.
How does it work?
- The script worker.js is bundled into
dist/worker.bundle.jsusing Webpack - From the worker bundle, a base64 encoded data url is created and stored in a JavaScript file
dist/worker.embedded.js. This file looks like:module.exports = 'data:application/javascript;base64,...'; - The file app.js loads the embedded worker and passes it to the worker pool like:
```js
var workerDataUrl = require('./dist/worker.embedded');
// create a worker pool
var pool = workerpool.pool(workerDataUrl);
```
- The application
app.jsis bundled using Webpack, and the bundle is loaded into app.html.