{"name":"rollup-plugin-worker-factory","version":"0.2.0","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":"8e9f615ac5abae65ced99e6ae190f6121d369c79","_id":"rollup-plugin-worker-factory@0.2.0","_nodeVersion":"10.22.1","_npmVersion":"6.14.6","dist":{"integrity":"sha512-1swe+UVms2GGTQu/dzKRt4mau4GPX1yWTxrchtN8uFXWvzOElZYXTqZSKyKInv1bHZnlD+Pkv8XM6vfSIWFnvQ==","shasum":"2913cd86227458bd6e0e7df10db3f1f06a662c86","tarball":"http://registry-npm.ywwl.com/rollup-plugin-worker-factory/download/rollup-plugin-worker-factory-0.2.0.tgz","fileCount":6,"unpackedSize":19210,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf28c2CRA9TVsSAnZWagAAjsIP/iYWK50jgvnL9HrnE/ph\nuAw4h/107rYk9PwGJNQItGyCZPOX8cIcg7zYY+yCby2/3Cr2SGG9qy5vK/t+\ncFioq/zuovJqc83GSgH16s33+a82qPZXyDBRUeKdgNhVIZ9R7P/SCQwwlcgr\nDiIr7gv7cgJS1B/dMae1TQxcPl7rN56BgiYJfhq/WUHkscULoQQJdhw2OWPw\nWJGajPw2zhO7W6pVcM8v7tt2K8oK/htGwmaohI9jWyKSnGNNjq/DIIdi0wJ9\nIoM7iCeYQ5h+w8ZsjPimd7sQiNbWhonM+jaNWBJ3dKhRsBLkf+f+UznZY1W0\nLTzOxSQScUddDxEUhrpc2YzexY98nz638WWMnvpkC+KF3Qbvw3AF9D5Lgns4\nwaD39MXKwsXbUClkCJJKEpWUcWCWXg0kCRz45w6AZ6nz8YAQCgADlxD554Gz\nTu2E0tUbIm6RKnHvc0lhFPrHoxexXcneXzsQMtu9ACZjt5FgWn3DcKLSic1V\npskMfqBVM6ymEwBrnIUpcw5zfdEqBcI29pjpQHybRCXkoZMVxALRsA5vYzVA\nlTdxPeF94GXxaAgc95NaGJLaEOQtEXda/F2IqKZliND+AsWH3zihiCfwBmkd\n2f6Qh8eHKEmGP6SkKexzc3P0PcqojQltqvw9h7W1/IYAqVNplXtXTBcr2Uud\n8gW1\r\n=s38h\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBT/MBTl/BC01B8Ql1+BqypKuaPxXaiLsGix0fKWdwnUAiAvcUGTa4C1jQZPlW05gWFForthlUIpQAAmem3f/kqBkA=="}],"size":5510,"noattachment":false,"key":"/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.2.0.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.2.0_1608238901554_0.41096970922064013"},"_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":1608238901698,"_cnpm_publish_time":1608238901698,"dist-tags":{"latest":"0.5.7"}}