Skip to content

Latest commit

 

History

History
30 lines (16 loc) · 1.39 KB

README.md

File metadata and controls

30 lines (16 loc) · 1.39 KB

Thrafe

Pronounced like the name 'Rafe', as in:

My uncle, Thrafe lives in the Cayman Islands.

This is a library that aims to make it simple and straightforward to make typesafe, multithreaded web applications (using Typescript and web workers) -- hence the annoying name, Thrafe: threading + typesafe.

Why?

When working on my CommunicativeCode webapp, I found it tricky to use both Typescript and web workers for the following reasons.

Where / how should types fit it in?

Bungling Bundling

On one side, it's completely unobvious how best to compile & bundle a web worker written in typescript down to a single javascript file so that it can then be executed as a worker in the browser, e.g.:

const worker = new Worker('https://www.my-example-website.com/static/worker.js');

Bundlers are supporting this in different ways, which I think is already confusing.

Vite's solution seems pretty neat, webpack seems to be working on it (not immediately clear to me how this works with typescript), but regardless I don't like how any of the solutions I've seen.

Two-way communication

Anatomy of a Thrafe Implementation