{"name":"rollup-plugin-worker-factory","version":"0.5.7","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":"9dae9823f9e47b0eeb2ad32a91461336977aee7c","_id":"rollup-plugin-worker-factory@0.5.7","_nodeVersion":"14.16.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-DZ9HOy8FFVnx9in/x2DFrbH2Dj3iBMUm5zuisBnfQst2WcDbNicJLveiytgnoKqXQnBm7TPnlEklp4ce1eT1aw==","shasum":"a6043ce4aae34d5b72ff9c1dbd1bef78b79f08b2","tarball":"http://registry-npm.ywwl.com/rollup-plugin-worker-factory/download/rollup-plugin-worker-factory-0.5.7.tgz","fileCount":10,"unpackedSize":27887,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3zsFCRA9TVsSAnZWagAA+BYQAIUNXfFslwv7I1e8KOMY\nGMNUkt906YdiTOgVN6qPffUCXgzTrATxN/I0WsFAdFVkga02HOgjHR5W60ci\nCKIdbwbiw1Tf5KqAuXYWsjGRsQ5r1xK0k5ujXtORD9L1Au7jXUwaSFzz/W6T\npvSIhjSfdb5SNljDUi8CGKzVElDoRM8D+j0YFKNr616l8+uF/WkaiWk3CnFS\nmZgS/uzwgI8wUaXqikDksp2c1jI8PkA/mpWQzIfmYeIPWwpg9x/xLaK+ZY2c\naxCTJtVix/Pzew0BfUpoy0+hM9x59by2GeszkStS6SIK6ScjXQI6RRgLuy8r\ny1d+MapbpOi1E2qayzJuaQOWnrUYAEjArs2Hf9ffqi7ueHY2jtjL1nW0BSoi\nZqNTLtto6BvInJHQojzMBok6FnH1/BbKIweyM17CnKSVzaUhLf4LFgUKLnfs\nbq3HOac7G9OcAXVmbD5XbplT90J+mZQLfKvugEvp1bHEvf2E5FzsV/BZ9YLo\nius5Vicgc/v8zi3myJhry6i6p4YwMOTm5KloONgcficvHyLNjsQeRiWzZYbD\nTTvlAvEYLFFG9XGfoZKna19Ggg0mDlAl77xDfcNZ/btxSJFSDu97jrNOscrd\nEzAW1N7riK1KEZa7K8QmY06Q+lPtxskpQkpMladPH3vMmbFqdochuY+4KRId\nSs4+\r\n=Tgts\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDS/45Uo+CA8j/x/Q2/j/G9bnBytZS16VNucmHifzHztwIhAIRs5hCcZcgI9TM0vuKprm1MxNeYFsT7zH8/S+21w25Y"}],"size":7672,"noattachment":false,"key":"/rollup-plugin-worker-factory/-/rollup-plugin-worker-factory-0.5.7.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.7_1625242372736_0.7666999535367318"},"_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":1625242372857,"_cnpm_publish_time":1625242372857,"dist-tags":{"latest":"0.5.7"}}