{"name":"rollup-plugin-worker-factory","version":"0.5.4","description":"Bundle web workers that work in nodejs and the browser, without a separate build target.","main":"src/index.js","scripts":{"lint":"vjsstandard","test":"npm run test:unit && npm run test:verify","test:unit":"npm run lint","test:verify":"vjsverify --skip-es-check --verbose","preversion":"npm test","version":"is-prerelease || npm run update-changelog && git add CHANGELOG.md","update-changelog":"conventional-changelog -p videojs -i CHANGELOG.md -s","prepublishOnly":"npm run test:verify"},"lint-staged":{"*.js":"vjsstandard --fix","README.md":"doctoc --notitle"},"keywords":["rollup","rollup-plugin"],"repository":{"type":"git","url":"git+https://github.com/brandonocasey/rollup-plugin-worker-factory.git"},"author":{"name":"Brandon Casey","email":"brandonocasey@gmail.com"},"license":"Apache-2.0","bugs":{"url":"https://github.com/brandonocasey/rollup-plugin-worker-factory/issues"},"homepage":"https://github.com/brandonocasey/rollup-plugin-worker-factory","devDependencies":{"@videojs/generator-helpers":"^2.0.1","videojs-generator-verify":"~3.0.1","videojs-standard":"^8.0.4"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"dependencies":{"rollup":"^2.34.2"},"gitHead":"de9c04905ebaa7cf71052d03bb7b270c3da68a25","_id":"rollup-plugin-worker-factory@0.5.4","_nodeVersion":"10.22.1","_npmVersion":"6.14.6","dist":{"integrity":"sha512-JuIwBZjiMzvqtcwZdY4gAFcS9O3+L+8hNJqWX763b95pqTY31O6T+gxWcYVWX0JuzsPOL9QKClkLN+RgBhgkQg==","shasum":"0f0d16b0fc23dab61394ad01eadbfdf63c2b1c60","tarball":"http://registry-npm.ywwl.com/rollup-plugin-worker-factory/download/rollup-plugin-worker-factory-0.5.4.tgz","fileCount":10,"unpackedSize":25181,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgSo//CRA9TVsSAnZWagAAlHIQAJ3BqMAKx8KUQek8Q6A1\n5mlgQ1cVrbBGaPplo33XUh8GXXcavJGTUAlWdH/ea0nVUqhaDtH60pnPsVjr\nkh4N19dYKs0ROHl/UuRfFb9Rxhu5dptm6cRyAEn5gcECoY4Vm2PghfzieJqW\n+9YM6W0nKg4E1q/hAlDmGGUQGSEbxe0BPvtzjs1VWu2cnjtxa5ZPkPtbuoK7\n8PAeSalOX9aOOVd+ObpHM5b1FZjPbqfXDBJ390Fj18fCH1vDhezB/jtblUm5\nC8jQscY9Z3g0Ldd04wo+onhJcubU6S45hmB/Rwhi/iMMjD86rlbVoDR/Bs88\ncZeWtdRXx/RcuQMG9v2rSpXrg4NP/SuNJvgMVb4ZcR1xGgcem8tepPE0OwQX\nNHrFC7hznNOJo4HO5GG4hH/izCmcFZy/vlWJzTjBwKmopoMg4K4x/zlo36jC\nOkKeTwDQGn/NYCvu3xhz4NPldkoDylLoVcvfDlkXUxpiW0pbulmxKHOPXhkt\nHgCz4dYQ+4cwHFmbO8eOpowqAgNIoga2XVeFXS3gBsA15HRi2A9eIPiFoz60\nhToF6opo0hNVJaup6XT/Gbpx83gKzWL4VBJM7LzXXvCPKt9E4sxMF8k3qlGf\nvfsU0WN0tvDkxcTeh29DNuqy7FcdTcAoGXVdIXCPRu+5wLKQCRa8qZvzUvcg\n7Lym\r\n=k+bO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGYDtffNmPGoEdT9yxODDJigrXWuHHvH5XySqtbAix3AAiBLvpLjXbkpGB0NdzF3VKdqR+iNn72boHK81Ip4y8mROQ=="}],"size":6963,"noattachment":false,"key":"/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.5.4.tgz"},"_npmUser":{"name":"brandonocasey","email":"brandonocasey@gmail.com"},"directories":{},"maintainers":[{"name":"brandonocasey","email":"brandonocasey@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-worker-factory_0.5.4_1615499262624_0.40203998179904876"},"_hasShrinkwrap":false,"readme":"<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n\n- [Install](#install)\n- [Requirements](#requirements)\n- [Usage](#usage)\n- [How it works](#how-it-works)\n- [Modifications to node worker_threads](#modifications-to-node-worker_threads)\n- [Modifictaion to browser WebWorkers](#modifictaion-to-browser-webworkers)\n- [Options](#options)\n  - [plugins](#plugins)\n  - [type](#type)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Install\n```sh\nnpm i -D rollup-plugin-worker-factory\n```\n\n## Requirements\n* browsers with web worker support (tested in ie 11)\n* nodejs >= 10 when node is run with `--experimental-workers`\n* natively in nodejs >= 12 without any arguments to node\n\n## Usage\ninclude rollup-plugin-worker-factory in your rollup plugins array for a build:\n```js\nconst worker = require('rollup-plugin-worker-factory');\n\n...\nplugins: [\n  worker()\n]\n...\n```\n\nWhen you want to include a worker in your code prefix the file with `worker!`:\n```js\nimport SomeWorker from \"worker!./src/some-worker.js\";\n```\n\nYour worker should run without exporting any code and use the global `self` variable to interact with the worker API. `worker_threads.parentPort` for node has been slightly modified so that their API more closely matches web workers in the browser and will also be available on the global `self`.\n\n```js\nconst someDependency = require('../some-dep');\nconst whoKnows = require('who-knows');\n\nself.addEventListener('message', function(e) {\n  const foo = someDependency(e);\n\n  self.postMessage(whoKnows(foo));\n});\n```\n\n## How it works\n1. We use rollup to rollup all dependencies for your web worker file into a bundle.\n2. We wrap that rollup in a function so that it can be minified and included normally in your code without doing anything.\n3. We return a web worker constructor for your function that will run in the web worker with slight modifications to unify the API (nothing that you, the user should have to worky about).\n\n\n## Modifications to node worker_threads\n* We mirror `on` to `addEventListener` on worker objects\n* We mirror `off` to `removeEventListener` on worker objects\n* We wrap `postMessage` so that the message sent is included as a value for a `data` key on an object as this is how the browser works with postMessage.\n\n## Modifictaion to browser WebWorkers\n* We automagically create a blob url of your code to run in the worker that will be revoked on worker terminate\n* We mirror `addEventListener` to `on` on worker objects\n* We mirror `removeEventListener` to `on` on worker objects\n* We add the created blob url to the worker as an `objURL` property\n\n## Options\n### plugins\nAn array of rollup plugins to bundle the web workers with, you will probably want:\n\n### type\n> Default: 'universal'\n\nThe type of factory to build, can be 'node', 'mock', 'browser', or 'universal'.\n* browser will only work in the browser\n* node will only work in node\n* mock will work everywhere but runs on the same thread\n* universal will work on the browser or node depending on available apis\n\n\n* [@rollup/plugin-node-resolve](https://www.npmjs.com/package/@rollup/plugin-node-resolve)\n* [@rollup/plugin-json](https://www.npmjs.com/package/@rollup/plugin-json)\n* [@rollup/plugin-commonjs](https://www.npmjs.com/package/@rollup/plugin-commonjs)\n","publish_time":1615499262748,"_cnpm_publish_time":1615499262748,"dist-tags":{"latest":"0.5.7"}}