{"name":"rollup-plugin-worker-factory","version":"0.4.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":"c4bc1b20d703c79b9b0808bf15161d77fb425de3","_id":"rollup-plugin-worker-factory@0.4.0","_nodeVersion":"10.22.1","_npmVersion":"6.14.6","dist":{"integrity":"sha512-hT/KXztibS9AZnz4M9BISRedTPJDlVm+vBy3sAcTgEkECuVoJrSmOIguTbPOS1iqBrU6eTU6fvzf/pZNc/m6YQ==","shasum":"28f0bfd6de13055802820ab4917a86ad668affa5","tarball":"http://registry-npm.ywwl.com/rollup-plugin-worker-factory/download/rollup-plugin-worker-factory-0.4.0.tgz","fileCount":10,"unpackedSize":22633,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgDyjxCRA9TVsSAnZWagAAspMP/jJJ5rGa6zVcEQgWsE3h\n51OJu7U7YJ9MNUu/IX917Z5r9M3S8sv2aWg76NoDgKDm2aVjfPDun5mFWii6\nEwndkRhWhzumcNeC+KcpENfl/Dzi/qoMGRWuTzbt7CSliePpHWb1sMXs6yLQ\n3pKu2nujxCn7xZNHqTd6dAj1IoMYVgx1J8v6WXns1vpPb0M2gWXaZbr4iVrQ\nnR/1G4DGgCw/Nvgu3Ibx5zUmqENEy4hwKydSNvFiROX8vm2WG++SYf9YY9id\nkvVeYLisFJNfdiXwyshsdMqRuCMLy9IpokygZwwUSjGzhtV8Heh8ALm65ASV\nodZcmjo954b5FgxNEV6OJncEHcUVH9X1dZ3oXNVy0nvKAWbmwrv92hNwL2Zd\n6I9VBko/MD+RdRDnwJmWd/p0SZoAWl/XxJjxVVKomflruaDNf5JrX6so6G80\njWxfsLNUSXbneEokp9y6ARzKmUUMDAQqH993ek9sFIKRvJbcS0Oc/nip86lj\nlL3Ags+0+TJ6G7620t8FKWg3xOK1Dg9LlgAv+z6x3xSxMNkIhF9GJEGNMk3G\nbxjbuqr6nJmgh7LJGVOlIw5AUzKOAdhx6Om6+ygOq8F3Fteh6pB6h1OUXQFZ\ns46SpKk9KwDXRDL64l+LAk2JieaX5dggEjg+LWjuwaxWyMAfBwPAwFImBVXv\n6pwH\r\n=MD13\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC57jPTF530i+sCyZh5QMnUYroZbAuH5sp8un1RKtcmlAiAH3ILDTuSJ0vSTeokMosdgJ9FQmYJIlgOJSqYgTOdFLg=="}],"size":6455,"noattachment":false,"key":"/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.4.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.4.0_1611606257399_0.3223326000926521"},"_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":1611606257519,"_cnpm_publish_time":1611606257519,"dist-tags":{"latest":"0.5.7"}}