Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interlock-webworkers #21

Open
5 tasks
divmain opened this issue Sep 22, 2016 · 0 comments
Open
5 tasks

interlock-webworkers #21

divmain opened this issue Sep 22, 2016 · 0 comments
Labels

Comments

@divmain
Copy link
Member

divmain commented Sep 22, 2016

Create a plugin that provides a simple API for using web workers from your application code.

Typically, web worker scripts will be generated in a separate build, or minimally by defining a separate entry-point. This can prove cumbersome, especially since there's boilerplate to setup for message passing, and lots of associated build config to get right.

This plugin will alleviate these issues by fulfilling the following requirements:

  • provide a require.worker("./path/to/worker") mechanism in app code
  • set up a separate, specialized entry point for the specified worker module automatically (which will be bundled as normal)
  • replace require.worker("./path/to/worker") with a dynamically generated module that looks something like:
const worker = new Worker("./path/to/worker.bundle.js");
module.exports = onMessage => {
  worker.addEventListener("message", onMessage);
  return msg => { worker.postMessage(msg); };
};
  • allow access to split bundles from inside the web worker by inserting a runtime module provider that uses the importScripts global function instead of creating <script> tags
  • the worker should be configurable, such that a SharedWorker can be created instead [0] [1]
@divmain divmain added the next label Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant