{"name":"@surma/rollup-plugin-off-main-thread","version":"1.4.1","description":"Use Rollup with workers and ES6 modules today.","main":"index.js","scripts":{"fmt":"prettier --write 'tests/**/*.js' *.js *.md *.json","test":"node ./run_tests.js"},"author":{"name":"Surma","email":"surma@google.com"},"license":"Apache-2.0","devDependencies":{"chai":"4.2.0","karma":"4.2.0","karma-chai":"0.1.0","karma-chrome-launcher":"3.0.0","karma-firefox-launcher":"1.1.0","karma-mocha":"1.3.0","karma-safari-launcher":"1.0.0","karma-safaritechpreview-launcher":"2.0.2","mocha":"6.1.4","prettier":"1.18.2","rollup":"2.0.0-0"},"repository":{"type":"git","url":"git+https://github.com/surma/rollup-plugin-off-main-thread.git"},"dependencies":{"ejs":"^2.6.1","magic-string":"^0.25.0"},"gitHead":"640c74295778b23b430b40b4c23c93b3ccbe7f4e","bugs":{"url":"https://github.com/surma/rollup-plugin-off-main-thread/issues"},"homepage":"https://github.com/surma/rollup-plugin-off-main-thread#readme","_id":"@surma/rollup-plugin-off-main-thread@1.4.1","_nodeVersion":"12.8.0","_npmVersion":"6.12.1","dist":{"integrity":"sha512-ZPBWYQDdO4JZiTmTP3DABsHhIPA7bEJk9Znk7tZsrbPGanoGo8YxMv//WLx5Cvb+lRgS42+6yiOIYYHCKDmkpQ==","shasum":"bf1343e5a926e5a1da55e3affd761dda4ce143ef","tarball":"http://registry-npm.ywwl.com/@surma/rollup-plugin-off-main-thread/download/@surma/rollup-plugin-off-main-thread-1.4.1.tgz","fileCount":79,"unpackedSize":77601,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeXUSYCRA9TVsSAnZWagAAoF4QAJTYGsDuJcI3CdACCj1T\nmcXxaYmc8LkBGIbbDVevmHf/uwctGMiT8tAkBUrGEfKj3Z2FsxRV+1pkPA06\nJpPbePTmLX9RlfapBfPCW+V33oG5nXPSiE21ijuXskE0kXKX460nD6iHVjmO\nHXaJwAA1HXt0hLEoIQpNh1KVRTM8egssEhDyyTcifYglkYjPv5k47JgBw7A1\nzGpGRpn3l7fkLIwGDS0mm0bZHZVnC7Bdeluz4eYQXL/Q9bykMELKY5tLaaPT\nY75w/at+lPJs51c0jio/vZmdNq9n1CfztUapW0+Z55QLoD62UOMu6YaLSuOe\nkZ+KhZg7KBTVG+Pult/8mxOD02nWXzS3wxF/8awvvmBTgO4amnP9+qXlTIac\n8iDDtN1J/8PwgI778PuEMbYrLYAMyoinnldzNDQb7Wq538NlsaHDTlzY4JzU\ng8nbCsPzuYsVXpNkcO1zh+PCN1PaNgDfJhoM+fTwjqqUdoDwP0ILi/jt66tM\n2DJ7EjbrW+XU2gwPpSZAeOIW1flXcfe9dhGke0sWHCEUqUbZpg0+QGB+rls4\nZi50vu7IrLtdOCu3K5jBjGbTyIsOC1CzqzfjT81MmJs24POujDACUOmXTr7J\n0wMS315b8oPC5XzILYUs2x+uQBq6Bmh82iqWtXt3mpgExgFgLKwTKQg2589T\nQ/Dv\r\n=i3C2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBCYM9ZFiYN29wMkUWytyxe67Vgvl07IIpcW16IIWddUAiEAiikx3GkYBM/EcA6JvHUImh/dM7B8wqvQtbCKvGddxDM="}],"size":14693,"noattachment":false,"key":"/@surma/rollup-plugin-off-main-thread/-/@surma/rollup-plugin-off-main-thread-1.4.1.tgz"},"maintainers":[{"name":"surma","email":"surma@surma.link"}],"_npmUser":{"name":"surma","email":"surma@surma.link"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rollup-plugin-off-main-thread_1.4.1_1583170712219_0.21556866116200646"},"_hasShrinkwrap":false,"readme":"# rollup-plugin-off-main-thread\n\nUse Rollup with workers and ES6 modules _today_.\n\n```\n$ npm install --save @surma/rollup-plugin-off-main-thread\n```\n\nWorkers are JavaScript’s version of threads. [Workers are important to use][when workers] as the main thread is already overloaded, especially on slower or older devices.\n\nThis plugin takes care of shimming module support in workers and allows you to use `new Worker()`.\n\nOMT is the result of merging loadz0r and workz0r.\n\n## Usage\n\nI set up [a gist] to show a full setup with OMT.\n\n### Config\n\n```js\n// rollup.config.js\nimport OMT from \"@surma/rollup-plugin-off-main-thread\";\n\nexport default {\n  input: [\"src/main.js\"],\n  output: {\n    dir: \"dist\",\n    // You _must_ use either “amd” or “esm” as your format.\n    // But note that only very few browsers have native support for\n    // modules in workers.\n    format: \"amd\"\n  },\n  plugins: [OMT()]\n};\n```\n\n### Auto bundling\n\nIn your project's code use a module-relative path via `new URL` to include a Worker:\n\n```js\nconst worker = new Worker(new URL(\"worker.js\", import.meta.url), {\n  type: \"module\"\n});\n```\n\nThis will just work.\n\nIf required, the plugin also supports plain literal paths:\n\n```js\nconst worker = new Worker(\"./worker.js\", { type: \"module\" });\n```\n\nHowever, those are less portable: in Rollup they would result in module-relative\npath, but if used directly in the browser, they'll be relative to the document\nURL instead.\n\nHence, they're deprecated and `new URL` pattern is encouraged instead for portability.\n\n### Importing workers as URLs\n\nIf your worker constructor doesn't match `workerRegexp` (see options below), you might find it easier to import the worker as a URL. In your project's code:\n\n```js\nimport workerURL from \"omt:./worker.js\";\nimport paintWorkletURL from \"omt:./paint-worklet.js\";\n\nconst worker = new Worker(workerURL, { name: \"main-worker\" });\nCSS.paintWorklet.addModule(paintWorkletURL);\n```\n\n`./worker.js` and `./paint-worklet.js` will be added to the output as chunks.\n\n## Options\n\n```js\n{\n  // ...\n  plugins: [OMT(options)];\n}\n```\n\n- `loader`: A string containing the EJS template for the amd loader. If `undefined`, OMT will use `loader.ejs`.\n- `useEval`: Use `fetch()` + `eval()` to load dependencies instead of `<script>` tags and `importScripts()`. _This is not CSP compliant, but is required if you want to use dynamic imports in ServiceWorker_.\n- `workerRegexp`: A RegExp to find `new Workers()` calls. The second capture group _must_ capture the provided file name without the quotes.\n- `amdFunctionName`: Function name to use instead of AMD’s `define`.\n- `prependLoader`: A function that determines whether the loader code should be prepended to a certain chunk. Should return true if the load is suppsoed to be prepended.\n- `urlLoaderScheme`: Scheme to use when importing workers as URLs. If `undefined`, OMT will use `\"omt\"`.\n\n[when workers]: https://dassur.ma/things/when-workers\n[a gist]: https://gist.github.com/surma/a02db7b53eb3e7870bf539b906ff6ff6\n\n---\n\nLicense Apache-2.0\n","publish_time":1583170712340,"_cnpm_publish_time":1583170712340,"dist-tags":{"latest":"2.2.3"}}