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

Support workers #4

Open
kriskowal opened this issue Sep 17, 2016 · 1 comment
Open

Support workers #4

kriskowal opened this issue Sep 17, 2016 · 1 comment

Comments

@kriskowal
Copy link
Member

This would look like further data- attributes on a script tag that would build a set of entry points for workers. Every worker including the main thread would be able to "spawn" any worker as effectively a child process. The interface for the worker needs to be identical between use in Node.js, in the browser during development, in the browser with a bundle. Each worker would produce a separate bundle and be cross-referenced by relative URL so they can execute each other.

Punting ideas for shared common bundles and service workers as out of scope for minimum viable workers.

@kriskowal
Copy link
Member Author

Also, IO channels need to be consistent between use in Node.js, use in bundler in Node.js, use in Browser during development, use in Browser with bundles. There needs to be a convention for exposing the "executables" to the script and how to expose the communication channel to the worker. It might be that workers and their executors need a conventionally exported main() that the module loader calls.

<script src="boot.js" data-worker="./worker" data-import="./entry"></script>
// entry.js
var child = new require.Worker("./worker");

// worker.js
module.exports = function main(parent) {
    parent.addEventListener("message", ...);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant